Skip to content

Commit

Permalink
Add OTP settings JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
will-v-pi committed Nov 15, 2024
1 parent 512df57 commit 9e7b543
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ These commands will set/get specific rows of OTP. By default, they will write/re

### load

This command allows loading of a range of OTP rows onto the device. The source can be a binary file, or a JSON file such as the one output by `picotool sign`.
This command allows loading of a range of OTP rows onto the device. The source can be a binary file, or a JSON file such as the one output by `picotool sign`. The schema for this JSON file is [here](json/schemas/otp-schema.json)
For example, if you wish to sign a binary and then test secure boot with it, you can run the following set of commands:
```text
$ picotool sign hello_world.elf hello_world.signed.elf private.pem otp.json
Expand Down
50 changes: 50 additions & 0 deletions json/schemas/otp-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "OTP Settings",
"description": "OTP Settings",
"type": "object",
"properties": {"$schema": {}},
"patternProperties": {
"^\\d{1,2}:\\d{1,2}$": {
"description": "Generic OTP Row",
"type": "object",
"properties": {
"ecc": {
"description": "Protect with ECC",
"type": "boolean"
},
"value": {
"description": "Value to write",
"type": ["array", "string", "integer"],
"pattern": "^0x[0-9a-fA-F]{1,6}$",
"items": {
"description": "Data Byte",
"type": ["string", "integer"],
"pattern": "^0x[0-9a-fA-F]{1,2}$"
}
}
},
"additionalProperties": false,
"required": ["ecc", "value"]
},
"^[\\d\\w_]+$": {
"description": "Defined OTP Row",
"type": ["object", "array", "string", "integer"],
"pattern": "^0x[0-9a-fA-F]{1,6}$",
"items": {
"description": "Data Byte",
"type": ["string", "integer"],
"pattern": "^0x[0-9a-fA-F]{1,2}$"
},
"patternProperties": {
"^[\\d\\w_]+$": {
"description": "OTP Field",
"type": ["string", "integer"],
"pattern": "^0x[0-9a-fA-F]{1,6}$"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}

0 comments on commit 9e7b543

Please sign in to comment.