Serial DFU Procedure and Tips

Serial DFU Procedure and Tips

Hi,

Some of you may need to use Serial DFU to transfer firmware from external MCU or PC. So I am posting this blog to might help saving your time to debug and development.

Serial DFU Sequence


  1. Basic Serial DFU Sequence Diagram

Basically it need to take some time between Transmit and ACK. If you don't have enough time for waiting DFU communication will be failed.

image description

  1. Packet Format

Transmits by PC >>>>> image description

<<<<< ACKs from Target Device image description

Full raw data

  1. Script of flashing Hex

Here is script to get raw data of two way communication. When you use this script it will be helpful to understand and analysis bidirection sequence.

  • For SDK 6.x.x : hci_dfu_send_hex

    The script file placed in "SDK\nrf51822\Board\nrf6310\device_firmware_updates\hci_dfu_send_hex"

    hci_dfu_send_hex.py --verbose --file ble_app_hrs.hex --port COM3

    Raw data of blinky example of SDK 6.1.0

  • For SDK 7.x.x : hci_dfu_send_hex

    The script file placed in "SDK\examples\dfu\hci_dfu_send_hex"

    hci_dfu_send_hex.py --verbose --file ble_app_hrs.hex --port COM3

    Raw data of blinky example of SDK 7.2.0

  • For SDK 8.x.x ~ : pc-nrfutil

    It will be created executable file automatically by "setup.py" and copy compiled resource and executable file to python folder.

    python setup.py install



Tips


  1. Create Executable file

“py2exe” might has an issue that fail to convert python script to windows executable file with access permission error. This way will be an option to avoid issue.

Preparation

  • PyInstaller

  • Prepare icon file to embed in executable file(option)

    Create executable file for windows

    pyinstaller -noconsole --onefile hci_dfu_send_hex.py -i Nordic_Small.ico -n hci_dfu_send_hex


Usage Serial DFU ----------------
  1. ~SDK v 7.x.x
  • The following is an example of how to use the script:

python hci_dfu_send_hex.py -f C:\NewFirmware\ble_app_hrs.hex -p COM7 -fc

  • The following is an example of how to use the executable windows file:

hci_dfu_send_hex.exe -f C:\NewFirmware\ble_app_hrs.hex -p COM7 -fc

  • The following is an example of show raw packet data :

hci_dfu_send_hex.exe -f C:\NewFirmware\ble_app_hrs.hex -p COM7 -fc -v or

hci_dfu_send_hex.exe -f C:\NewFirmware\ble_app_hrs.hex -p COM7 -fc --verbose

  1. SDK v 8.x.x ~

nrfutil.exe dfu serial --package=< image_file.zip > --port=< com_port > [--flowcontrol] [--baudrate <baud_rate>]

Parents Comment Children
No Data