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

Enter Bootloader from App SDK15

I am struggling with getting a Secure UART(Serial) DFU operation to function correctly when I attempt to enter the bootloader with a call from my app. I am using the basic Secure Serial Bootloader example from SDK15. The bootloader enters DFU and correctly updates an app image when I use a button to enter the DFU. It also works great when I have NO app flashed in the device. But when I try to call the boot/DFU process from within my app I get a "No ping response after opening COM port" error from nrfutil.

My trigger is a cmd (thru the UART) that I detect. I then close my UART and disable any timers that I have used, as well as terminating the use of any other peripherals. I then delay about 100mS and then execute the following lines of code:

  nrf_power_gpregret_set(nrf_power_gpregret_get() | BOOTLOADER_DFU_START);
  nrf_power_gpregret2_set(BOOTLOADER_DFU_SKIP_CRC);
  nrf_delay_ms(50);
  NVIC_SystemReset();

Then, from a cmd shell window I execute the nrfutil dfu process with:

PS C:\..\Wayne\> nrfutil dfu serial -pkg app_v109_pkg.zip -p COM5 -b 115200 -fc 0

I get the following response:

***************************************************************************************************

PS C:\..\Wayne\> nrfutil dfu serial -pkg app_v109_pkg.zip -p COM5 -b 115200 -fc 0
  [------------------------------------]    0%
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\nrfutil.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\python27\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 745, in serial
    do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, True)
  File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 680, in do_serial
    dfu.dfu_send_images()
  File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
    self._dfu_send_image(self.manifest.application)
  File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
    self.dfu_transport.open()
  File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 211, in open
    raise NordicSemiException("No ping response after opening COM port")
pc_ble_driver_py.exceptions.NordicSemiException: No ping response after opening COM port
PS C:\..\Wayne\>

***************************************************************************************************

When I enter the bootloader with BTN 4/Reset and the very same cmd line:

(PS C:\..\Wayne\> nrfutil dfu serial -pkg app_v109_pkg.zip -p COM5 -b 115200 -fc 0)

All works just fine.

What am I missing?

Thanks for your help.

(I have seen several other postings about 'buttonless' DFU and followed them closely.)

Parents
  • Hi,

     

    I don't see what could be the issue here. But could you try to test using the _uart_debug project ? It has logging enabled and you can see the log with Jlink RTT Viewer. You may want to check if the bootloader actually enter DFU mode after reset or not (GPREGRET register has been written and read correctly, check function dfu_enter_check() ). Make sure you set NRF_BL_DFU_ENTER_METHOD_GPREGRET = 1 in sdk_config.h
    If the log doesn't reveal what could be the problem, you may need to step/add breakpoint into the code to see if it receive any command from the PC. You may need to change the optimization level to level 0 to be able to step . 

Reply
  • Hi,

     

    I don't see what could be the issue here. But could you try to test using the _uart_debug project ? It has logging enabled and you can see the log with Jlink RTT Viewer. You may want to check if the bootloader actually enter DFU mode after reset or not (GPREGRET register has been written and read correctly, check function dfu_enter_check() ). Make sure you set NRF_BL_DFU_ENTER_METHOD_GPREGRET = 1 in sdk_config.h
    If the log doesn't reveal what could be the problem, you may need to step/add breakpoint into the code to see if it receive any command from the PC. You may need to change the optimization level to level 0 to be able to step . 

