Dear Nordic Team,
I am working with the SDK 2.0.0 in Visual studio Code and with a custom board with a nrf9160. The board configuration is based on the nrf9160dk and has only minor changes.
At the moment I am trying to implement the nvs(none-volatile-storage) library into my project. I tested the sample on my custom board and this worked without any problems at the beginning.
After the successful test I incorporated the nvs library into my project and began to test it.
Unfortunately I encountered some problems with my implementation and also with the nvs sample. The initialization of the nvs stroage partition works fine and completes without any problems, but reading or writing always yield the same error namely the error -2 which is classified as ENOENT or " nor such file or directory". Also the sample always shows this error since the use of my own implementation. When debugging the functions it always fails at these lines:
zephyr\subsys\fs\nvs\nvs.c line 1166 to 1169:
if (((wlk_addr == fs->ate_wra) && (wlk_ate.id != id)) || (wlk_ate.len == 0U) || (cnt_his < cnt)) { return -ENOENT; }
The problem is that wlk_ate.id always shows the number 65535.
This is my proj.conf file:
CONFIG_BUILD_WITH_TFM=y CONFIG_TFM_PROFILE_TYPE_MINIMAL=y CONFIG_TFM_BL2=n # Reroute loggong to RTT terminal CONFIG_PRINTK=y CONFIG_CONSOLE=y CONFIG_SERIAL=y CONFIG_STDOUT_CONSOLE=y CONFIG_LOG=y CONFIG_UART_CONSOLE=n CONFIG_RTT_CONSOLE=y CONFIG_USE_SEGGER_RTT=y CONFIG_LOG_MODE_IMMEDIATE=n # Enable GPIOs CONFIG_GPIO=y # Enable I2C/TWI CONFIG_I2C=y CONFIG_I2C_NRFX=y # Heap and stacks CONFIG_HEAP_MEM_POOL_SIZE=73728 CONFIG_MAIN_STACK_SIZE=40960 CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096 CONFIG_FLASH=y CONFIG_FLASH_MAP=y CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_DEBUG_OPTIMIZATIONS=y CONFIG_DEBUG_THREAD_INFO=y CONFIG_NEWLIB_LIBC=y CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y # Uart Config CONFIG_NRFX_UARTE0=y CONFIG_UART_ASYNC_API=y # Watchdog CONFIG_WATCHDOG=y CONFIG_WDT_LOG_LEVEL_DBG=y CONFIG_WDT_DISABLE_AT_BOOT=n # Networking CONFIG_NETWORKING=y CONFIG_NET_NATIVE=n CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_OFFLOAD=y CONFIG_NET_SOCKETS_POSIX_NAMES=y # LTE link control CONFIG_LTE_LINK_CONTROL=y CONFIG_LTE_AUTO_INIT_AND_CONNECT=n CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=n CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=y CONFIG_LTE_MODE_PREFERENCE_LTE_M=y # Modem info CONFIG_MODEM_INFO=y CONFIG_MODEM_INFO_ADD_DATE_TIME=n CONFIG_DATE_TIME=y # Modem library CONFIG_NRF_MODEM_LIB=y # AT Host CONFIG_AT_HOST_LIBRARY=y # MQTT CONFIG_MQTT_LIB=y CONFIG_MQTT_LIB_TLS=y CONFIG_MQTT_CLEAN_SESSION=y CONFIG_MQTT_KEEPALIVE=10 CONFIG_NRF_MODEM_LIB=y CONFIG_MODEM_KEY_MGMT=y CONFIG_MODEM_KEY_MGMT_LOG_LEVEL_DBG=y # Application CONFIG_MQTT_MESSAGE_BUFFER_SIZE=512 CONFIG_MQTT_PAYLOAD_BUFFER_SIZE=4096 CONFIG_MQTT_RECONNECT_DELAY_S=10 # FOTA library CONFIG_FOTA_DOWNLOAD=y CONFIG_REBOOT=y # Download client CONFIG_DOWNLOAD_CLIENT=y CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096 # DFU Target CONFIG_DFU_TARGET=y # CONFIG_DFU_TARGET_STREAM_SAVE_PROGRESS=y # Non-volatile Storage CONFIG_NVS=y CONFIG_SETTINGS_NVS=y CONFIG_FLASH_PAGE_LAYOUT=y # Application update support CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_MCUBOOT_IMAGE_VERSION="0.1.0" # Image manager CONFIG_IMG_MANAGER=y CONFIG_IMG_ERASE_PROGRESSIVELY=y
The partitions.yml file also does not show any problems at least to my knowledge:
EMPTY_0: address: 0xfe000 end_address: 0x100000 placement: after: - nvs_storage region: flash_primary size: 0x2000 EMPTY_1: address: 0xf4000 end_address: 0xf8000 placement: after: - mcuboot_secondary region: flash_primary size: 0x4000 app: address: 0x1c200 end_address: 0x80000 region: flash_primary size: 0x63e00 mcuboot: address: 0x0 end_address: 0xc000 placement: before: - mcuboot_primary region: flash_primary size: 0xc000 mcuboot_pad: address: 0xc000 end_address: 0xc200 placement: before: - mcuboot_primary_app region: flash_primary size: 0x200 mcuboot_primary: address: 0xc000 end_address: 0x80000 orig_span: &id001 - app - mcuboot_pad - tfm region: flash_primary sharers: 0x1 size: 0x74000 span: *id001 mcuboot_primary_app: address: 0xc200 end_address: 0x80000 orig_span: &id002 - app - tfm region: flash_primary size: 0x73e00 span: *id002 mcuboot_secondary: address: 0x80000 end_address: 0xf4000 placement: after: - mcuboot_primary align: start: 0x8000 region: flash_primary share_size: - mcuboot_primary size: 0x74000 nonsecure_storage: address: 0xf8000 end_address: 0xfe000 orig_span: &id003 - nvs_storage region: flash_primary size: 0x6000 span: *id003 nrf_modem_lib_ctrl: address: 0x20010000 end_address: 0x200104e8 inside: - sram_nonsecure placement: after: - tfm_sram - start region: sram_primary size: 0x4e8 nrf_modem_lib_rx: address: 0x200124e8 end_address: 0x200144e8 inside: - sram_nonsecure placement: after: - nrf_modem_lib_tx region: sram_primary size: 0x2000 nrf_modem_lib_sram: address: 0x20010000 end_address: 0x200144e8 orig_span: &id004 - nrf_modem_lib_ctrl - nrf_modem_lib_tx - nrf_modem_lib_rx region: sram_primary size: 0x44e8 span: *id004 nrf_modem_lib_tx: address: 0x200104e8 end_address: 0x200124e8 inside: - sram_nonsecure placement: after: - nrf_modem_lib_ctrl region: sram_primary size: 0x2000 nvs_storage: address: 0xf8000 align: start: 0x8000 end_address: 0xfe000 inside: - nonsecure_storage placement: align: start: 0x8000 before: - end region: flash_primary size: 0x6000 otp: address: 0xff8108 end_address: 0xff83fc region: otp size: 0x2f4 sram_nonsecure: address: 0x20010000 end_address: 0x20040000 orig_span: &id005 - sram_primary - nrf_modem_lib_ctrl - nrf_modem_lib_tx - nrf_modem_lib_rx region: sram_primary size: 0x30000 span: *id005 sram_primary: address: 0x200144e8 end_address: 0x20040000 region: sram_primary size: 0x2bb18 sram_secure: address: 0x20000000 end_address: 0x20010000 orig_span: &id006 - tfm_sram region: sram_primary size: 0x10000 span: *id006 tfm: address: 0xc200 end_address: 0x1c200 inside: - mcuboot_primary_app placement: before: - app region: flash_primary size: 0x10000 tfm_nonsecure: address: 0x1c200 end_address: 0x80000 orig_span: &id007 - app region: flash_primary size: 0x63e00 span: *id007 tfm_secure: address: 0xc000 end_address: 0x1c200 orig_span: &id008 - mcuboot_pad - tfm region: flash_primary size: 0x10200 span: *id008 tfm_sram: address: 0x20000000 end_address: 0x20010000 inside: - sram_secure placement: after: - start region: sram_primary size: 0x10000
This is the logging I get for the nvs initialization:
*** Booting Zephyr OS build v3.0.99-ncs1 *** [00:00:05.627,410] <inf> app: Application started.. [00:00:07.281,585] <inf> fs_nvs: 4 Sectors of 4096 bytes [00:00:07.281,585] <inf> fs_nvs: alloc wra: 0, fe8 [00:00:07.281,616] <inf> fs_nvs: data wra: 0, 0 [00:00:09.686,035] <inf> uart_communication: UART_RX_BUF_REQUEST
If any other information is necessary to pinpoint the problems please let me know.
Best reagrds,
Andreas