Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/ci/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,11 @@ def check_no_undef_outside_kconfig(self, kconf):
"FOO_SETTING_1",
"FOO_SETTING_2",
"GEN_UICR_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
"GEN_UICR_PROTECTEDMEM", # Used in specialized build tool, not part of main Kconfig
"GEN_UICR_PROTECTEDMEM_SIZE_BYTES", # Used in specialized build tool, not part of main Kconfig
"GEN_UICR_SECONDARY", # Used in specialized build tool, not part of main Kconfig
"GEN_UICR_SECONDARY_GENERATE_PERIPHCONF", # Used in specialized build tool, not part of main Kconfig
"GEN_UICR_SECONDARY_PROCESSOR_VALUE", # Used in specialized build tool, not part of main Kconfig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to fix the order to pass compliance check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Fixed.

"GEN_UICR_SECURESTORAGE", # Used in specialized build tool, not part of main Kconfig
"HEAP_MEM_POOL_ADD_SIZE_", # Used as an option matching prefix
"HUGETLBFS", # Linux, in boards/xtensa/intel_adsp_cavs25/doc
Expand Down
29 changes: 29 additions & 0 deletions soc/nordic/common/uicr/gen_uicr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
ENABLED_VALUE = 0xFFFF_FFFF
DISABLED_VALUE = 0xBD23_28A8

KB_4 = 4096


class ScriptError(RuntimeError): ...

