adafruit / Adafruit_nRF52_nrfutil

Modified version of Nordic's nrfutil 0.5.x for use with the Adafruit Feather nRF52
BSD 3-Clause "New" or "Revised" License
87 stars 29 forks source link

DFU bootloader fails after init packet #15

Closed irarykim closed 4 years ago

irarykim commented 4 years ago

Problem description:

Operations:

  1. Flash the Adafruit nRF52 Bootloader hex file(with SoftDevice) to PCA10056.
  2. Generate bootloader package file using adafruit_nrfutil from Adafruit nRF52 Bootloader hex file without SoftDevice.
  3. Update bootloader using adafruit_nrfutil, but it failed.

Environments:

OS: Windows 10 Pro 1903 Board: PCA10056 (nRF52840 D/K made by Nordic Semiconductor) adafruit-nrfutil: version 0.5.3.post12 (commit version) (use python 3.8 to generate exe file) Bootloader used: Adafruit_nRF52_Bootloader master v0.3.2 Shell: windows powershell (Runs as Administrator)

The log for generating bootloader dfu package:

PS D:\SW\E2\Debug\DFU> .\adafruit-nrfutil.exe dfu genpkg --dev-type 0x0052 --bootloader .\pca10056_bootloader-0.3.0-8-g3666e69-dirty-nosd.hex .\pca10056_bootloader-0.3.0-8-g3666e69-dirty-nosd.zip
Zip created at .\pca10056_bootloader-0.3.0-8-g3666e69-dirty-nosd.zip

The log for updating bootloader:

PS D:\SW\E2\Debug\DFU> .\adafruit-nrfutil.exe --verbose dfu serial -p COM13 -b 115200 --singlebank -pkg .\pca10056_bootloader-0.3.0-8-g3666e69-dirty-nosd.zip --touch 1200
Upgrading target on COM13 with DFU package D:\SW\E2\Debug\DFU\pca10056_bootloader-0.3.0-8-g3666e69-dirty-nosd.zip. Flow control is disabled, Single bank, Touch 1200
Touched serial port COM13
Opened serial port COM13
Starting DFU upgrade of type 2, SoftDevice size: 0, bootloader size: 30144, application size: 0
Sending DFU start packet
Sending DFU init packet
Sending firmware file

Failed to upgrade target. Error is: WriteFile failed (PermissionError(13, 'The device does not recognize the command.', None, 22))
Traceback (most recent call last):
  File "nordicsemi\__main__.py", line 294, in serial
  File "nordicsemi\dfu\dfu.py", line 232, in dfu_send_images
  File "nordicsemi\dfu\dfu.py", line 206, in _dfu_send_image
  File "nordicsemi\dfu\dfu_transport_serial.py", line 213, in send_firmware
  File "nordicsemi\dfu\dfu_transport_serial.py", line 241, in send_packet
  File "site-packages\serial\serialwin32.py", line 315, in write
serial.serialutil.SerialException: WriteFile failed (PermissionError(13, 'The device does not recognize the command.', None, 22))

Possible causes:
- Selected Bootloader version does not match the one on Bluefruit device.
    Please upgrade the Bootloader or select correct version in Tools->Bootloader.
- Baud rate must be 115200, Flow control must be off.
- Target is not in DFU mode. Ground DFU pin and RESET and release both to enter DFU mode.

USB Raw data: PC -> Board:

START PACKET: (0xDBDC might be the replacement of 0xC0)
C0 D1 4E 01 E0 03 00 00 00 02 00 00 00 00 00 00 00 DB DC 75 00 00 00 00 00 00 47 99 C0
INIT PACKET:
C0 DA 4E 01 D7 01 00 00 00 52 00 FF FF FF FF FF FF 01 00 FE FF 3D 28 00 00 9F 2A C0

Board -> PC:

C0 10 00 00 F0 C0 (ACK)
C0 18 00 00 E8 C0 (ACK)
irarykim commented 4 years ago

It is my mistake.. I should try make BOARD=pca10056 SERIAL=COM13 dfu-flash command showed in https://github.com/adafruit/Adafruit_nRF52_Bootloader#option-1-build-with-makefile