-
Notifications
You must be signed in to change notification settings - Fork 11
tools
: Improve ROM image support
#208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
498193e
[ot] python/qemu: ot.rom.image: add scramble feature to ROM images
rivos-eblot cc4c8c5
[ot] python/qemu: ot.rom.image: add support for plain and scrambed VM…
rivos-eblot 7368f68
[ot] python/qemu: ot.rom.image: add alternative output file formats
rivos-eblot 8ef36de
[ot] python/qemu: ot.rom.image: load secrets from QEMU config file
rivos-eblot 960522b
[ot] python/qemu: ot.rom.image: add new scrambling mode without S&P
rivos-eblot 4f6d140
[ot] scripts/opentitan: romtool.py: add a tiny helper script to scram…
rivos-eblot ae54706
[ot] docs/opentitan: romtool: add initial documentation
rivos-eblot 3324652
[ot] python/qemu: ot.util.prince: improve execution time
rivos-eblot a606f35
[ot] python/qemu: ot.rom.image: improve execution time
rivos-eblot 6c04f5f
[ot] hw/opentitan: ot_rom_ctrl: implement local address scrambling an…
rivos-eblot c6e73dd
[ot] hw/opentitan: ot_rom_ctrl_img: improve VMEM detection resilience
rivos-eblot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# `romtool.py` | ||
|
||
`romtool.py` converts ROM image between different file formats. | ||
|
||
Supported input formats: | ||
* `ELF`: RISC-V RV32 executable file (only supported as input ROM file) | ||
* `BIN`: RISC-V RV32 executable file | ||
* `VMEM`: Plain VMEM text file | ||
* `SVMEM`: Scrambled VMEM text file with 7-bit SEC-DED | ||
* `HEX`: Scrambled HEX text file with 7-bit SEC-DED | ||
|
||
## Usage | ||
|
||
````text | ||
usage: romtool.py [-h] -c CFG [-o OUTPUT] [-i ROM_ID] [-z SIZE] | ||
[-f {HEX,BIN,SVMEM,VMEM}] [-s] [-v] [-d] | ||
rom | ||
|
||
QEMU OT tool to generate a scrambled ROM image. | ||
|
||
options: | ||
-h, --help show this help message and exit | ||
|
||
Files: | ||
rom input ROM image file | ||
-c, --config CFG input QEMU OT config file | ||
-o, --output OUTPUT output ROM image file | ||
|
||
Parameters: | ||
-i, --rom-id ROM_ID ROM image identifier | ||
-z, --rom-size SIZE ROM image size in bytes (accepts Ki suffix) | ||
-f, --output-format {HEX,BIN,SVMEM,VMEM} | ||
Output file format (default: HEX) | ||
-s, --subst-perm Enable legacy mode with S&P mode | ||
|
||
Extras: | ||
-v, --verbose increase verbosity | ||
-d, --debug enable debug mode | ||
```` | ||
|
||
### Arguments | ||
|
||
* `-c` specify a QEMU [configuration file](otcfg.md) from which to read all the cryptographic | ||
constants. See [`cfggen.py`](cfggen.md) tool to generate such a file. | ||
|
||
* `-d` only useful to debug the script, reports any Python traceback to the standard error stream. | ||
|
||
* `-f` output file format. `HEX` format always output scrambled/SEC-DED data, `SVMEM` specifies a | ||
VMEM format with scrambled/SEC-DED data. Note: input file format is automatically detected from | ||
the content of the input ROM file. | ||
|
||
* `-i` ROM identifier. Required for platforms with multiple ROMs | ||
|
||
* `-o` outfile file, default to stdout (beware when using a binary format) | ||
|
||
* `-s` use legacy scrambling scheme, with extra substitute and permute stages, but less PRINCE | ||
stages. Only useful for older files. | ||
|
||
* `-v` can be repeated to increase verbosity of the script, mostly for debug purpose. | ||
|
||
* `-z` ROM file size. Required for all input file formats but the `HEX` or `SVMEM` format. | ||
`Ki` (kilobytes) suffix is supported. | ||
|
||
### Examples | ||
|
||
Generate a scrambled with SEC-DED data in HEX format: | ||
````sh | ||
# EarlGrey | ||
scripts/opentitan/romtool.py -c ot.cfg -z 32Ki -o rom.hex rom.elf | ||
# Darjeeling (base ROM) | ||
scripts/opentitan/romtool.py -c ot.cfg -z 32Ki -i 0 -o rom0.hex rom0.elf | ||
```` | ||
|
||
Extract clear data from a scrambled HEX file: | ||
````sh | ||
# EarlGrey | ||
scripts/opentitan/romtool.py -c ot.cfg -f VMEM -o rom.vmem rom.hex | ||
# Darjeeling (base ROM) | ||
scripts/opentitan/romtool.py -c ot.cfg -i 0 -f VMEM -o rom.vmem rom.hex | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.