I'm attempting to use the serial DFU bootloader to update my nRF52832 firmware but am unable to. I started by following this guide though I changed some things so that the uart and not the ble bootloader was loaded. My setup consists of a nRF52832 on a custom board connected via a serial port to a linux computer. I'm using the most recent SDK (15.3) My process so far has been:
- Generate public and private keys with nrfutil
- Compiling uECC in external/micro-ecc/nRF52hf_gcc/armgcc
- Building the bootloader in examples/dfu/secure_bootloader/pca10040_uart_debug/armgcc
- Flash the nRF with the commands
nrfjprog -f nrf52 --program softdevice.hex --chiperase nrfjprog -f nrf52 --program bootloader.hex -r
Thanks to a comment on this post.
I should note that when I flash with the version of the bootloader in pca10040_ble_debug, the nRF now begins advertising with the name DFUTarg, indicating to me that the DFU bootloader has been loaded successfully. - In my Linux computer, which is separate from the computer I flashed the Bluetooth module with, I generate a DFU packet with the ble_app_blinky example and my private key with the command
nrfutil pkg generate --debug-mode --application ble_blinky_example.hex --key-file private.key app_dfu_package.zip
- Try to perform a DFU with the command
nrfutil dfu serial -pkg app_dfu_package.zip -p /dev/ttymxc3 -b 115200
At this point after a while the terminal where I run nrfutil prints "pc_ble_driver_py.exceptions.NordicSemiException: No ping response after opening COM port".
To try to figure out what was going wrong, I added a bunch of debug statements in the files for the DFU bootloader and in dfu_transport_serial.py, which is called by nrfutil. On the terminal where I run nrfutil, I see that it continuously sends pings to the nRF but never receives a response. I also confirmed that the serial connection made with pyserial has identical parameters to serial connections I have made between my Linux computer and the nRF in the past, where each device was able to send and receive properly. Using the JLinkRTTViewer, I see the following from the nRF when I try to perform the DFU (please excuse the inconsistent debug format):
in nrfx_uarte_0_irq_handler in nrfx_uarte uarte_irq_handler Receive buffer is filled up secondary buffer == 0 in nrfx_uarte rx_done_event in nrf_drv_uart uarte_evt_handler in nrfx_uarte_rx Function: nrfx_uarte_rx, error code: NRF_SUCCESS. reached end of uarte_irq_handler in nrfx_uarte_0_irq_handler in nrfx_uarte uarte_irq_handler Receive buffer is filled up secondary buffer == 0 in nrfx_uarte rx_done_event in nrf_drv_uart uarte_evt_handler in nrfx_uarte_rx Function: nrfx_uarte_rx, error code: NRF_SUCCESS. reached end of uarte_irq_handler in nrfx_uarte_0_irq_handler in nrfx_uarte uarte_irq_handler Receive buffer is filled up secondary buffer == 0 in nrfx_uarte rx_done_event in nrf_drv_uart uarte_evt_handler in nrfx_uarte_rx Function: nrfx_uarte_rx, error code: NRF_SUCCESS. reached end of uarte_irq_handler in nrf_drv_uart_tx NRF_DRV_UART_USE_UARTE==true in nrfx_uarte_tx in nrf_uarte_tx_buffer_set <debug> nrf_dfu_serial: Received ping 1 <info> nrf_dfu_serial_uart: Allocated buffer 20001764 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1] in nrfx_uarte_0_irq_handler in nrfx_uarte uarte_irq_handler Receive buffer is filled up secondary buffer == 0 in nrfx_uarte rx_done_event in nrf_drv_uart uarte_evt_handler in nrfx_uarte_rx Function: nrfx_uarte_rx, error code: NRF_SUCCESS. reached end of uarte_irq_handler in nrfx_uarte_0_irq_handler in nrfx_uarte uarte_irq_handler Receive buffer is filled up secondary buffer == 0 in nrfx_uarte rx_done_event in nrf_drv_uart uarte_evt_handler in nrfx_uarte_rx Function: nrfx_uarte_rx, error code: NRF_SUCCESS. reached end of uarte_irq_handler in nrfx_uarte_0_irq_handler in nrfx_uarte uarte_irq_handler Receive buffer is filled up secondary buffer == 0 in nrfx_uarte rx_done_event in nrf_drv_uart uarte_evt_handler in nrfx_uarte_rx Function: nrfx_uarte_rx, error code: NRF_SUCCESS. reached end of uarte_irq_handler in nrf_drv_uart_tx NRF_DRV_UART_USE_UARTE==true in nrfx_uarte_tx uarte tx in progress <debug> nrf_dfu_serial: Received ping 2 <info> nrf_dfu_serial_uart: Allocated buffer 20001764 <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1 <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1] <error> nrf_dfu_serial: Failed to send data over serial interface!
So it seems that the Bluetooth module is receiving the ping and attempting to send a response but the python script called by nrfutil never receives it. Thinking that nrfutil may simply be pinging too frequently and too quickly, I tried adding a delay but that didn't help. I have written other programs on this same set up where the nRF device was able to send serial messages that were received by the Linux computer, so I'm not sure what could be the issue now. Does anybody have any suggestions?