This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to configure flash and RAM partitions

Hello,

I am trying to partition the RAM and the internal flash of the nRF9160, and I am blocked. 

I began by defining the partitions in the board device tree, based on the examples from the SDK. One of the partitions in flash is labeled "storage",

which I will use for storing application specific data. However when I compiled the code, I got an error saying that the label "storage" does not exist.

Digging through the forum, I found out that I should use the Partition Manager instead of the device tree. So I remove the partition definitions

from the device tree and wrote a pm_static.yml with the partitions I need. However now the firmware crashes immediately on startup.

I am suspecting that Zephyr requires the partitions to be defined in the device tree, even though this particular device tree information is ignored

when the firmware image is build. If this is correct, then I have to keep the partition information in two different places: the device tree and the 

pm_static.yml file. Am I correct ? Because this seems absurd to me.

Quite frankly I am very confused and discouraged with the nrf9160. 

  • Hi!

    If your application has more than one image (for example including SPM or MCUboot) then you need to use the Partition Manager to partition the memory region. 

    The way to add a static configuration to a multi-image is to define the partitions of the child images in a pm.yml file in every child image (for example MCUboot or SPM). Then when you build the main application with all the child images, the resulting partition configuration can be found in $BUILD_DIR/partitions.yml. Take this file and rename it "pm_static.yml" and place it in the application directory (doc: Configuring static partitions).

    The documentation mentions you can build this pm_static.yml file from scratch, but we really don't recommend doing that. It's much easier to use the one that the build creates for you. 

    Let me know if you have any more questions!

    Best regards,

    Heidi

  • Hello Heidi,

    I was confused by how the NVS sample application works. 

    It seems that "CONFIG_NVS=y" adds the "nvs_storage" flash partition, but I only found out after much head banging. And because the partitions defined in the device tree are ignored, no matter the changes I made to the label or size, nothing would work.

    Thanks for the tip on how to create a pm_static.yml file. I was trying to do it by hand, but going nowhere.

    Regarding the partitions defined in the device tree, I believe they are needed by Zephyr. So, I still need to defined the flash and RAM partitions in the device tree files. Correct ? 

  • Hi

    No, you don't need to add the partitions to the device tree. They're defined in partitions.yml which is enough.

  • Ok, but then this section in the device tree (from the nrf910dk_nrf9160ns.dts):

    chosen {
    zephyr,flash = &flash0;
    zephyr,sram = &sram0_ns;
    zephyr,code-partition = &slot0_ns_partition;
    };

    it is not needed ? 

  • Hi!

    As Didrik mentions here, NCS uses the Partition Manager to partition the flash and RAM, and not the device tree.

    Therefore, any devicetree configuration of flash or RAM partitions is ignored by the Partition Manager script.

    This script is used by the build system to properly allocate space for multi-image builds and is thus used for most nRF9160 applications, as all applications using the modem library require SPM as a child image and are therefore multi-image builds.

Related