Skip to content

Commit

Permalink
[otp] Allow partitions to automatically determine size
Browse files Browse the repository at this point in the history
- This is mainly done to support lowRISC#6404
- Unallocated bits can optionally be allocated to other
  partitions.

Signed-off-by: Timothy Chen <[email protected]>

[otp] slightly re-arrange code

- done to ensure size calculation is NOT done before
  validation.

Signed-off-by: Timothy Chen <[email protected]>

[otp] Allow unused otp bits to be distributed

- Add a new attribute called "absorb" to partitions.
- The "absorb" attribute indicates a partition is willing
  to accept extra bits.

Signed-off-by: Timothy Chen <[email protected]>

[otp] Do not enable absorb function for now

Signed-off-by: Timothy Chen <[email protected]>
  • Loading branch information
Timothy Chen authored and Muqing-Liu committed Aug 18, 2021
1 parent df4d8d3 commit 9b52780
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 138 deletions.
38 changes: 19 additions & 19 deletions hw/ip/otp_ctrl/data/otp_ctrl.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
{ name: "HwCfgSize",
desc: "Size of the HW_CFG partition",
type: "int",
default: "208",
default: "80",
local: "true"
},
{ name: "DeviceIdOffset",
Expand Down Expand Up @@ -432,7 +432,7 @@
{ name: "HwCfgDigestOffset",
desc: "Offset of HW_CFG_DIGEST",
type: "int",
default: "1736",
default: "1608",
local: "true"
},
{ name: "HwCfgDigestSize",
Expand All @@ -444,7 +444,7 @@
{ name: "Secret0Offset",
desc: "Offset of the SECRET0 partition",
type: "int",
default: "1744",
default: "1616",
local: "true"
},
{ name: "Secret0Size",
Expand All @@ -456,7 +456,7 @@
{ name: "TestUnlockTokenOffset",
desc: "Offset of TEST_UNLOCK_TOKEN",
type: "int",
default: "1744",
default: "1616",
local: "true"
},
{ name: "TestUnlockTokenSize",
Expand All @@ -468,7 +468,7 @@
{ name: "TestExitTokenOffset",
desc: "Offset of TEST_EXIT_TOKEN",
type: "int",
default: "1760",
default: "1632",
local: "true"
},
{ name: "TestExitTokenSize",
Expand All @@ -480,7 +480,7 @@
{ name: "Secret0DigestOffset",
desc: "Offset of SECRET0_DIGEST",
type: "int",
default: "1776",
default: "1648",
local: "true"
},
{ name: "Secret0DigestSize",
Expand All @@ -492,7 +492,7 @@
{ name: "Secret1Offset",
desc: "Offset of the SECRET1 partition",
type: "int",
default: "1784",
default: "1656",
local: "true"
},
{ name: "Secret1Size",
Expand All @@ -504,7 +504,7 @@
{ name: "FlashAddrKeySeedOffset",
desc: "Offset of FLASH_ADDR_KEY_SEED",
type: "int",
default: "1784",
default: "1656",
local: "true"
},
{ name: "FlashAddrKeySeedSize",
Expand All @@ -516,7 +516,7 @@
{ name: "FlashDataKeySeedOffset",
desc: "Offset of FLASH_DATA_KEY_SEED",
type: "int",
default: "1816",
default: "1688",
local: "true"
},
{ name: "FlashDataKeySeedSize",
Expand All @@ -528,7 +528,7 @@
{ name: "SramDataKeySeedOffset",
desc: "Offset of SRAM_DATA_KEY_SEED",
type: "int",
default: "1848",
default: "1720",
local: "true"
},
{ name: "SramDataKeySeedSize",
Expand All @@ -540,7 +540,7 @@
{ name: "Secret1DigestOffset",
desc: "Offset of SECRET1_DIGEST",
type: "int",
default: "1864",
default: "1736",
local: "true"
},
{ name: "Secret1DigestSize",
Expand All @@ -552,7 +552,7 @@
{ name: "Secret2Offset",
desc: "Offset of the SECRET2 partition",
type: "int",
default: "1872",
default: "1744",
local: "true"
},
{ name: "Secret2Size",
Expand All @@ -564,7 +564,7 @@
{ name: "RmaTokenOffset",
desc: "Offset of RMA_TOKEN",
type: "int",
default: "1872",
default: "1744",
local: "true"
},
{ name: "RmaTokenSize",
Expand All @@ -576,7 +576,7 @@
{ name: "CreatorRootKeyShare0Offset",
desc: "Offset of CREATOR_ROOT_KEY_SHARE0",
type: "int",
default: "1888",
default: "1760",
local: "true"
},
{ name: "CreatorRootKeyShare0Size",
Expand All @@ -588,7 +588,7 @@
{ name: "CreatorRootKeyShare1Offset",
desc: "Offset of CREATOR_ROOT_KEY_SHARE1",
type: "int",
default: "1920",
default: "1792",
local: "true"
},
{ name: "CreatorRootKeyShare1Size",
Expand All @@ -600,7 +600,7 @@
{ name: "Secret2DigestOffset",
desc: "Offset of SECRET2_DIGEST",
type: "int",
default: "1952",
default: "1824",
local: "true"
},
{ name: "Secret2DigestSize",
Expand All @@ -612,7 +612,7 @@
{ name: "LifeCycleOffset",
desc: "Offset of the LIFE_CYCLE partition",
type: "int",
default: "1960",
default: "1832",
local: "true"
},
{ name: "LifeCycleSize",
Expand All @@ -624,7 +624,7 @@
{ name: "LcTransitionCntOffset",
desc: "Offset of LC_TRANSITION_CNT",
type: "int",
default: "1960",
default: "1832",
local: "true"
},
{ name: "LcTransitionCntSize",
Expand All @@ -636,7 +636,7 @@
{ name: "LcStateOffset",
desc: "Offset of LC_STATE",
type: "int",
default: "2008",
default: "1880",
local: "true"
},
{ name: "LcStateSize",
Expand Down
63 changes: 30 additions & 33 deletions hw/ip/otp_ctrl/data/otp_ctrl_mmap.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@
{
name: "CREATOR_SW_CFG",
variant: "Unbuffered",
//absorb: true,
size: "768", // in bytes
secret: "False",
sw_digest: "True",
hw_digest: "False",
secret: false,
sw_digest: true,
hw_digest: false,
write_lock: "Digest",
read_lock: "CSR",
key_sel: "NoKey",
bkout_type: "False", // Do not generate a breakout type for this partition.
bkout_type: false, // Do not generate a breakout type for this partition.
items: [
{
name: "CREATOR_SW_CFG_AST_CFG",
Expand All @@ -110,14 +111,15 @@
{
name: "OWNER_SW_CFG",
variant: "Unbuffered",
//absorb: true,
size: "768", // in bytes
secret: "False",
sw_digest: "True",
hw_digest: "False",
secret: false,
sw_digest: true,
hw_digest: false,
write_lock: "Digest",
read_lock: "CSR",
key_sel: "NoKey",
bkout_type: "False",
bkout_type: false,
items: [
{
name: "ROM_ERROR_REPORTING",
Expand Down Expand Up @@ -169,14 +171,13 @@
{
name: "HW_CFG",
variant: "Buffered",
size: "208", // in bytes
secret: "False",
sw_digest: "False",
hw_digest: "True",
secret: false,
sw_digest: false,
hw_digest: true,
write_lock: "Digest",
read_lock: "None",
key_sel: "NoKey",
bkout_type: "True",
bkout_type: true,
items: [
{
name: "DEVICE_ID",
Expand Down Expand Up @@ -224,14 +225,13 @@
{
name: "SECRET0",
variant: "Buffered",
size: "40", // in bytes
secret: "True",
sw_digest: "False",
hw_digest: "True",
secret: true,
sw_digest: false,
hw_digest: true,
write_lock: "Digest",
read_lock: "Digest",
key_sel: "Secret0Key",
bkout_type: "False",
bkout_type: false,
items: [
{
name: "TEST_UNLOCK_TOKEN",
Expand All @@ -253,14 +253,13 @@
{
name: "SECRET1",
variant: "Buffered",
size: "88", // in bytes
secret: "True",
sw_digest: "False",
hw_digest: "True",
secret: true,
sw_digest: false,
hw_digest: true,
write_lock: "Digest",
read_lock: "Digest",
key_sel: "Secret1Key",
bkout_type: "False",
bkout_type: false,
items: [
{
name: "FLASH_ADDR_KEY_SEED",
Expand All @@ -285,14 +284,13 @@
{
name: "SECRET2",
variant: "Buffered",
size: "88", // in bytes
secret: "True",
sw_digest: "False",
hw_digest: "True",
secret: true,
sw_digest: false,
hw_digest: true,
write_lock: "Digest",
read_lock: "Digest",
key_sel: "Secret2Key",
bkout_type: "False",
bkout_type: false,
items: [
{
name: "RMA_TOKEN",
Expand All @@ -316,14 +314,13 @@
{
name: "LIFE_CYCLE",
variant: "LifeCycle",
size: "88", // in bytes
secret: "False",
sw_digest: "False",
hw_digest: "False",
secret: false,
sw_digest: false,
hw_digest: false,
write_lock: "None",
read_lock: "None",
key_sel: "NoKey",
bkout_type: "False",
bkout_type: false,
items: [
// The life cycle transition count is specified
// first such that any programming attempt of the life cycle
Expand Down
30 changes: 15 additions & 15 deletions hw/ip/otp_ctrl/doc/otp_ctrl_mmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ It has been generated with ./util/design/gen-otp-mmap.py
| | | | 32bit | ROM_ALERT_TIMEOUT_CYCLES | 0x4A4 | 16 |
| | | | 32bit | ROM_ALERT_PHASE_CYCLES | 0x4B4 | 64 |
| | | | 64bit | [OWNER_SW_CFG_DIGEST](#Reg_owner_sw_cfg_digest_0) | 0x5F8 | 8 |
| 2 | HW_CFG | 208 | 32bit | DEVICE_ID | 0x600 | 32 |
| 2 | HW_CFG | 80 | 32bit | DEVICE_ID | 0x600 | 32 |
| | | | 32bit | MANUF_STATE | 0x620 | 32 |
| | | | 32bit | EN_SRAM_IFETCH | 0x640 | 1 |
| | | | 32bit | EN_CSRNG_SW_APP_READ | 0x641 | 1 |
| | | | 32bit | EN_ENTROPY_SRC_FW_READ | 0x642 | 1 |
| | | | 32bit | EN_ENTROPY_SRC_FW_OVER | 0x643 | 1 |
| | | | 64bit | [HW_CFG_DIGEST](#Reg_hw_cfg_digest_0) | 0x6C8 | 8 |
| 3 | SECRET0 | 40 | 64bit | TEST_UNLOCK_TOKEN | 0x6D0 | 16 |
| | | | 64bit | TEST_EXIT_TOKEN | 0x6E0 | 16 |
| | | | 64bit | [SECRET0_DIGEST](#Reg_secret0_digest_0) | 0x6F0 | 8 |
| 4 | SECRET1 | 88 | 64bit | FLASH_ADDR_KEY_SEED | 0x6F8 | 32 |
| | | | 64bit | FLASH_DATA_KEY_SEED | 0x718 | 32 |
| | | | 64bit | SRAM_DATA_KEY_SEED | 0x738 | 16 |
| | | | 64bit | [SECRET1_DIGEST](#Reg_secret1_digest_0) | 0x748 | 8 |
| 5 | SECRET2 | 88 | 64bit | RMA_TOKEN | 0x750 | 16 |
| | | | 64bit | CREATOR_ROOT_KEY_SHARE0 | 0x760 | 32 |
| | | | 64bit | CREATOR_ROOT_KEY_SHARE1 | 0x780 | 32 |
| | | | 64bit | [SECRET2_DIGEST](#Reg_secret2_digest_0) | 0x7A0 | 8 |
| 6 | LIFE_CYCLE | 88 | 32bit | LC_TRANSITION_CNT | 0x7A8 | 48 |
| | | | 32bit | LC_STATE | 0x7D8 | 40 |
| | | | 64bit | [HW_CFG_DIGEST](#Reg_hw_cfg_digest_0) | 0x648 | 8 |
| 3 | SECRET0 | 40 | 64bit | TEST_UNLOCK_TOKEN | 0x650 | 16 |
| | | | 64bit | TEST_EXIT_TOKEN | 0x660 | 16 |
| | | | 64bit | [SECRET0_DIGEST](#Reg_secret0_digest_0) | 0x670 | 8 |
| 4 | SECRET1 | 88 | 64bit | FLASH_ADDR_KEY_SEED | 0x678 | 32 |
| | | | 64bit | FLASH_DATA_KEY_SEED | 0x698 | 32 |
| | | | 64bit | SRAM_DATA_KEY_SEED | 0x6B8 | 16 |
| | | | 64bit | [SECRET1_DIGEST](#Reg_secret1_digest_0) | 0x6C8 | 8 |
| 5 | SECRET2 | 88 | 64bit | RMA_TOKEN | 0x6D0 | 16 |
| | | | 64bit | CREATOR_ROOT_KEY_SHARE0 | 0x6E0 | 32 |
| | | | 64bit | CREATOR_ROOT_KEY_SHARE1 | 0x700 | 32 |
| | | | 64bit | [SECRET2_DIGEST](#Reg_secret2_digest_0) | 0x720 | 8 |
| 6 | LIFE_CYCLE | 88 | 32bit | LC_TRANSITION_CNT | 0x728 | 48 |
| | | | 32bit | LC_STATE | 0x758 | 40 |
Loading

0 comments on commit 9b52780

Please sign in to comment.