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. 

  • This is a somewhat not related issue, but my point is just to make it clear how difficult using the NCS sometimes is:

    Based on the UDP sample (nrf\samples\nrf9160\udp) I changed "prj.conf" to add the modem library to my build.

    Compiled my application *without* any changes, flashed and it immediately crashed. Same code, no changes, crash.

    So I took a look at the flash/ram partitions with "ninja rom_report". Noticed immediately that the RAM partitions changed, and that the section allotted to the non-secure application had changed.

    Could this be the problem ? Probably not because the DTS partitions are ignored, but then again only the RAM partitions changed. After a few hours I finally found that I forgot to copy this config option:

    CONFIG_MAIN_STACK_SIZE=4096

    But why was my code working before, and not now ? This option is not specific to the modem library. Grepping through the NCS source code I did not see any immediate connection to the modem library. The Zephyr doc says this is the stack size for the main thread. So why do I need to set it now and not before ? 

    But the larger problem is that each sample appears to have config options specific to the particular sample application, Zephyr OS and the Nordic libraries. And these options are spread across the DTS (although some parts seem to be ignored but nonetheless needed), Kconfig files and several other .conf , .yml  and .overlay files. Which of these should I copy/modify to my application ? Not possible to know without some trial and error, head banging and searching through this forum.

    Sorry for the long rant, but understand how frustrating working with the NCS can be.

  • Hi!

    I'll just mention this here for future reference and other users on DevZone. 

    When you build a multi-image build (for instance by building an application for the non-secure board which automatically adds the SPM as a child image) the Partition Manager gets enabled implicitly and takes over partitioning. The PM will define all partitions that are needed based on which subsystem are enabled in the application (for example enabling NCS will give you a secure partition) and will also expose a Kconfig to the user to determine the size of this partition. 

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

    This is part of the devicetree bindings and will break the build of deleted, but you can just ignore them. Bindings are not related to the partitioning. 

    With the non-secure and secure regions, there is a way to call secure functions from the non-secure app using secure entry gateway functions.

    If you need to do anything more in Kconfig than simply enabling the modules you need, there might be a bug in the Partition Manager.

    Let me know if there's anything else I can do for you!

    Best regards,

    Heidi

Related