Skip to content

Commit

Permalink
suit: Add build asserts for SUIT storage partition
Browse files Browse the repository at this point in the history
Add build asserts that check if all SUIT storage partitions are defined
within the globally defined SUIT storage area.

Ref: NCSDK-26649

Signed-off-by: Tomasz Chyrowicz <[email protected]>
  • Loading branch information
tomchy authored and rlubos committed May 24, 2024
1 parent 740378b commit 397a2f8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
19 changes: 19 additions & 0 deletions subsys/suit/storage/src/suit_storage_nrf54h20.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

LOG_MODULE_REGISTER(suit_storage, CONFIG_SUIT_LOG_LEVEL);

/* SUIT storage partition is defined as reserved-memory region, thus it uses absolute addresses. */
#define SUIT_STORAGE_OFFSET \
(FIXED_PARTITION_OFFSET(suit_storage_partition) - DT_REG_ADDR(DT_CHOSEN(zephyr_flash)))
#define SUIT_STORAGE_SIZE FIXED_PARTITION_SIZE(suit_storage_partition)
#define SUIT_STORAGE_NORDIC_ADDRESS suit_plat_mem_nvm_ptr_get(SUIT_STORAGE_NORDIC_OFFSET)
#define SUIT_STORAGE_NORDIC_OFFSET FIXED_PARTITION_OFFSET(cpusec_suit_storage)
#define SUIT_STORAGE_NORDIC_SIZE FIXED_PARTITION_SIZE(cpusec_suit_storage)
Expand All @@ -22,6 +26,21 @@ LOG_MODULE_REGISTER(suit_storage, CONFIG_SUIT_LOG_LEVEL);
#define SUIT_STORAGE_APP_OFFSET FIXED_PARTITION_OFFSET(cpuapp_suit_storage)
#define SUIT_STORAGE_APP_SIZE FIXED_PARTITION_SIZE(cpuapp_suit_storage)

BUILD_ASSERT((SUIT_STORAGE_OFFSET <= SUIT_STORAGE_NORDIC_OFFSET) &&
(SUIT_STORAGE_NORDIC_OFFSET + SUIT_STORAGE_NORDIC_SIZE <=
SUIT_STORAGE_OFFSET + SUIT_STORAGE_SIZE),
"Secure storage must be defined within SUIT storage partition");

BUILD_ASSERT((SUIT_STORAGE_OFFSET <= SUIT_STORAGE_RAD_OFFSET) &&
(SUIT_STORAGE_RAD_OFFSET + SUIT_STORAGE_RAD_SIZE <=
SUIT_STORAGE_OFFSET + SUIT_STORAGE_SIZE),
"Radiocore storage must be defined within SUIT storage partition");

BUILD_ASSERT((SUIT_STORAGE_OFFSET <= SUIT_STORAGE_APP_OFFSET) &&
(SUIT_STORAGE_APP_OFFSET + SUIT_STORAGE_APP_SIZE <=
SUIT_STORAGE_OFFSET + SUIT_STORAGE_SIZE),
"Application storage must be defined within SUIT storage partition");

typedef uint8_t suit_storage_digest_t[32];

struct suit_storage_nvv {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
#size-cells = <1>;

/* Use the last 32 kB of SecDom SUIT NVM storage. */
suit_storage_partition: partition@1e9000 {
reg = <0x1e9000 DT_SIZE_K(32)>;
};

/* Use the first 4kB as area reserved for Secure domain. */
cpusec_suit_storage: partition@1e7000 {
reg = <0x1e7000 DT_SIZE_K(4)>;
cpusec_suit_storage: partition@1eb000 {
reg = <0x1eb000 DT_SIZE_K(4)>;
};

/* Use the next 4kB as area reserved for Radio domain. */
cpurad_suit_storage: partition@1e8000 {
reg = <0x1e8000 DT_SIZE_K(4)>;
cpurad_suit_storage: partition@1ec000 {
reg = <0x1ec000 DT_SIZE_K(4)>;
};

/* Use the next 8kB as area reserved for Application domain. */
cpuapp_suit_storage: partition@1e9000 {
reg = <0x1e9000 DT_SIZE_K(8)>;
cpuapp_suit_storage: partition@1ed000 {
reg = <0x1ed000 DT_SIZE_K(8)>;
};
};
};
16 changes: 10 additions & 6 deletions tests/subsys/suit/storage_nrf54h20/boards/native_posix.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
#size-cells = <1>;

/* Use the last 32 kB of SecDom SUIT NVM storage. */
suit_storage_partition: partition@1e9000 {
reg = <0x1e9000 DT_SIZE_K(32)>;
};

/* Use the first 4kB as area reserved for Secure domain. */
cpusec_suit_storage: partition@1e7000 {
reg = <0x1e7000 DT_SIZE_K(4)>;
cpusec_suit_storage: partition@1eb000 {
reg = <0x1eb000 DT_SIZE_K(4)>;
};

/* Use the next 4kB as area reserved for Radio domain. */
cpurad_suit_storage: partition@1e8000 {
reg = <0x1e8000 DT_SIZE_K(4)>;
cpurad_suit_storage: partition@1ec000 {
reg = <0x1ec000 DT_SIZE_K(4)>;
};

/* Use the next 8kB as area reserved for Application domain. */
cpuapp_suit_storage: partition@1e9000 {
reg = <0x1e9000 DT_SIZE_K(8)>;
cpuapp_suit_storage: partition@1ed000 {
reg = <0x1ed000 DT_SIZE_K(8)>;
};
};
};

0 comments on commit 397a2f8

Please sign in to comment.