Declaring partition for user storage

Hardware: nRF5340 DK

Software: NCS 2.2.0

IDE: VSCode (nRF Connect)

Hi,

I am attempting to create my own partition in flash. I've done this before on an nRF53832 DK running an older version of NCS but have not been successful in porting this over to the nRF5430. 

Are there examples of overlay/yaml files that show how to do this on the nRF5340? The reason behind this is, I've had issues writing user data to flash using NVS since the zephyr stack also uses NVS to write bond data to flash. I write my own data to flash with no errors returned but upon reading back the same data, it returns garbage even though the correct number of bytes are returned.

Thanks for any information regarding this matter,

Tom

  • Hello Tom,

    Sorry for the late reply, and that I didn't get to look properly into this yet. To speed things up, what did you try, and what did you do that was working in the older NCS version?

    Best regards,

    Edvin

  • I created an overlay file but I wasn't sure about which sections of flash to partition for the custom segment.

    I had created a custom overlay and yaml file that was working as expected with an older version of NCS and nRF52832.

    Overlay:

    // To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.
    // For more help, browse the DeviceTree documentation at https://docs.zephyrproject.org/latest/guides/dts/index.html
    /* User storage */
    &flash0 {
    	partitions {
    		storage_partition: partition@7a000 {
    			label = "storage";
    			reg = <0x7a000 0x4000>;
    		};
    		user_partition: partition@7e000 {
    			label = "userstorage";
    			reg = <0x7e000 0x2000>;
    		};
    	};
    };
      

    Yaml:

    settings_storage:
      address: 0x78000
      end_address: 0x7a000
      placement:
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000
    storage:
      address: 0x7a000
      end_address: 0x7e000
      placement:
        before:
        - userstorage
      region: flash_primary
      size: 0x4000
    userstorage:
      address: 0x7e000
      end_address: 0x80000
      placement:
        before:
        - end
      region: flash_primary
      size: 0x2000

    Would the same approach work on NCS 2.2.0 and on an nRF5340 MCU?

    Much appreciated,

    Tom

  • Hi,


    I've taken over the support for this case now. Apologies for the long wait time.

    Yes, the same approach would work on NCS 2.2.0 and with the nRF5340. I would recommend you to follow the partition manager documentation which should describe where to put and what to do with the various partitions you create.

    Are there examples of overlay/yaml files that show how to do this on the nRF5340?

    Afaik, all of our samples, except the ones which has a secondary slot on the external flash for DFU purposes, uses the default configuration for flash partitions but a few of these samples contains a minimal pm_static.yml file in the folder: https://github.com/hellesvik-nordic/samples_for_nrf_connect_sdk/tree/main/bootloader_samples/serial_recovery

    Kind regards,
    Andreas

Related