how to add a custom memory section specifically for the NRF5340 in Zephyr project

Dear Nordic

Our primary configuration in pm_static.yml is as follows:

mcuboot: 0x0~0x10000
mcuboot_primary: 0x10000~0x40000
mcuboot_secondary: 0x40000~0x70000
extlib_section: 0x70000~0x100000

In the generated storage section configuration in the linker.cmd file under the build zephyr directory, we see:

MEMORY
{
    FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x28000
    RAM (wx) : ORIGIN = 0x20010000, LENGTH = 0x40000
   
    IDT_LIST (wx) : ORIGIN = 0xFFFF7FFF, LENGTH = 32K
}

I would like to define the extlib_section storage segment within the MEMORY block and allocate external libraries to this section in SECTIONS.

Using zephyr_linker_sources in CMakeLists.txt, I can add configuration to SECTIONS, but I haven't found a way to add custom storage segments to MEMORY. I tried using zephyr_linker_memory; it doesn't generate errors during compilation, but it also has no effect.

Do you have any suggestions?

  • Hi  .

    I'm in a very similar situation to yours.

    Can you suggest how you solved the problem?

    Thank you

  • Hi  

    I cannot be certain if your requirements are the same as mine, but I will briefly describe my approach for your reference. I directly allocated a flash segment and a RAM segment in pm_static.yml that are not used by my Zephyr program. Then, I compiled a firmware for the same core using another compilation tool, where the firmware content only includes the library that I need to update separately and its dependent libraries, with the address range corresponding to these segments. This way, this part of the firmware will be confined to execute within the specified flash and RAM areas, and I can directly call the functions within the library through the corresponding addresses.

    At first, I also wanted to configure a project in the Zephyr VS Code environment that does not include Zephyr and is hardware-independent, but that seems to be very difficult.

  • Hi I just tried inserting "zephyr_linker_sources(SECTIONS rem_ram_sections.ld)" into CMakeLists.txt and it seems to work well for what I need.
    Thanks for your reply.
Related