Trouble trying to write data to the NRF52840

I am programming firmware for the NRF52840-DONGLE. I have been able to get all the features I'm developing working, except I am now just trying to store a simple 10 digit number to the device flash but I am unable to get it working no matter what I try.

ChatGPT has been able to help write a good amount of the code, which has worked perfectly, but it is unable to figure out this piece after many days of trying. I tried the NVS sample code too, which compiled but it crashes as soon as nvs_mount is called. When I say "crash", I'm not sure if it's technically crashing or something else. Basically if I run screen to view the logs, I see them fine, but as soon as I add nvs_mount(&fs) in the code and boot it, screen just starts and terminates with no log info at all. 

Any idea what could be wrong? Thanks 

Parents
  • Hello,

    The bootloader pre-programmed on the dongle occupies the flash region from address 0xE0000 to 0x100000 and has write protection enabled. If the application attempts to write to this region, a fault exception will be raised. To prevent this, please try to reserve the flash area by including the nrf52840dongle_nrf52840_pm_static.yml file in your build as I did in this post:

     RE: nRF52840 dongle, BLE peripheral_uart example, SDK migration from 2.6.0 to 2.9.0  

    Relevant changes:

    diff --git a/boards/nrf52840dongle_nrf52840_pm_static.yml b/boards/nrf52840dongle_nrf52840_pm_static.yml
    new file mode 100644
    index 0000000..ae8446e
    --- /dev/null
    +++ b/boards/nrf52840dongle_nrf52840_pm_static.yml
    @@ -0,0 +1,10 @@
    +nrf5_bootloader:
    +  address: 0xE0000
    +  end_address: 0x100000
    +  placement:
    +    align:
    +      start: 0x1000
    +    before:
    +    - end
    +  region: flash_primary
    +  size: 0x20000
    \ No newline at end of file
    diff --git a/sample.yaml b/sample.yaml
    index dbf218c..4469dba 100644
    --- a/sample.yaml
    +++ b/sample.yaml
    @@ -10,6 +10,7 @@ tests:
           thingy53/nrf5340/cpuapp/ns nrf21540dk/nrf52840 nrf54l15dk/nrf54l05/cpuapp
           nrf54l15dk/nrf54l10/cpuapp nrf54l15dk/nrf54l15/cpuapp
           nrf54h20dk/nrf54h20/cpuapp nrf54h20dk/nrf54h20/cpurad
    +      nrf52840dongle/nrf52840
         integration_platforms:
           - nrf52dk/nrf52832
           - nrf52833dk/nrf52833
    diff --git a/sysbuild.cmake b/sysbuild.cmake
    new file mode 100644
    index 0000000..aa2619b
    --- /dev/null
    +++ b/sysbuild.cmake
    @@ -0,0 +1,3 @@
    +if(SB_CONFIG_BOARD_NRF52840DONGLE)
    +  set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_LIST_DIR}/boards/nrf52840dongle_nrf52840_pm_static.yml CACHE INTERNAL "")
    +endif()

    Best regards,

    Vidar

Reply
  • Hello,

    The bootloader pre-programmed on the dongle occupies the flash region from address 0xE0000 to 0x100000 and has write protection enabled. If the application attempts to write to this region, a fault exception will be raised. To prevent this, please try to reserve the flash area by including the nrf52840dongle_nrf52840_pm_static.yml file in your build as I did in this post:

     RE: nRF52840 dongle, BLE peripheral_uart example, SDK migration from 2.6.0 to 2.9.0  

    Relevant changes:

    diff --git a/boards/nrf52840dongle_nrf52840_pm_static.yml b/boards/nrf52840dongle_nrf52840_pm_static.yml
    new file mode 100644
    index 0000000..ae8446e
    --- /dev/null
    +++ b/boards/nrf52840dongle_nrf52840_pm_static.yml
    @@ -0,0 +1,10 @@
    +nrf5_bootloader:
    +  address: 0xE0000
    +  end_address: 0x100000
    +  placement:
    +    align:
    +      start: 0x1000
    +    before:
    +    - end
    +  region: flash_primary
    +  size: 0x20000
    \ No newline at end of file
    diff --git a/sample.yaml b/sample.yaml
    index dbf218c..4469dba 100644
    --- a/sample.yaml
    +++ b/sample.yaml
    @@ -10,6 +10,7 @@ tests:
           thingy53/nrf5340/cpuapp/ns nrf21540dk/nrf52840 nrf54l15dk/nrf54l05/cpuapp
           nrf54l15dk/nrf54l10/cpuapp nrf54l15dk/nrf54l15/cpuapp
           nrf54h20dk/nrf54h20/cpuapp nrf54h20dk/nrf54h20/cpurad
    +      nrf52840dongle/nrf52840
         integration_platforms:
           - nrf52dk/nrf52832
           - nrf52833dk/nrf52833
    diff --git a/sysbuild.cmake b/sysbuild.cmake
    new file mode 100644
    index 0000000..aa2619b
    --- /dev/null
    +++ b/sysbuild.cmake
    @@ -0,0 +1,3 @@
    +if(SB_CONFIG_BOARD_NRF52840DONGLE)
    +  set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_LIST_DIR}/boards/nrf52840dongle_nrf52840_pm_static.yml CACHE INTERNAL "")
    +endif()

    Best regards,

    Vidar

Children
Related