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

Secure Bootloader USB Debug only works if there's no application in the flash

IAR 7.60

52840

nRF5_SDK_15.2.0_9412b96

Hi there,
I'm trying to do some modification in the bootloader (so that we can write the image to the flash's bank1 using our custom method via wifi and just have the bootloader proceed from there).  But using the "secure_bootloader_usb_mbr_pca_10056_debug", I can only run the upgrade once, only if there's no application on the flash.
Once upgraded, the second fails with this message.  I don't make any modification yet to the bootloader.  Any idea how to continue using the debug bootloader even if there's image?

To be exact, after the application is written, the Device Manager no longer shows the COM port.  But, you hear the noise that a new USB device is found, but it shows nothing in the Device Manager.

C:\turing\github\trunk\wearable\pivot_3_0\binaries>nrfutil dfu usb_serial -pkg nordic_main_green.zip -p COM26
[####################################] 100%
Device programmed.

C:\turing\github\trunk\wearable\pivot_3_0\binaries>nrfutil dfu usb_serial -pkg nordic_main_green.zip -p COM26
[------------------------------------] 0%
Traceback (most recent call last):
File "nordicsemi\__main__.py", line 1133, in <module>
File "site-packages\click\core.py", line 722, in __call__
File "site-packages\click\core.py", line 697, in main
File "site-packages\click\core.py", line 1066, in invoke
File "site-packages\click\core.py", line 1066, in invoke
File "site-packages\click\core.py", line 895, in invoke
File "site-packages\click\core.py", line 535, in invoke
File "nordicsemi\__main__.py", line 827, in usb_serial
File "nordicsemi\__main__.py", line 793, in do_serial
File "nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
File "nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
File "nordicsemi\dfu\dfu_transport_serial.py", line 200, in open
pc_ble_driver_py.exceptions.NordicSemiException: Serial port could not be opened on {0}. Reason: could not open port 'COM26': WindowsError(2, 'The system cannot find the file specified.')
Failed to execute script __main__

C:\turing\github\trunk\wearable\pivot_3_0\binaries>

Parents Reply Children
  • I did not add "DFU Trigger Library" to the application yet.

    However, I forgot to tell you, actually I changed something in the bootloader.  I changed the setting to
    "#define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 10000"

    In the non-debug version of the bootloader, it works as I intended.  That is, when I plug in the Nordic to the USB, it will show up as "nrf52 sDFU USB" in the Device Manager for 10 seconds before it tries to go to application.  So it gives me opportunity to update the FW within 10 seconds.

    But in the debug version, it doesn't work the same way.  Why? Should I prepare the application differently if I use Debug Bootloader?

  • When you power on the chip, the bootloader will check if it should enter DFU mode or not. There are several methods to enter DFU mode, and you can configure them in sdk_config.h. The different methods are documented here. If none of these methods have been used to activate DFU mode, the bootloader will check if the application is valid, and if it's valid, the bootloader will start the app.

    The inactivity timer is used when you activate and enter DFU mode, and then you have the configured amount of ms to start the DFU, before the bootloader exits DFU mode, and tries to start the app again. If the non-debug bootloader does not start the app immediately, then one of the methods for entering DFU mode have been activated, OR the app that is on the chip is not valid.

    I can only run the upgrade once, only if there's no application on the flash.

    You need a way to enter DFU mode. By default, the project have NRF_BL_DFU_ENTER_METHOD_BUTTON enabled, with NRF_BL_DFU_ENTER_METHOD_BUTTON_PIN set to 25. That means that you can hold down button 4 when you reset the board, and then the bootloader will enter DFU mode.

Related