Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/opentitan/flashgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ matching signed binary files to help with debugging.
may also be hardcoded in the ROM_EXT application. Changing the default offset may cause the
ROM_EXT to fail to load the BL0 application.

* `-t binfile@address[:elfile]` specify a binary file to store into the data partition of the flash.
* `-t binfile@address` specify a binary file to store into the data partition of the flash.
This is a compatibility option introduced to support the original `opentitantool image assemble`
syntax. In this mode, the file kind and the destination flash bank are guessed from the specified
address. The address should be specified in hexadecimal format. It is possible to specify an
matching ELF file by appending its path after a column separator following the address value. This
option may be repeated to specify multiple files such as the ROM EXT and a bootloader for example.
This option is mutually exclusive with `-b`, `-B`, `-x`, `-X` and `-a`.
syntax. The provided address should be specified in hexadecimal format. Currently, it is not
possible to specify a matching ELF file as the flash debug trailer format is hardcoded to only
support ROM EXT and bootloader binaries in both banks, and does not support arbitrary ELFs.
This option may be repeated to specify multiple files such as the ROM EXT and a bootloader for
example. This option is mutually exclusive with `-b`, `-B`, `-x`, `-X` and `-a`.

* `-X elf` specify an alternative path to the ROM_EXT ELF file. If not specified, the ELF path file
is reconstructed from the specified binary file (from the same directory). The ELF file is only
Expand Down
32 changes: 16 additions & 16 deletions python/qemu/ot/eflash/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,11 @@ def store_bootloader(self, bank: int, dfp: BinaryIO,
self._store_debug_info(ename, elfpath)

def store_ot_files(self, otdescs: list[str]) -> None:
for dpos, otdesc in enumerate(otdescs, start=1):
parts = otdesc.rsplit(':', 1)
if len(parts) > 1:
otdesc = parts[0]
elf_filename = parts[1]
else:
elf_filename = None
for otdesc in otdescs:
# @TODO: add back support for ELFs for convenience debug symbols
# when the flash debug trailer format is changed to support
# arbitrary numbers (and locations) of ELFs, which is also
# needed due to mutable flash.
parts = otdesc.split('@', 1)
if len(parts) < 2:
raise ValueError('Missing address in OT descriptor')
Expand All @@ -376,16 +374,18 @@ def store_ot_files(self, otdescs: list[str]) -> None:
address = int(parts[1], 16)
except ValueError as exc:
raise ValueError('Invalid address in OT descriptor') from exc
bank = address // self.BYTES_PER_BANK
address %= self.BYTES_PER_BANK
kind = 'rom_ext' if address < self.CHIP_ROM_EXT_SIZE_MAX else \
'bootloader'
self._log.info(
'Handling file #%d as %s @ 0x%x in bank %d with%s ELF',
dpos, kind, address, bank, '' if elf_filename else 'out')
max_offset = self.NUM_BANKS * self.BYTES_PER_BANK
if not 0 <= address < max_offset:
raise ValueError(f'Invalid address 0x{address:x} for bin '
f'{basename(bin_filename)}')
with open(bin_filename, 'rb') as bfp:
# func decode should never fail, so no error handling here
getattr(self, f'store_{kind}')(bank, bfp, elf_filename)
data = bfp.read()
address_end = address + len(data)
if not 0 <= address_end <= max_offset:
raise ValueError(f'Binary {basename(bin_filename)} at '
f'0x{address:x}:0x{address_end:x} does not '
f'fit in flash size 0x{max_offset:x}')
self._write(self._header_size + address, data)

def _compare_bin_elf(self, bindesc: RuntimeDescriptor, elfpath: str) \
-> Optional[bool]:
Expand Down
Loading