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
  • Hello,

     

    but the next time you go with F10, the system goes down.

     are there any error codes? Do you have a log output?

  • 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.

  • Did you set

    CONFIG_MPU_ALLOW_FLASH_WRITE=y

    in prj.conf?

  • Yes, it is set.

    prj.conf

    CONFIG_BT=y
    CONFIG_BT_CENTRAL=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic Discovery Sample"

    CONFIG_BT_SCAN=y
    CONFIG_BT_SCAN_FILTER_ENABLE=y
    CONFIG_BT_SCAN_UUID_CNT=1

    CONFIG_BT_SMP=y
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_GATT_DM=y
    CONFIG_HEAP_MEM_POOL_SIZE=2048

    # Needed to print UUID.
    CONFIG_BT_DEBUG_LOG=y
    #CONFIG_BT_GATT_DM_DATA_PRINT=y

    CONFIG_USE_SEGGER_RTT=y
    CONFIG_UART_CONSOLE=n
    CONFIG_RTT_CONSOLE=y
    CONFIG_LOG_PRINTK=y

    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n

    CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y
    CONFIG_BT_CTLR=y

    #CONFIG_BT_SETTINGS=y
    CONFIG_SETTINGS=y

    CONFIG_BT_OBSERVER=y
    CONFIG_BT_BACKGROUND_SCAN_INTERVAL=2048
    CONFIG_BT_BACKGROUND_SCAN_WINDOW=18

    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_NVS_LOG_LEVEL_DBG=y
    CONFIG_REBOOT=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y

    CONFIG_NRFX_CLOCK=n

    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    #CONFIG_NRFX_UARTE0=y
    #CONFIG_NRFX_UARTE1=y
    #CONFIG_SERIAL=y
    #CONFIG_CONSOLE=y

    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_NANO=n

    CONFIG_JSON_LIBRARY=y

    CONFIG_MAIN_STACK_SIZE=92160

Reply
  • Yes, it is set.

    prj.conf

    CONFIG_BT=y
    CONFIG_BT_CENTRAL=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic Discovery Sample"

    CONFIG_BT_SCAN=y
    CONFIG_BT_SCAN_FILTER_ENABLE=y
    CONFIG_BT_SCAN_UUID_CNT=1

    CONFIG_BT_SMP=y
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_GATT_DM=y
    CONFIG_HEAP_MEM_POOL_SIZE=2048

    # Needed to print UUID.
    CONFIG_BT_DEBUG_LOG=y
    #CONFIG_BT_GATT_DM_DATA_PRINT=y

    CONFIG_USE_SEGGER_RTT=y
    CONFIG_UART_CONSOLE=n
    CONFIG_RTT_CONSOLE=y
    CONFIG_LOG_PRINTK=y

    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n

    CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y
    CONFIG_BT_CTLR=y

    #CONFIG_BT_SETTINGS=y
    CONFIG_SETTINGS=y

    CONFIG_BT_OBSERVER=y
    CONFIG_BT_BACKGROUND_SCAN_INTERVAL=2048
    CONFIG_BT_BACKGROUND_SCAN_WINDOW=18

    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_NVS_LOG_LEVEL_DBG=y
    CONFIG_REBOOT=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y

    CONFIG_NRFX_CLOCK=n

    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    #CONFIG_NRFX_UARTE0=y
    #CONFIG_NRFX_UARTE1=y
    #CONFIG_SERIAL=y
    #CONFIG_CONSOLE=y

    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_NANO=n

    CONFIG_JSON_LIBRARY=y

    CONFIG_MAIN_STACK_SIZE=92160

Children
Related