When I run my code using Segger debugger, all is well and I can read and write from flash with issues. However, when I run the same code independently I sometimes get:
ASSERT ERROR 16 [NRF_ERROR_INVALID_ADDR]
when calling:
#define FLASH_START_ADDRESS 0x7e000
#define FLASH_END_ADDRESS 0x7ffff
…
ret = nrf_fstorage_read(&fstorage, FLASH_START_ADDRESS, buf, size);
APP_ERROR_CHECK(ret);
at this point buf is 1940 bytes.
The application RAM start is 0x200039d8 as determined by nrf_sdh_ble_enable().
My set-up is:
Module: nrf52840
Hardware: nrf52840 DVK and custom board
Soft Device: s140_nrf52_7.2.0_softdevice
SDK: nRF5_SDK_17.0.2_d674dde
Memory Segments:
FLASH RX 0x0 0x100000;RAM1 RWX 0x20000000 0x40000
Section Placement Macros:
FLASH_PH_START=0x0
FLASH_PH_SIZE=0x100000
RAM_PH_START=0x20000000
RAM_PH_SIZE=0x40000
FLASH_START=0x27000
FLASH_SIZE=0x2a222
RAM_START=0x200039d8
RAM_SIZE=0x3dda0
Stack and Heap both set to:
32768 bytes
I did notice that when code downloaded via Segger and then viewed via nRF Connect programmer, there is a memory chunk starting at 0x7000 and ending 0x7e676. [I don’t know why this is not either the size of my file ie 1940 bytes or the 0x7ffff specified as flash end address.]
I also don’t get this memory chunk when the code is run after being downloaded via nrfjprog or nRF Connect programmer but either way, I still get the invalid address error.
I’m clearly misunderstanding something here and would be grateful for some pointers….
Nick