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

Have to run DFU OTA twice

Hi, I know there are already lots of threads around this but it seems none is like mine.

I'm running my toolchain on a Mac so I think I have a more challenging debug setup as I never found out how I can get RTT logger to log the normal app and still continue logging during DFU. However, this is the end of the DFU log:

<info> dfu_req_handling: Doing postvalidate
<info> dfu_req_handling: Current bank is bank 1
<info> dfu_req_handling: Running SD version check ============== 
<info> dfu_req_handling: Successfully ran the postvalidation check!
<info> dfu_req_handling: Invalidating old application in bank 0.
<debug> nrf_dfu_settings: Writing settings...
<debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
<debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 3
<debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, len=0x1B8 bytes), queue usage: 4
<debug> app: Sending Response: [0x4, 0x1]
<debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 3
<debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 2
<debug> dfu_req_handling: Response sent.
<debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 1
<debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
<debug> nrf_dfu_flash: This operation had a callback, calling back to 0x00073445.
<debug> dfu_req_handling: All flash operations have completed.
<debug> dfu_req_handling: Starting reset timer.
<debug> dfu_req_handling: Attempting to reset the device.
<debug> app: In nrf_dfu_transports_close
<debug> app: num transports: 1
<debug> app: Shutting down BLE transport.
<debug> app: Disconnecting.
<debug> app: BLE transport shut down.
<debug> app: After nrf_dfu_transports_init
<debug> dfu_req_handling: Reset.

After that, I restart the logger to get my application log, and it still shows the old version.

As the log shows that it is actually marking the new bank as primary, I really don't know how to proceed with debugging

  • You should try Ozone. Its a free cross platform debugging tool from Segger. It will allow you to set breakpoints, inspect variables etc. like any IDE.

    Also: What SDK version are you on? If you are on 14.0.0 then there is a known bug with doing SoftDevice updates where the new SoftDevice does not have the same size as the old one.

  • SDK 14.1 and the softdevice is the same :(

    I use Ozone, but as the bootloader is a different image file (it has to be, right?) I can either debug the bootloader or the app

  • What did you use to update the firmware ? How did you update the initial application firmware ? Should it work on the initial OTA DFU ? Have you tried to update SDK examples instead of your app ?

    If you want RTT logging for both application and bootloader you can have a look here.

  • My testing is set up as follows:

    • flash the initial bootloader + sd + app + bl settings via nrfjprog
    • generate a package (debug) with only the app via nrfutil pkg generate --application-version 3 --application app.hex --hw-version 52 --sd-req 0x9D --debug-mode --key-file private.pem package.zip

    And here's the nrfutil settings display output:

    After initial flash

    Family:               nRF52
    CRC:                  0x9600BC1B
    Settings Version:     0x00000001 (1)
    App Version:          0x00000003 (3)
    Bootloader Version:   0x00000002 (2)
    Bank Layout:          0x00000000
    Current Bank:         0x00000000
    Application Size:     0x00015F34 (89908 bytes)
    Application CRC:      0x42280D65
    Bank0 Bank Code:      0x00000001
    

    ** After OTA dfu (secure ble w/o bonding) **

    Bootloader DFU Settings:
    File:                 temp.hex
    Family:               nRF52
    CRC:                  0x40FB9CB2
    Settings Version:     0x00000001 (1)
    App Version:          0x00000003 (3)
    Bootloader Version:   0x00000002 (2)
    Bank Layout:          0x00000000
    Current Bank:         0x00000001
    Application Size:     0x00015F34 (89908 bytes)
    Application CRC:      0x42280D65
    Bank0 Bank Code:      0x00000000
    

    it looks like the bank was switched, but the application is still the same, right?

    Thanks for the hint about logging!

  • I did another run, to show the output after 2nd OTA as well:

    Initial flash

    Family:               nRF52
    CRC:                  0xB591D895
    Settings Version:     0x00000001 (1)
    App Version:          0x00000003 (3)
    Bootloader Version:   0x00000002 (2)
    Bank Layout:          0x00000000
    Current Bank:         0x00000000
    Application Size:     0x00015F34 (89908 bytes)
    Application CRC:      0x05475C39
    Bank0 Bank Code:      0x00000001
    

    After 1st OTA

    Family:               nRF52
    CRC:                  0xCC460A3F
    Settings Version:     0x00000001 (1)
    App Version:          0x00000003 (3)
    Bootloader Version:   0x00000002 (2)
    Bank Layout:          0x00000000
    Current Bank:         0x00000001
    Application Size:     0x00015F34 (89908 bytes)
    Application CRC:      0x05475C39
    Bank0 Bank Code:      0x00000000
    

    After 2nd OTA

    Family:               nRF52
    CRC:                  0xD32C0C63
    Settings Version:     0x00000001 (1)
    App Version:          0x00000003 (3)
    Bootloader Version:   0x00000002 (2)
    Bank Layout:          0x00000000
    Current Bank:         0x00000001
    Application Size:     0x00015F34 (89908 bytes)
    Application CRC:      0x704102E6 **<-- now the CRC changed**
    Bank0 Bank Code:      0x00000000
    
Related