@@ -10,7 +10,8 @@ usage: otptool.py [-h] [-j HJSON] [-m VMEM] [-l SV] [-o C] [-r RAW]
10
10
[-k {auto,otp,fuz}] [-e BITS] [-C CONFIG] [-c INT] [-i INT]
11
11
[-w] [-n] [-s] [-E] [-D] [-U] [--empty PARTITION]
12
12
[--clear-bit CLEAR_BIT] [--set-bit SET_BIT]
13
- [--toggle-bit TOGGLE_BIT] [-L | -P | -R] [-v] [-d]
13
+ [--toggle-bit TOGGLE_BIT] [-G {LCVAL,LCTPL,PARTS,REGS}] [-v]
14
+ [-d]
14
15
15
16
QEMU OT tool to manage OTP files.
16
17
23
24
-m VMEM, --vmem VMEM input VMEM file
24
25
-l SV, --lifecycle SV
25
26
input lifecycle system verilog file
26
- -o C, --output C output C file
27
+ -o C, --output C output filename for C file generation
27
28
-r RAW, --raw RAW QEMU OTP raw image file
28
29
29
30
Parameters:
@@ -50,9 +51,8 @@ Commands:
50
51
--set-bit SET_BIT set a bit at specified location
51
52
--toggle-bit TOGGLE_BIT
52
53
toggle a bit at specified location
53
- -L, --generate-lc generate lc_ctrl C arrays
54
- -P, --generate-parts generate partition descriptor C arrays
55
- -R, --generate-regs generate partition register C definitions
54
+ -G {LCVAL,LCTPL,PARTS,REGS}, --generate {LCVAL,LCTPL,PARTS,REGS}
55
+ generate C code, see doc for options
56
56
57
57
Extras:
58
58
-v, --verbose increase verbosity
@@ -124,8 +124,9 @@ Fuse RAW images only use the v1 type.
124
124
the kind of the input VMEM file from its content when this option is not specified or set to
125
125
` auto ` . It is fails to detect the file kind or if the kind needs to be enforced, use this option.
126
126
127
- * ` -L ` generate a file describing the LifeCycle contants as C arrays. Mutually exclusive with the
128
- ` -P ` and ` -R ` option switches. See ` -o ` to specify an output file.
127
+ * ` -G ` can be used to generate C code for QEMU, from OTP and LifeCycle known definitions. See the
128
+ [ Generation] ( #generation ) section for details. See option ` -o ` to specify the path to the file to
129
+ generate
129
130
130
131
* ` -l ` specify the life cycle system verilog file that defines the encoding of the life cycle
131
132
states. This option is not required to generate a RAW image file, but required when the ` -L `
@@ -136,14 +137,8 @@ Fuse RAW images only use the v1 type.
136
137
* ` -n ` tell the script not to attempt to decode the content of encoded fields, such as the hardened
137
138
booleans values. When used, the raw value of each field is printed out.
138
139
139
- * ` -o ` specify the path to the output C file to generate, see ` -L ` , ` -P ` and ` -R ` option switches.
140
- Defaults to the standard output.
141
-
142
- * ` -P ` generate a file describing the OTP partition properties as C arrays. Mutually exclusive with
143
- the ` -L ` and ` -R ` option switches. See ` -o ` to specify an output file.
144
-
145
- * ` -R ` generate a file describing the OTP partition registers as C defintion. Mutually exclusive
146
- with the ` -L ` and ` -P ` option switches. See ` -o ` to specify an output file.
140
+ * ` -o ` specify the path to the output C file to generate, see ` -G ` option. If not specified, the
141
+ generated file is emitted on the standard output.
147
142
148
143
* ` -r ` specify the path to the QEMU OTP RAW image file. When used with the ` -m ` option switch, a
149
144
new QEMU OTP image file is generated. Otherwise, the QEMU OTP RAW image file should exist and is
@@ -194,6 +189,22 @@ If the bit is larger than the data slot, it indicates the location with the ECC
194
189
fuses are organized as 16-bit slots wtih 6-bit ECC, bit 0 to 15 indicates a bit into the data slot,
195
190
while bit 16 to 21 indicates an ECC bit.
196
191
192
+ ### Generation [ #generation]
193
+
194
+ The generation feature may be used to generate part of the OTP and LifeCycle QEMU implementation,
195
+ based on known definitions from the OpenTitan constants. This option accepts on of the following
196
+ argument:
197
+
198
+ * ` LCVAL ` generates a file describing the LifeCycle constants as C arrays. Requires ` -l ` option.
199
+ * ` LCTPL ` generates a file describing the LifeCycle State encoding as a C array. . Requires ` -l `
200
+ option.
201
+ * ` PARTS ` generates a file describing the OTP partition properties as C arrays. Requires ` -j `
202
+ option.
203
+ * ` REGS ` generates a file describing the OTP partition registers as C definitions. Requires ` -j `
204
+ option.
205
+
206
+ See ` -o ` to specify an output file for the generated file.
207
+
197
208
### Examples
198
209
199
210
Generate a QEMU RAW v1 image for the virtual OTP controller, here with an RMA OTP configuration:
@@ -248,10 +259,10 @@ scripts/opentitan/otptool.py -r otp.raw -j otp_ctrl_mmap.hjson -D \
248
259
249
260
Generate a C source file with LifeCycle constant definitions:
250
261
```` sh
251
- scripts/opentitan/otptool.py -L -l lc_ctrl_state_pkg.sv -o lc_state.c
262
+ scripts/opentitan/otptool.py -G LCVAL -l lc_ctrl_state_pkg.sv -o lc_state.c
252
263
````
253
264
254
265
Generates a C source file with OTP partition properties:
255
266
```` sh
256
- scripts/opentitan/otptool.py -j otp_ctrl_mmap.hjson -P -o otp_part.c
267
+ scripts/opentitan/otptool.py -j otp_ctrl_mmap.hjson -G PARTS -o otp_part.c
257
268
````
0 commit comments