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

BOOTLOADER with Application not working

Hi, 

Im using nRF52840 DK, Segger Studio v4.52 and SDK version 17. 

I have been trying to make BLE OTA DFU work but have had many problems along the way. 

I followed the guides provided (getting started with bootloader and OTA DFU). 

I used sdk17/examples/dfu/secure_bootloader/pca10056_s140_ble_debug and ble_dfu_buttonless example. 

I manage to upload the bootloader to nrf52840 dk and it works fine. But as soon as I try to upload ble_dfu_buttonless on top of it, the application does not run and gets stuck. It doesn't enter main function or shows any error code. 
Picture below show when I build and debug option. There is no option to jump function or enter function, it's stuck somewhere. 
Thus, it is advertising as DfuTarg.. 



















Is there any update guide for nrf52840 dk and SDK 17 for BLE OTA DFU? Or application notes? 

Regards,
Hamza

Parents
  • Hi,

    . But as soon as I try to upload ble_dfu_buttonless on top of it, the application does not run and gets stuck. It doesn't enter main function or shows any error code. 

    You cannot just build and debug the application when there is a bootloader present. The reason is that the bootloader needs to know that there is a valid application present, or it will not start it. I assume this is the problem here, though you could confirm it by looking at the RTT log from the bootloader (using the J-Link RTT Viewer), as you are using a _debug bootloader. 

    There are several ways around this issue, but regardless of the method you must make the bootloader know that an application is present, and either make the CRC in bootloader settings correct or make the bootloader ignore the CRC settings page. The "proper" way of doing this is generating a bootloader settings page, and programming that. With that in place you can debug as normal, but the minute you make any change to the application, you need to generate and program a new bootloader settings page, as the CRC of the application will have changed. To avoid always having to reprogram a settings page every time the app is changed you can make a debug bootloader where you modify crc_on_valid_app_required() in nrf_bootlaoder.c to always return false.

  • Thank you for clarifying it Einar! 


    I created and uploaded the application with bootloader settings you suggested (followed this AN). The application almost worked on ble_dfu_buttonless example and didn't work at all with my application (BLE APP). 

    With Ble_Dfu_buttonless the application got stuck upon entering main loop, could see RTT viewer that it entered main loop and got stuck (didn't respond to ble connection or gatt configuration). 

    I did the same process with my application (BLE APP) and it got the error I showed in the figure. The application with bootloader boots up but since the application never executes (timeout) it enters the bootloader. 

    In conclusion: I understand better how to configure bootloader with application now - thank you! 
    But my problem with the application running over bootloader (following the guide) doesn't work. 
    Any idea how to debug that problem? 

    Regards,
    Hamza

  • Hi Hamza,

    I do not fully understand what you are describing.

    Hamza_HK said:
    The application with bootloader boots up but since the application never executes (timeout) it enters the bootloader. 

    Can you elaborate? The bootloader does not have a timeout for starting the application (there are other timeouts in the bootloader, though, but not relevant here). If no DFU update has been requested, the bootloader will start the application if present and valid. In this case, the bootloader will never run until the next reset. If an application is not present though, the bootloader will enter DFU mode.

    What happens in the bootloader in your case? Can you clarify? Perhaps even upload the RTT log from the bootloader? That will most likely clearly show if the app is started or not.

    Hamza_HK said:
    I did the same process with my application (BLE APP) and it got the error I showed in the figure.

    I do not see any error in the screenshot, other than that the application does not run, which is typically caused by what I described in my previous post.

    Hamza_HK said:
    Any idea how to debug that problem? 

    Please look at this and my previous post for how to ensure that the bootloader actually starts the application.

  • Hi Einar, 

    I managed to pinpoint the issue here, It is more the application rather than the bootloader. So currently my application (running on nrf52840 dk) is registering the services in services_init but doesn't show all in the nrf connect app on phone. But when I swap to the nrf9160 dk I am able to see all services on the app on my phone..

    I somehow found an issue when doing init gatt, gap and advertising, the debugger pointer enters but never returns from the function and get output on terminal "Stopped by vector catch" followed by SOFTDEVICE ASSERTION FAILED..

  • I found the issue was on the order of initializing the different functions (gatt, gap, ble adv etc)...
    Is there a recommended way to initialize those functions? 

    The application works correct now, I can see all my services and the bootloader starts DFU when receiving 0x01 on the DFU Service. 

    Regards,
    Hamza

  • Hi Hamza,

    I am glad to hear you got it working.

    The order does not always matter unless one depends on another. In that case, you should get a sensible error code when doing something that required something else to be done before. The SoftDevice must be initialized before any other SoftDevice calls, and from there it makes sense to configure GAP related things, then GATT services, and then scanning and/or advertising, though it is not required.

    Einar

Reply
  • Hi Hamza,

    I am glad to hear you got it working.

    The order does not always matter unless one depends on another. In that case, you should get a sensible error code when doing something that required something else to be done before. The SoftDevice must be initialized before any other SoftDevice calls, and from there it makes sense to configure GAP related things, then GATT services, and then scanning and/or advertising, though it is not required.

    Einar

Children
No Data
Related