I'm attempting to write to flash memory on our custom board using the nRF52840 using the NVS library in Zephyr 1.5.0. I've ported over the example code from samples/subsys/nvs and nvs successfully initializes:
[00:00:01.011,199] [0m<inf> fs_nvs: 3 Sectors of 4096 bytes[0m [00:00:01.011,535] [0m<inf> fs_nvs: alloc wra: 0, f40[0m [00:00:01.011,901] [0m<inf> fs_nvs: data wra: 0, 133[0m
The storage file system structure is initialized identically to the example code.
But, when I go to actually save data, I get a hard fault, specifically MPU Fault:
[00:00:04.200,897] [1;31m<err> os: ***** HARD FAULT *****[0m [00:00:04.201,416] [1;31m<err> os: Fault escalation (see below)[0m [00:00:04.201,934] [1;31m<err> os: ***** MPU FAULT *****[0m [00:00:04.202,423] [1;31m<err> os: Data Access Violation[0m [00:00:04.202,911] [1;31m<err> os: MMFAR Address: 0xf8130[0m [00:00:04.203,460] [1;31m<err> os: r0/a1: 0x4001e400 r1/a2: 0x00000000 r2/a3: 0x4001e504[0m [00:00:04.204,223] [1;31m<err> os: r3/a4: 0x01ffffff r12/ip: 0x20000aa4 r14/lr: 0x000053f3[0m [00:00:04.205,017] [1;31m<err> os: xpsr: 0x81000018[0m [00:00:04.205,535] [1;31m<err> os: Faulting instruction address (r15/pc): 0x000054d4[0m [00:00:04.206,176] [1;31m<err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0[0m [00:00:04.206,848] [1;31m<err> os: Fault during interrupt handling [0m [00:00:04.207,397] [1;31m<err> os: Current thread: 0x20001b60 (unknown)[0m [00:00:04.223,052] [1;31m<err> fatal_error: Resetting system[0m
My prj.conf file includes the same lines from the example, specifically CONFIG_MPU_ALLOW_FLASH_WRITE=y which I saw was mentioned as a fix on some git tickets.
This is all on a custom board, with the devicetree based on the nRF52840DK and successfully working with our board specific peripherals. Nothing in the flash memory section has been changed.
Also strange is that when running the default nvs code on the dev kit, I get this error: <err> flash_nrf: not word-aligned, followed by the memory address, for every attempted write.
Thanks in advance for your help!