Hang with nRF5 SDK 17.1.0 Bootloader and nRF Connect SDK 2.1.0 application

I have an existing product that is using the nRF5 SDK 17.1.0 Bootloader.  I have updated the application to use nRF Connect SDK 2.1.0.  The new application also has an implementation of the buttonless DFU service, so that the nRF Connect app on iOS can be used to do the updates.

Most of this is working.  The application runs fine when built to run without a boot loader.  When build to run with the boot loader (CONFIG_FLASH_LOAD_OFFSET=0x27000) there is an issue that I'm having trouble debugging.  This is what is happening:

  1. I erase the device and program in the nRF5 SDK 17.1.0 Bootloader.  After reset the boot loader starts up normally.
  2. I use the nRF Connect app on iOS to transfer over the nRF Connect SDK 2.1.0 application.  I get a success message from the nRF Connect app.
  3. The application does not start BLE advertising and the device appears to be hung.
  4. If I attach the VScode debugger, it usually halts inside the boot loader startup sequence where it is checking the CRC.
  5. Looking at the RESETREAS register I see the expected SREQ, but I also see LOCKUP.
  6. If I continue code execution then the application starts up and works fine.

The hang happens every time I run the above sequence.  It happens with or without a debug probe attached.  None of the nrfjprog resets (--reset, --debugreset, --pinreset) have any effect - the device remains hung.  If I attach the debugger before step 2 above then the halt doesn't happen.  The application starts up fine without any hang.

Anyone have any ideas on what might be happening?  Any tips on how to debug this type of issue where simply having the debugger attached avoids the issue?

  • I ran the above binaries on an nRF52840-DK and am seeing the hang here.

  • I built peripheral_lbs with these additions to the prj.conf and reproduced the hang:

    Can you confirm that it hangs at the same location inside the cryptocell runtime library, and not in the fault handler because the settings partition overlap with the bootloader?

    I can't get this bootloader to exit DFU mode. I guess it may be because of your NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN setting in sdk_config, or were you able to run the same hex on your DK?

    Turns out I programmed the wrong settings page. Programming your bootloader with my ncs_app.hex works on the DK:

    nrfutil settings generate --family NRF52840 --application ncs_app.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 settings.hex
    
    nrfjprog -e
    nrfjprog --program bootloader-neo.hex --verify
    nrfjprog --program s140_nrf52_7.2.0_softdevice.hex --verify
    nrfjprog --program ncs_app.hex --verify
    nrfjprog --program settings.hex --verify
    nrfjprog -r
    

  • By "works on the DK" do you mean that peripheral_lbs starts up without hanging and you can connect to it?

    I'm not programming in any settings.hex (or ncs_app.hex).  Just programming in the boot loader, then the soft device, then the boot loader hex.  Then using nrf connect app to run the DFU process.  At the end of that is says "Your DFU update was completed successfully".  At that point I do not see peripheral_lbs advertisements.

    When I attach the vscode debugger, the call stack is the boot loader crc32_compute.  When I continue from there I still don't see advertisements.  Break in the debugger again and it is in the application in CC_PalWaitInterruptRND.  Then tried break and continue a few more times and it is usually in one of those, but sometimes in other parts of the startup code.  Sounds like a reset loop...

    So seeing three different things:

    1) My app.  Doesn't startup properly.  Connect debugger and continue and it then starts up fine.

    2) The hello_world app.  With the clock crystal in the startup it hangs waiting for the crystal startup.  With the synthetic option, it starts fine.

    3) The peripheral_lbs app.  Connect debugger and continue and it appears to be stuck in a reset loop.

  • Yes, the DK starts advertiding when using my version. But it enters a reset loop if I DFU your app. Writing the settings page is a quicker way to test this. And it’s the only way for me if I’m going to run my app with your bootloader.

    Did you move the settings partition in your lbs project. If not, it will go in a boot loop like I mentioned in my first reply here.

  • Sorry, I missed that.  I see, the change is in the peripheral_lbs/nrf52840dk_nrf52840.overlay.  Using the nRF52840-DK board I can now DFU with that change and the app starts up.  And if I remove the config changes to not use the DC/DC and to use the RC the app also starts up.

    I then tried the same boot loader and peripheral_lbs dfu on my custom board without the RC changes.  And it does hang.  Until I attach debugger and hit continue.

    So the behavior on the nRF52840-DK and our custom board is different.

    I then checked the schematics and sure enough the inductors are not in this design for the DC/DC converter.  Adding CONFIG_BOARD_ENABLE_DCDC=n to my app fixed the issue.  The app starts up properly now.

    Thank you for all the help!  Obviously I should have seen this when setting up the custom dts.  What I still don't understand is how that manifested in all these other odd things happening, working from the debugger, etc...

    BTW: I don't have a storage partition defined in my custom board dts that my app uses.

    CONFIG_BT_SETTINGS=y
    CONFIG_SETTINGS_RUNTIME=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_NONE=y

Related