Expand Down Expand Up @@ -428,6 +430,16 @@ def main() -> None:
type=lambda s: int(s, 0),
help="Size in bytes of cpurad_its_partition (decimal or 0x-prefixed hex)",
)
parser.add_argument(
"--protectedmem",
action="store_true",
help="Enable protected memory region in UICR",
)
parser.add_argument(
"--protectedmem-size-bytes",
type=int,
help="Protected memory size in bytes (must be divisible by 4096)",
)
parser.add_argument(
"--secondary",
action="store_true",
Expand All @@ -439,6 +451,12 @@ def main() -> None:
type=lambda s: int(s, 0),
help="Absolute flash address of the secondary firmware (decimal or 0x-prefixed hex)",
)
parser.add_argument(
"--secondary-processor",
default=0xBD2328A8,
type=lambda s: int(s, 0),
help="Processor to boot for the secondary firmware ",
)
parser.add_argument(
"--secondary-periphconf-address",
default=None,
Expand Down Expand Up @@ -529,6 +547,16 @@ def main() -> None:
uicr.SECURESTORAGE.ITS.APPLICATIONSIZE1KB = args.cpuapp_its_size // 1024
uicr.SECURESTORAGE.ITS.RADIOCORESIZE1KB = args.cpurad_its_size // 1024

# Handle protected memory configuration
if args.protectedmem:
if args.protectedmem_size_bytes % KB_4 != 0:
raise ScriptError(
f"Protected memory size ({args.protectedmem_size_bytes} bytes) "
f"must be divisible by {KB_4}"
)
uicr.PROTECTEDMEM.ENABLE = ENABLED_VALUE
uicr.PROTECTEDMEM.SIZE4KB = args.protectedmem_size_bytes // KB_4

# Process periphconf data first and configure UICR completely before creating hex objects
periphconf_hex = IntelHex()
secondary_periphconf_hex = IntelHex()
Expand Down Expand Up @@ -562,6 +590,7 @@ def main() -> None:
if args.secondary:
uicr.SECONDARY.ENABLE = ENABLED_VALUE
uicr.SECONDARY.ADDRESS = args.secondary_address
uicr.SECONDARY.PROCESSOR = args.secondary_processor

# Handle secondary periphconf if provided
if args.out_secondary_periphconf_hex:
Expand Down
9 changes: 9 additions & 0 deletions soc/nordic/common/uicr/gen_uicr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ endfunction()
if(CMAKE_VERBOSE_MAKEFILE)
endif()

set(protectedmem_args)
set(periphconf_args)
set(periphconf_elfs)
set(merged_hex_file ${APPLICATION_BINARY_DIR}/zephyr/${CONFIG_KERNEL_BIN_NAME}.hex)
Expand Down Expand Up @@ -105,6 +106,12 @@ if(CONFIG_GEN_UICR_SECURESTORAGE)
list(APPEND securestorage_args --cpurad-its-size ${CPURAD_ITS_SIZE})
endif(CONFIG_GEN_UICR_SECURESTORAGE)

# Handle protected memory configuration
if(CONFIG_GEN_UICR_PROTECTEDMEM)
list(APPEND protectedmem_args --protectedmem)
list(APPEND protectedmem_args --protectedmem-size-bytes ${CONFIG_GEN_UICR_PROTECTEDMEM_SIZE_BYTES})
endif()

if(CONFIG_GEN_UICR_GENERATE_PERIPHCONF)
# gen_uicr.py parses all zephyr.elf files. To find these files (which
# have not been built yet) we scan sibling build directories for
Expand Down Expand Up @@ -154,6 +161,7 @@ if(CONFIG_GEN_UICR_SECONDARY)

list(APPEND secondary_args
--secondary-address ${SECONDARY_ADDRESS}
--secondary-processor ${CONFIG_GEN_UICR_SECONDARY_PROCESSOR_VALUE}
)

if(CONFIG_GEN_UICR_SECONDARY_GENERATE_PERIPHCONF)
Expand All @@ -180,6 +188,7 @@ add_custom_command(
--out-uicr-hex ${uicr_hex_file}
${periphconf_args}
${securestorage_args}
${protectedmem_args}
${secondary_args}
DEPENDS ${periphconf_elfs} ${secondary_periphconf_elfs}
WORKING_DIRECTORY ${APPLICATION_BINARY_DIR}
Expand Down
62 changes: 51 additions & 11 deletions soc/nordic/common/uicr/gen_uicr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ config GEN_UICR_GENERATE_PERIPHCONF
When enabled, the UICR generator will populate the
periphconf_partition partition.

config GEN_UICR_SECONDARY
bool "Enable UICR.SECONDARY.ENABLE"

config GEN_UICR_SECONDARY_GENERATE_PERIPHCONF
bool "Generate SECONDARY.PERIPHCONF hex alongside UICR"
default y
depends on GEN_UICR_SECONDARY
help
When enabled, the UICR generator will populate the
secondary_periphconf_partition partition.

config GEN_UICR_SECURESTORAGE
bool "Enable UICR.SECURESTORAGE"
default y
Expand All @@ -43,6 +32,57 @@ config GEN_UICR_SECURESTORAGE
- At least one subpartition must be defined
- Combined subpartition sizes must equal secure_storage_partition size

config GEN_UICR_PROTECTEDMEM
bool "Enable UICR.PROTECTEDMEM"
help
When enabled, the UICR generator will configure the
protected memory region.

config GEN_UICR_PROTECTEDMEM_SIZE_BYTES
int "Protected memory size in bytes"
default 4096
depends on GEN_UICR_PROTECTEDMEM
help
Size of the protected memory region in bytes.
This value must be divisible by 4096 (4 kiB).

config GEN_UICR_SECONDARY
bool "Enable UICR.SECONDARY.ENABLE"

if GEN_UICR_SECONDARY

config GEN_UICR_SECONDARY_GENERATE_PERIPHCONF
bool "Generate SECONDARY.PERIPHCONF hex alongside UICR"
default y
help
When enabled, the UICR generator will populate the
secondary_periphconf_partition partition.

choice GEN_UICR_SECONDARY_PROCESSOR
prompt "Secondary processor selection"
default GEN_UICR_SECONDARY_PROCESSOR_APPLICATION
help
Processor to boot for the secondary firmware.

config GEN_UICR_SECONDARY_PROCESSOR_APPLICATION
bool "APPLICATION processor"
help
Boot secondary firmware on the APPLICATION processor.

config GEN_UICR_SECONDARY_PROCESSOR_RADIOCORE
bool "RADIOCORE processor"
help
Boot secondary firmware on the RADIOCORE processor.

endchoice

config GEN_UICR_SECONDARY_PROCESSOR_VALUE
hex
default 0xBD2328A8 if GEN_UICR_SECONDARY_PROCESSOR_APPLICATION
default 0x1730C77F if GEN_UICR_SECONDARY_PROCESSOR_RADIOCORE

endif # GEN_UICR_SECONDARY

endmenu

source "Kconfig.zephyr"
Loading