Using FIXED_PARTITION_OFFSET macro for external flash partition

Hello,

In my application (nrf52840, v. sdk 3.0.2) I have a partition named "settings_storageuser", which is defined in the internal flash using partition manager and that I use for application parameters: 

In order to initialize this flash space I extract the device name and offset with SDK macros and then pass them to a nvs_fs object:


And I can correctly use the space for my non-volatile parameter. So far so good.
Now I would like to have this space on the external flash (which is correctly setup and working because I use the double image update with the support image on external flash. Also the littlefs is built inside the external flash). In order to do this, I add a similar partition to the external flash (settings_storageuser_external) and I replace it to the one built in the internal flash:


In doing so, however, the macro FIXED_PARTITION_OFFSET seems to fail:

It must be noted that FIXED_PARTITION_DEVICE does not fail. Also, if I set NVS_PARTITION_OFFSET to a fixed value instead of invoking the macro the project compiles (not sure it works as expected though, I did not try):

What am I doing wrong with the external flash-defined partition?
Thank you.

Regards,

Stefano

Parents
  • Hi,

     

    Can you first delete your build folder, and regenerate the build, and see if this helps?

    If it does not help, can you please share the full build log?

     

    Kind regards,

    Håkon

  • Dear Hakon,

    Thank you for your answer. Cancelling the build directory did not help (I had used the "pristine build" option anyway). Here is the build log (I only cancelled the names of our modules):


    Where FlashInit is the function where the macro I showed you before is invoked:

    As you can see NVS_PARTITION_OFFSET is undefined, while NVS_PARTITION_DEVICE is not.

    Thank you.


    Kind regards,

    Stefano

  • Hi,

     

    I took the zephyr/samples/subsys/nvs sample as a starting point, and added this overlay:

    &mx25r64 {
    	status = "okay";
    };
    
    / {
    	chosen {
    		nordic,pm-ext-flash = &mx25r64;
    	};
    };
    

     

    Added pm_static.yml file:

    settings_storageuser:
      address: 0x0
      end_address: 0x100000
      placement:
        align:
          start: 0x1000
      region: external_flash
      size: 0x100000

     

    Added boards/nrf52840dk_nrf52840.conf:

    # Need this when storage is on flash
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # Need this when storage is on MX25R64
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    

     

    And lastly, changed the main.c to use settings_storageuser:

    #define NVS_PARTITION		settings_storageuser
    

     

    This compiled for nrf52840dk_nrf52840 board on NCS v3.0.2 at my end.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    I took the zephyr/samples/subsys/nvs sample as a starting point, and added this overlay:

    &mx25r64 {
    	status = "okay";
    };
    
    / {
    	chosen {
    		nordic,pm-ext-flash = &mx25r64;
    	};
    };
    

     

    Added pm_static.yml file:

    settings_storageuser:
      address: 0x0
      end_address: 0x100000
      placement:
        align:
          start: 0x1000
      region: external_flash
      size: 0x100000

     

    Added boards/nrf52840dk_nrf52840.conf:

    # Need this when storage is on flash
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # Need this when storage is on MX25R64
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    

     

    And lastly, changed the main.c to use settings_storageuser:

    #define NVS_PARTITION		settings_storageuser
    

     

    This compiled for nrf52840dk_nrf52840 board on NCS v3.0.2 at my end.

     

    Kind regards,

    Håkon

Children
No Data
Related