This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

thingy:91 nRF52840 nvs_write mpu_fault on

I referred to the following sample.

\ncs\v1.4.2\zephyr\samples\subsys\nvs\src\main.c

void main(void)
{
int rc = 0, cnt = 0, cnt_his = 0;
char buf[16];
uint8_t key[8], longarray[128];
uint32_t reboot_counter = 0U, reboot_counter_his;
struct flash_pages_info info;

/* define the nvs file system by settings with:
* sector_size equal to the pagesize,
* 3 sectors
* starting at FLASH_AREA_OFFSET(storage)
*/
fs.offset = FLASH_AREA_OFFSET(storage);
rc = flash_get_page_info_by_offs(
device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL),
fs.offset, &info);
if (rc) {
printk("Unable to get page info");
}
fs.sector_size = info.size;
fs.sector_count = 3U;

rc = nvs_init(&fs, DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL);
if (rc) {
printk("Flash Init failed\n");
}

/* ADDRESS_ID is used to store an address, lets see if we can
* read it from flash, since we don't know the size read the
* maximum possible
*/
rc = nvs_read(&fs, ADDRESS_ID, &buf, sizeof(buf)); <------ (A)
if (rc > 0) { /* item was found, show it */
printk("Id: %d, Address: %s\n", ADDRESS_ID, buf);
} else {/* item was not found, add it */
strcpy(buf, "192.168.1.1");
printk("No address found, adding %s at id %d\n", buf,
ADDRESS_ID);
(void)nvs_write(&fs, ADDRESS_ID, &buf, strlen(buf)+1); <------ (B)
}

I went down the system at the point (A), so I fixed it.
&buf --> buf

(B) was fix as well, but the system goes down.

sdc_soc_flash_write_async to the point where it is falling in the function.

The attachment is stuck at 0x0000466E, but the next time you go with F10, the system goes down.

Parents Reply
  • On the nRF9160 side, flash writing is successful.

    I tried to find out what was different.

    nvs_fs.flash_device.api-> write functions are different.

    z_impl_flash_write API that writes in a function is called.

    On the nRF9160 side flash_nrf_write is called. This will be written successfully.

    On the nRF52890 side sdc_flash_write is called. This one sdc_soc_flash_write_async with a hand.

Children
Related