Skip to content

Conversation

AlexJones0
Copy link

Currently, the --otdesc option accepts an address for a binary, and then attempts to guess whether the binary is a ROM_EXT or a bootloader file, loading it at hard-coded offsets with relevant size and ELF checks etc. This is not hugely useful and primarily exists for compatibility with the opentitantool image assemble format (it is unclear whether anything still uses this, I don't think so though).

Currently, opentitantool image assemble is being used within OpenTitan to construct an image spanning both flash banks; it is more useful in flashgen.py to be able to place binaries (or any data) of any size at any arbitrary location in flash, so long as it does not exceed the flash capacity. This commit modifies this option to mean "place this data at this location, without care for what it is".

For now, use of ELFs for debug symbol support is dropped from the --otdesc option, because binaries can be loaded which are not ROM_EXTs or bl0s as defined in the flash format (e.g. further boot stages). The flash format currently hardcodes ELFs to only support ROM_EXT and bl0 ELFs in specific locations (also see #193). An ideal solution to this issue would update the flash format in the future to support an arbitrary number of convenience debugging ELFs, at which point this option can be added back, but for now this PR drops support for this option (for --otdesc only, not for --exec and --boot) to prioritise debugging of ROM_EXT tests on Earlgrey.

Aside: in the future it might be nice to extend this to also support placing binaries in INFO pages to essentially support splicing of flash info pages.

Currently the `otdesc` option accepts an address for a binary and then
attempts to guess whether the binary is a ROM_EXT or a bootloader file,
loading it at the hard-coded offsets.

With the result of `opentitantool image assemble` it would instead be
more useful to place binaries arbitrarily, wherever we wish, even across
flash banks to support mirrored flash images. This commit changes the
`otdesc` option to just load the given data at the given offset provided
it does not exceed the maximum flash size. This option is basically
converted to mean "place this data at this location, without care for
what it is".

For now, use of ELFs for debug symbol support is dropped from the
`otdesc` option, because binaries can be loaded that are not ROM_EXTs or
bl0s as defined in the flash format. In the future, the flash format
should be updated to support an arbitrary number of convenience
debugging ELFs, and then this option can be added back, but support for
this is dropped for now when using this option (debug ELFs still remain
if loading ROM_EXT and bl0 files the normal way).

Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
@AlexJones0 AlexJones0 force-pushed the arbitrary_flash_imgs branch from 0549b33 to 9028353 Compare October 2, 2025 15:09
@AlexJones0 AlexJones0 requested a review from rivos-eblot October 2, 2025 15:10
Copy link

@rivos-eblot rivos-eblot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@jwnrt jwnrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlexJones0 AlexJones0 merged commit 7b28086 into lowRISC:ot-9.2.0 Oct 2, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants