Hi,
Maybe you are looking for these figures:
https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/memory/appmem.html
https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/memory.network/netmem.html
Kenneth
Hi,
Thanks for pointing to correct pages, hal/nrf_vmc.h header seems to be incorrect then. It would also be good to update link at WMC documentation to point at more informative pages.
Actual retaining has some issue though. Even reset (kernel reboot warm) seems to fill noinit section with 0xFF. And when right retain bit is set I'm not able to get similar CRC check that system off example uses to pass.
Can for example debugging affect this?
- Arto
I could find these threads:
https://github.com/zephyrproject-rtos/zephyr/issues/31087
https://github.com/mcu-tools/mcuboot/issues/905
In specific check out: https://github.com/mcu-tools/mcuboot/issues/905#issuecomment-768551026
Kenneth
I could find these threads:
https://github.com/zephyrproject-rtos/zephyr/issues/31087
https://github.com/mcu-tools/mcuboot/issues/905
In specific check out: https://github.com/mcu-tools/mcuboot/issues/905#issuecomment-768551026
Kenneth
Finally got this working. Required rather extensive study of how things are built and linked. I was hoping to be able to patch bootloader without touching SDK directories, but did not find a way. If there is nicer way to achieve the same suggestions are welcome.
At ncs/v1.7.0/bootloader/mcuboot
To the end of CMakeLists.txt:
zephyr_library_sources(${CMAKE_CURRENT_SOURCE_DIR}/boot_keep_out.c)zephyr_linker_sources(SECTIONS boot_keep_out.ld)
New file boot_keep_out.c:
#include <stdint.h>/* Reserve one memory section for retainable ram across boots */#define BOOT_LOADER_KEEP_OUT_REGION_SIZE 0x3000__attribute__((section(".boot_loader_keep_out")))uint8_t boot_loader_keep_out_ram[BOOT_LOADER_KEEP_OUT_REGION_SIZE];
New file boot_keep_out.ld:
SECTION_PROLOGUE (boot_loader_keep_out, 0x2006A000 (NOLOAD),){KEEP(*(SORT_BY_NAME(".boot_loader_keep_out*")))}
To app CMakeLists.txt:
set(PM_STATIC_YML_FILE "${CMAKE_CURRENT_SOURCE_DIR}/pm_static.yml")
zephyr_linker_sources(SECTIONS src/boot_keep_out.ld)
# Reserve area from RAM to be retained by boot through modified mcubootsram_primary:address: 0x20000000end_address: 0x2006a000region: sram_primarysize: 0x6a000retained_sram:address: 0x2006a000end_address: 0x2006e000placement:before:- pcd_sramafter:- sram_primaryregion: retained_sramsize: 0x3000
__in_section_unique(boot_loader_keep_out) struct retained_data retained;
SECTION_PROLOGUE (boot_loader_keep_out, 0x2006A000 (NOLOAD),)
{
KEEP(*(SORT_BY_NAME(".boot_loader_keep_out*")))
}
#define SRAM_BEGIN (uintptr_t)DT_REG_ADDR(DT_NODELABEL(sram0))
#define SRAM_END (SRAM_BEGIN + (uintptr_t)DT_REG_SIZE(DT_NODELABEL(sram0)))
/* Number of blocks */
#define BLOCK_COUNT 8
/* Sections / block */
#define SECTIONS_PER_BLOCK 16
/* Size of a controllable RAM section in the small blocks */
#define SECTION_SIZE 4096
NRF_VMC_S->RAM[block].POWERSET = 1LU << (VMC_RAM_POWER_S0RETENTION_Pos + section);
volatile uint32_t dummy = NRF_VMC_S->RAM[block].POWERSET;
ARG_UNUSED(dummy);