Skip to content

Conversation

SebastianBoe
Copy link
Contributor

@SebastianBoe SebastianBoe commented Sep 9, 2025

Add support for PROTECTEDMEM.

Add support for uicr.SECONDARY.PROCESSOR.

nika-nordic
nika-nordic previously approved these changes Sep 11, 2025

# Handle protected memory configuration
if args.protectedmem:
if args.protectedmem_size_bytes % 4096 != 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Some variable named KB_4 would make this easier to read IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 14 to 15
The sample uses UICR (User Information Configuration Registers) to configure
secondary boot and protected memory regions, then intentionally corrupts the
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we state explicitly that we enable the secondary boot? Not only configure it, some users might assume that it is enabled by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

************

* nRF54H20DK board
* Zephyr SDK 0.17.0 or later
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to state this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 99 to 102
* ``CONFIG_ARM_MPU=n``: Disables the MPU to allow memory corruption
* ``CONFIG_GEN_UICR_SECONDARY=y``: Enables secondary boot in UICR
* ``CONFIG_GEN_UICR_PROTECTEDMEM=y``: Enables protected memory in UICR
* ``CONFIG_FLASH_LOAD_OFFSET=0x1b0000``: Places secondary image at correct address
Copy link
Contributor

Choose a reason for hiding this comment

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

For which sample? Does both set all of these?

Copy link
Contributor Author

@SebastianBoe SebastianBoe Sep 15, 2025

Choose a reason for hiding this comment

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

Removed docs.

The config is most easily understood by reading the config files.


* **Primary Image**: Located at ``0xe030000`` (default slot0_partition)
* **Secondary Image**: Located at ``0xe1b0000`` (secondary_partition)
* **UICR Configuration**: Generated and placed at ``0xfff8000``
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have this here? Isn't that part of the nRF54H20 architecture and not set by this sample? Does it give any value to present it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

/* Corrupt the protected memory (This is only possible because we
* have disabled CONFIG_ARM_MPU).
*/
*((volatile uint32_t *)0xe030000) = 0x5EB0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this its not clear that 0xe0300000 is covered by PROTECTEDMEM.

The docs states that PROTECTEDMEM starts from the end of RSLOT, so at the start of this image, but its not clear that this is 0xe0300000.

would it be better to use the symbols in linker_defs.h (or similar) and CONFIG_GEN_UICR_PROTECTEDMEM_SIZE_BYTES directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using linker_defs.h

*((volatile uint32_t *)0xe030008) = 0x5EB0;
*((volatile uint32_t *)0xe030010) = 0x5EB0;

printk("Rebooting\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

The sample output would be much more self-explanatory if we printed something like "Corrupting memory" as well.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixded

@SebastianBoe SebastianBoe changed the title Add support for configuring UICR.SECONDARY.PROCESSOR, UICR.PROTECTEDMEM, and a sample to demonstrate usage Add support for configuring UICR.SECONDARY.PROCESSOR and UICR.PROTECTEDMEM Sep 22, 2025
@carlescufi
Copy link
Member

Added @hakonfam as maintainer since

- hakonfam

"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_SECURESTORAGE", # 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.

Add support for uicr.SECONDARY.PROCESSOR.

Signed-off-by: Sebastian Bøe <[email protected]>
Add support for PROTECTEDMEM.

Signed-off-by: Sebastian Bøe <[email protected]>
Copy link

@cfriedt cfriedt merged commit 7c9275c into zephyrproject-rtos:main Sep 29, 2025
31 checks passed
@SebastianBoe SebastianBoe deleted the protected_mem branch October 8, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.