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

Buttonless BLE DFU - nrf_fstorage_write() failed with error 0x4

In our product we have implemented buttonless DFU over BLE with the secure boot-loader (unbonded) on SDK 15.2. The bootloader is unmodified except for the addition of PA/LNA control.

We are undertaking pre-production testing of our product and have been using the Nordic DFU libraries for iOS/Android to push firmware updates to our beta testers. Most of the time DFU process completes fine but occasionally (maybe 1 time in 10) the DFU process is failing.

We've managed to replicate this in nRFConnect by repeatedly performing DFU until it fails - here's a screenshot of nRFConnect showing the same error we see reported in our app logs:

After the error the device remains in DFU mode until timeout. This is a problem as the user experience is terrible - as the device remains stuck in DFU mode the user has to wait two minutes (for the DFU timeout) until the application starts again and we can re-establish a connection from the app to the product. We do the firmware version check/update when the user opens our app to interact with the product so asking them to wait two minutes for the product to reset is far from ideal.

I enabled logging on the bootloader and managed to replicate the problem with the product attached to the debugger, here is what gets logged:

 app: Entering DFU mode.
 nrf_dfu_validation: Signature required. Checking signature.
 nrf_dfu_validation: Calculating init packet hash (init packet len: 58)
 nrf_dfu_validation: Verify signature
 nrf_dfu_validation: Image verified
 nrf_dfu_settings: Backing up settings page to address 0xFE000.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_dfu_flash: nrf_fstorage_write() failed with error 0x4.
 nrf_bootloader_wdt: Internal feed
 app: Inactivity timeout.

I think error code 4 means no memory which seems like an odd error to be occurring in the bootloader....

Any suggestions as to what might be causing the issue and how to mitigate it would be appreciated.

Related