Children
  • Hi Hung Bui,

    Thanks for insight. I took the uart_debug project and added a few extra logging statements.

    I also took my basic app and added logging into it. I also used a load file to insure that the app was loading just above the mbr. (I don't need a SoftDevice for this app.)

    After doing that, I flashed the BootLoader/MBR into my device and then performed a dfu operation to load my app. (I entered the dfu process because, as expected, there was NO app found by the bootloader. ) That dfu worked just fine.

    My app then started and I could see the log entries for it.

    I then caused the app to enter the bootload process by a uart cmd that I had created. I can see the app generating the gpregret request for the bootloader and then see the bootloader actually taking over.

    I then entered an nrfutil cmd to initiate a dfu process. That command terminates with an error of "No ping response after opening COM port."

    In the RTTViewer, I can see the app's request for the dfu operation; the bootloader init process; and eventually see the Ping received. I can see that the dfu sends a response, but sits there until finally I get an Inactivity timeout.

    I am putting copies of the RTT window and the nrfutil window at the end of this message.

    Can you tell why the ping response gets lost?

    Thanks for your help.

    Wayne

    RTTViewer output==>

     0> <info> app: TCK_happens_NORM
     0> <info> app: Inside My secure BL main
     0> <info> app: Gpregret == B1  :
     0> <info> app: Calling nrf_bootloader_init
     0> <debug> app: In nrf_bootloader_init
     0> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
     0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
     0> <debug> app: Enter nrf_bootloader_fw_activate
     0> <info> app: No firmware to activate.
     0> <debug> app: Enter nrf_dfu_app_is_valid
     0> <debug> app: Return true. App was valid
     0> <debug> app: DFU mode requested via GPREGRET.
     0> <info> nrf_bootloader_wdt: WDT is not enabled
     0> <debug> app: in weak nrf_dfu_init_user
     0> <info> app_timer: RTC: initialized.
     0> <info> app: Entering DFU mode.
     0> <debug> app: Initializing transports (found: 1)
     0> <debug> nrf_dfu_serial_uart: serial_dfu_transport_init()
     0> <debug> nrf_dfu_serial_uart: serial_dfu_transport_init() completed
     0> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
     0> <debug> app: Enter main loop
     0> <debug> app: Shutting down transports (found: 1)
     0> <debug> nrf_dfu_serial: Received ping 1
     0> <info> nrf_dfu_serial_uart: Allocated buffer 20001318
     0> <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING
     0> <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
     0> <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1]
     0> <info> app: Inactivity timeout.
     0> <debug> app: Resetting bootloader.
     0> <info> app: Inside My secure BL main
     0> <info> app: Gpregret == 0  :
     0> <info> app: Calling nrf_bootloader_init

    ********************************************************************************************************************

    CndShell_output ==>

    PS C:\...> nrfutil dfu serial -pkg MyLoad_v1022.zip -p COM5 -b 115200
      [------------------------------------]    0%
    Traceback (most recent call last):
      File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "c:\python27\lib\runpy.py", line 72, in _run_code
        exec code in run_globals
      File "C:\Python27\Scripts\nrfutil.exe\__main__.py", line 9, in <module>
      File "c:\python27\lib\site-packages\click\core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "c:\python27\lib\site-packages\click\core.py", line 697, in main
        rv = self.invoke(ctx)
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "c:\python27\lib\site-packages\click\core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "c:\python27\lib\site-packages\click\core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 745, in serial
        do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, True)
      File "c:\python27\lib\site-packages\nordicsemi\__main__.py", line 680, in do_serial
        dfu.dfu_send_images()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 129, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu.py", line 90, in _dfu_send_image
        self.dfu_transport.open()
      File "c:\python27\lib\site-packages\nordicsemi\dfu\dfu_transport_serial.py", line 211, in open
        raise NordicSemiException("No ping response after opening COM port")
    pc_ble_driver_py.exceptions.NordicSemiException: No ping response after opening COM port
    PS C:\...>

    ***********************************************************************************

  • HiHung Bui,

    one more item to consider: I have been looking at the two log files and chasing through the code in the BootLoader/dfu. I notice that the device replies to the Ping request, but nrfutil never sees it.

    I go to great pains to disable the timer and the uart used in my app so that the bootloader has a relatively clean peripheral set when it starts up. 

    I know that my app does not use HW Flow Control thru the UART, but I see that the BL/dfu does use HWFC. Could my uart config be hanging around and messing with the BL process?

    Wayne

  • Hi Hung Bui-

    SUCCESS!

    I played with the HW Flow Control setting some more and determined that was the issue. My app does not use HWFC but the BL/dfu does. If I create images where both BL/dfu and my app use HWFC, it works fine! If I create images where both BL/dfu and my app DON'T use HWFC, it works just fine.

    I consider this issue resolved!!

    Thanks for letting me whine and chase through the stuff!

    Wayne

Related