Skip to content

Commit ec1ffaf

Browse files
committed
soc: nordic: uicr: Add support for uicr.PROTECTEDMEM
Add support for PROTECTEDMEM. Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 1a5844e commit ec1ffaf

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

scripts/ci/check_compliance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,8 @@ def check_no_undef_outside_kconfig(self, kconf):
12641264
"FOO_SETTING_1",
12651265
"FOO_SETTING_2",
12661266
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
1267+
"GEN_UICR_PROTECTEDMEM", # Used in specialized build tool, not part of main Kconfig
1268+
"GEN_UICR_PROTECTEDMEM_SIZE_BYTES", # Used in specialized build tool, not part of main Kconfig
12671269
"GEN_UICR_SECONDARY", # Used in specialized build tool, not part of main Kconfig
12681270
"GEN_UICR_SECONDARY_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
12691271
"GEN_UICR_SECONDARY_PROCESSOR_VALUE", # Used in specialized build tool, not part of main Kconfig

soc/nordic/common/uicr/gen_uicr.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ def main() -> None:
255255
type=lambda s: int(s, 0),
256256
help="Absolute flash address of the UICR region (decimal or 0x-prefixed hex)",
257257
)
258+
parser.add_argument(
259+
"--protectedmem",
260+
action="store_true",
261+
help="Enable protected memory region in UICR",
262+
)
263+
parser.add_argument(
264+
"--protectedmem-size-bytes",
265+
type=int,
266+
help="Protected memory size in bytes (must be divisible by 4096)",
267+
)
258268
parser.add_argument(
259269
"--secondary",
260270
action="store_true",
@@ -339,6 +349,16 @@ def main() -> None:
339349
uicr.VERSION.MAJOR = UICR_FORMAT_VERSION_MAJOR
340350
uicr.VERSION.MINOR = UICR_FORMAT_VERSION_MINOR
341351

352+
# Handle protected memory configuration
353+
if args.protectedmem:
354+
if args.protectedmem_size_bytes % 4096 != 0:
355+
raise ScriptError(
356+
f"Protected memory size ({args.protectedmem_size_bytes} bytes) "
357+
f"must be divisible by 4096"
358+
)
359+
uicr.PROTECTEDMEM.ENABLE = ENABLED_VALUE
360+
uicr.PROTECTEDMEM.SIZE4KB = args.protectedmem_size_bytes // 4096
361+
342362
# Process periphconf data first and configure UICR completely before creating hex objects
343363
periphconf_hex = IntelHex()
344364
secondary_periphconf_hex = IntelHex()

soc/nordic/common/uicr/gen_uicr/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ endfunction()
4848
if(CMAKE_VERBOSE_MAKEFILE)
4949
endif()
5050

51+
set(protectedmem_args)
5152
set(periphconf_args)
5253
set(periphconf_elfs)
5354
set(merged_hex_file ${APPLICATION_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.hex)
@@ -60,6 +61,12 @@ set(secondary_periphconf_hex_file ${APPLICATION_BINARY_DIR}/zephyr/secondary_per
6061
dt_nodelabel(uicr_path NODELABEL "uicr" REQUIRED)
6162
dt_reg_addr(UICR_ADDRESS PATH ${uicr_path} REQUIRED)
6263

64+
# Handle protected memory configuration
65+
if(CONFIG_GEN_UICR_PROTECTEDMEM)
66+
list(APPEND protectedmem_args --protectedmem)
67+
list(APPEND protectedmem_args --protectedmem-size-bytes ${CONFIG_GEN_UICR_PROTECTEDMEM_SIZE_BYTES})
68+
endif()
69+
6370
if(CONFIG_GEN_UICR_GENERATE_PERIPHCONF)
6471
# gen_uicr.py parses all zephyr.elf files. To find these files (which
6572
# have not been built yet) we scan sibling build directories for
@@ -135,6 +142,7 @@ add_custom_command(
135142
--out-merged-hex ${merged_hex_file}
136143
--out-uicr-hex ${uicr_hex_file}
137144
${periphconf_args}
145+
${protectedmem_args}
138146
${secondary_args}
139147
DEPENDS ${periphconf_elfs} ${secondary_periphconf_elfs}
140148
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}

soc/nordic/common/uicr/gen_uicr/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ config GEN_UICR_GENERATE_PERIPHCONF
1010
When enabled, the UICR generator will populate the
1111
periphconf_partition partition.
1212

13+
config GEN_UICR_PROTECTEDMEM
14+
bool "Enable UICR.PROTECTEDMEM"
15+
help
16+
When enabled, the UICR generator will configure the
17+
protected memory region.
18+
19+
config GEN_UICR_PROTECTEDMEM_SIZE_BYTES
20+
int "Protected memory size in bytes"
21+
default 4096
22+
depends on GEN_UICR_PROTECTEDMEM
23+
help
24+
Size of the protected memory region in bytes.
25+
This value must be divisible by 4096 (4 kiB).
26+
1327
config GEN_UICR_SECONDARY
1428
bool "Enable UICR.SECONDARY.ENABLE"
1529

0 commit comments

Comments
 (0)