In our code, we wish to store some data in flash via fstorage API. For this project we use
SDK 17.1.0 and the following (reduced) sample code
NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
{
.evt_handler = fstorage_evt_handler,
.start_addr = 0xff000,
.end_addr = 0xfffff,
};
static void write_word(uint32_t address, uint32_t data)
{
ret_code_t rc;
rc = nrf_fstorage_write(&fstorage, address, &data, sizeof(data), NULL);
APP_ERROR_CHECK(rc);
}
write_word(0xFF004, 0x55339977); wait_for_flash_ready();
write_word(0xFF000, 0xDDDDAAAA); wait_for_flash_ready();
write_word(0xFF008, 0xEEEEBBBB); wait_for_flash_ready();
write_word(0xFF00C, 0xAAAAEEEE); wait_for_flash_ready();
write_word(0xFF010, 0xCCCCBBBB); wait_for_flash_ready();
write_word(0xFF014, 0xAAAAEEEE); wait_for_flash_ready();
Early on, the following is called
ret_code_t rc;
rc = nrf_fstorage_init(&fstorage, &nrf_fstorage_sd, NULL);
APP_ERROR_CHECK(rc);
Expected is data written to flash address 0xFF000 and above
actual data seems to be written to 0x4xxxx instead of 0xFxxxx
The patterns are not found elsewhere on flash!
./nrfjprog -f nrf52 --memrd 0x4F600 --n 128
0x0004F600: 22014B15 480621F7 FFB6F7F4 FE8CF7FF |.K.".!.H........|
0x0004F610: BF00E79D 20016890 A55A5AA5 000617D4 |.....h. .ZZ.....|
0x0004F620: 00061694 55339977 0009F004 DDDDAAAA |....w.3U........|
0x0004F630: EEEEBBBB 0009F008 AAAAEEEE 0009F00C |................|
0x0004F640: CCCCBBBB 0009F010 0009F014 00061778 |............x...|
0x0004F650: 00061710 00061798 000617B4 B083B500 |................|
0x0004F660: F8AD2300 F8AD3004 00403000 0001F040 |.#...0...0@.@...|
0x0004F670: 0004F88D 46692202 F002A801 F89DFBB1 |....."iF........|
Also it appears that DDDDAAAA is written after 55339977. When running the software
without the softdevice and direct flash access via nrf_nvmc_write_word() the correct
location is used
Is there something obvious that we fail to see ?