NVS with external flash partition problem in non secure application

Hello, 

I'm trying to run the NVS example on the NRF9160DK rev 1.1.3  with the on-board MX25R6435F external flash memory.

The sample runs OK as nrf9160dk/nrf9160 but the partitioning seems to have problems with nrf9160dk/nrf9160/ns mode.

I modified the NVS_PARTITION  macro to match with my external flash partition.

#define NVS_PARTITION           sensor_data_ex_partition
I'm trying to run it without Partition Manager because I can't make it work with  an external flash aswell.
Thanks in advance.
 

This is the error:
C:/nrfconnect/nvs_int_flash_ns/src/main.c: In function 'main':
C:/ncs/v2.7.0/nrf/include/flash_map_pm.h:52:18: error: 'PM_PM_PM_sensor_data_ex_partition_ID_LABEL_OFFSET' undeclared (first use in this function)
52 | UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
| ^~~
C:/ncs/v2.7.0/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in definition of macro 'UTIL_PRIMITIVE_CAT'
105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
| ^
C:/ncs/v2.7.0/nrf/include/flash_map_pm.h:52:9: note: in expansion of macro 'UTIL_CAT'
52 | UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
| ^~~~~~~~
C:/ncs/v2.7.0/nrf/include/flash_map_pm.h:55:39: note: in expansion of macro 'FIXED_PARTITION_DATA_FIELD'
55 | #define FIXED_PARTITION_OFFSET(label) FIXED_PARTITION_DATA_FIELD(label, _OFFSET)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/nrfconnect/nvs_int_flash_ns/src/main.c:53:33: note: in expansion of macro 'FIXED_PARTITION_OFFSET'
53 | #define NVS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(NVS_PARTITION)
| ^~~~~~~~~~~~~~~~~~~~~~
C:/nrfconnect/nvs_int_flash_ns/src/main.c:86:21: note: in expansion of macro 'NVS_PARTITION_OFFSET'
86 | fs.offset = NVS_PARTITION_OFFSET;
| ^~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.7.0/nrf/include/flash_map_pm.h:52:18: note: each undeclared identifier is reported only once for each function it appears in
52 | UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
| ^~~
C:/ncs/v2.7.0/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in definition of macro 'UTIL_PRIMITIVE_CAT'
105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
| ^
C:/ncs/v2.7.0/nrf/include/flash_map_pm.h:52:9: note: in expansion of macro 'UTIL_CAT'
52 | UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
| ^~~~~~~~
C:/ncs/v2.7.0/nrf/include/flash_map_pm.h:55:39: note: in expansion of macro 'FIXED_PARTITION_DATA_FIELD'
55 | #define FIXED_PARTITION_OFFSET(label) FIXED_PARTITION_DATA_FIELD(label, _OFFSET)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/nrfconnect/nvs_int_flash_ns/src/main.c:53:33: note: in expansion of macro 'FIXED_PARTITION_OFFSET'
53 | #define NVS_PARTITION_OFFSET FIXED_PARTITION_OFFSET(NVS_PARTITION)
| ^~~~~~~~~~~~~~~~~~~~~~
C:/nrfconnect/nvs_int_flash_ns/src/main.c:86:21: note: in expansion of macro 'NVS_PARTITION_OFFSET'
86 | fs.offset = NVS_PARTITION_OFFSET;
| ^~~~~~~~~~~~~~~~~~~~


This is my prj.conf file:

CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_NVS=y
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_NVS_LOG_LEVEL_DBG=y
CONFIG_REBOOT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y


And this is my .overlay file:

&mx25r64 {
    status = "okay";
};

&mx25r64 {
    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;
        sensor_data_ex_partition: partition@0 {
            label = "sensor_data_ex_partition";
            reg = <0x00000000 0x00800000>;
        };
    };

};
Related