File tree Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -1266,6 +1266,8 @@ def check_no_undef_outside_kconfig(self, kconf):
1266
1266
"FOO_SETTING_1" ,
1267
1267
"FOO_SETTING_2" ,
1268
1268
"GEN_UICR_GENERATE_PERIPHCONF" , # Used in specialized build tool, not part of main Kconfig
1269
+ "GEN_UICR_PROTECTEDMEM" , # Used in specialized build tool, not part of main Kconfig
1270
+ "GEN_UICR_PROTECTEDMEM_SIZE_BYTES" , # Used in specialized build tool, not part of main Kconfig
1269
1271
"GEN_UICR_SECONDARY" , # Used in specialized build tool, not part of main Kconfig
1270
1272
"GEN_UICR_SECONDARY_GENERATE_PERIPHCONF" , # Used in specialized build tool, not part of main Kconfig
1271
1273
"GEN_UICR_SECONDARY_PROCESSOR_VALUE" , # Used in specialized build tool, not part of main Kconfig
Original file line number Diff line number Diff line change 25
25
ENABLED_VALUE = 0xFFFF_FFFF
26
26
DISABLED_VALUE = 0xBD23_28A8
27
27
28
+ KB_4 = 4096
29
+
28
30
29
31
class ScriptError (RuntimeError ): ...
30
32
@@ -255,6 +257,16 @@ def main() -> None:
255
257
type = lambda s : int (s , 0 ),
256
258
help = "Absolute flash address of the UICR region (decimal or 0x-prefixed hex)" ,
257
259
)
260
+ parser .add_argument (
261
+ "--protectedmem" ,
262
+ action = "store_true" ,
263
+ help = "Enable protected memory region in UICR" ,
264
+ )
265
+ parser .add_argument (
266
+ "--protectedmem-size-bytes" ,
267
+ type = int ,
268
+ help = "Protected memory size in bytes (must be divisible by 4096)" ,
269
+ )
258
270
parser .add_argument (
259
271
"--secondary" ,
260
272
action = "store_true" ,
@@ -339,6 +351,16 @@ def main() -> None:
339
351
uicr .VERSION .MAJOR = UICR_FORMAT_VERSION_MAJOR
340
352
uicr .VERSION .MINOR = UICR_FORMAT_VERSION_MINOR
341
353
354
+ # Handle protected memory configuration
355
+ if args .protectedmem :
356
+ if args .protectedmem_size_bytes % KB_4 != 0 :
357
+ raise ScriptError (
358
+ f"Protected memory size ({ args .protectedmem_size_bytes } bytes) "
359
+ f"must be divisible by { KB_4 } "
360
+ )
361
+ uicr .PROTECTEDMEM .ENABLE = ENABLED_VALUE
362
+ uicr .PROTECTEDMEM .SIZE4KB = args .protectedmem_size_bytes // KB_4
363
+
342
364
# Process periphconf data first and configure UICR completely before creating hex objects
343
365
periphconf_hex = IntelHex ()
344
366
secondary_periphconf_hex = IntelHex ()
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ endfunction()
48
48
if (CMAKE_VERBOSE_MAKEFILE )
49
49
endif ()
50
50
51
+ set (protectedmem_args)
51
52
set (periphconf_args)
52
53
set (periphconf_elfs)
53
54
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
60
61
dt_nodelabel(uicr_path NODELABEL "uicr" REQUIRED)
61
62
dt_reg_addr(UICR_ADDRESS PATH ${uicr_path} REQUIRED)
62
63
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
+
63
70
if (CONFIG_GEN_UICR_GENERATE_PERIPHCONF)
64
71
# gen_uicr.py parses all zephyr.elf files. To find these files (which
65
72
# have not been built yet) we scan sibling build directories for
@@ -135,6 +142,7 @@ add_custom_command(
135
142
--out-merged-hex ${merged_hex_file}
136
143
--out-uicr-hex ${uicr_hex_file}
137
144
${periphconf_args}
145
+ ${protectedmem_args}
138
146
${secondary_args}
139
147
DEPENDS ${periphconf_elfs} ${secondary_periphconf_elfs}
140
148
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
Original file line number Diff line number Diff line change @@ -10,6 +10,20 @@ config GEN_UICR_GENERATE_PERIPHCONF
10
10
When enabled, the UICR generator will populate the
11
11
periphconf_partition partition.
12
12
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
+
13
27
config GEN_UICR_SECONDARY
14
28
bool "Enable UICR.SECONDARY.ENABLE"
15
29
You can’t perform that action at this time.
0 commit comments