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

nRF9160DK read/write string to Flash in mqtt_simple

Hi,

I would like to write a string to flash in mqtt_simple SDK example using latest modem firmware and ncs v1.4.0. I based my code off the zephyr example (samples/subsys/nvs/src/main.c)

Added the following to proj.conf

and the following functions to mqtt_simple

Then in main()

It compiles and runs but I get the following error in LTE Link Monitor which causes a cyclic reboot:

I tried running the example code given in this post: 
https://devzone.nordicsemi.com/f/nordic-q-a/52095/nrf9160dk-storing-to-and-reading-from-flash
and here: 
https://devzone.nordicsemi.com/f/nordic-q-a/47275/why-doesn-t-nvs-write-data-to-flash-correctly 

but they both use:

DT_FLASH_AREA_STORAGE_OFFSET and DT_FLASH_DEV_NAME 

which return as undefined in my project. Seems like defining these and replacing:

FLASH_AREA_OFFSET(storage) and DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL)

would solve my problem.

Thoughts?

Thank you,

Robert

  • Grep'ing through the file system found the following:

    C:\ncs\v1.4.0\zephyr\doc\releases\release-notes-2.3.rst:

      989: * :github:`24356` - MCUboot (and other users of DT_FLASH_DEV_NAME) broken with current zephyr master

    and

    devicetree_legacy_unfixed.h



    I am new to zephyr, any thoughts to resolve? 

  • Hello,

     

    It compiles and runs but I get the following error in LTE Link Monitor which causes a cyclic reboot:

     What makes you think this is an error? This looks completely normal to me, and should not be the cause of the reboot. Can you set CONFIG_DEBUG=y in prj.conf and see if you get any other debug messages in the output log?

  • I'm not sure if I understand your question. The read/write to firmware above should read/write to flash on the nrf9160 (as indicated by other forum posts) but instead it causes a hard fault; causing my DK to reboot once per second. It is an error because the inclusion of the above firmware in mqtt_simple projects directly causes the cyclic reboot.

    Maybe to simplify the ask, can you please help me understand why:

    DT_FLASH_AREA_STORAGE_OFFSET and DT_FLASH_DEV_NAME are seemingly undeclared.

  • cachro2 said:
    I'm not sure if I understand your question.

     It looks like you didn't properly copy/paste the output log, because all I see is

    and no error.

  • Unfortunately, I bricked my DK trying to run variants of this firmware so I cannot get you more logs. However, the firmware never reached the printk statements which would have indicated that it wrote to and read from the flash sectors correctly. 

1 2