This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB-serial DFU without softdevice doesn't work using SDK 17.1.0.

I have an issue with DFU via USB CDC ACM.
I would like to update the firmware using open bootloader over USB without softdevice.
I already tried to follow the thread: devzone.nordicsemi.com/.../nordic-q-a/43698/bootloader-serial-dfu-without-softdevice-sdk-15?ReplySortBy=CreatedDate&ReplySortOrder=Ascending and also I've tried to follow the nrfutil/bootloader documentation.
My design is based on $SDK_path/nRF5_SDK_17.1.0_ddde560/examples/dfu/open_bootloader and the blink app. I have tried to use the precompilend one as well as compiled from source by myself (mbr version).

My steps and output:

Clear nrf52 flash memory and UICR:
bartek@iMac open_bootloader % make erase
nrfjprog -f nrf52 --eraseall
Erasing user available code and UICR flash areas.
Applying system reset.

I thing for the open bootloader I don't need this step, but anyway I have generated the key:
bartek@iMac open_bootloader % nrfutil keys generate private.key
bartek@iMac open_bootloader % nrfutil keys display --key pk --format code private.key --out_file public_key.c

Then I have coppied generated key from the public_key.c into the dfu_public_key.c from the example/dfu and maked the project:
bartek@iMac open_bootloader % make
Linking target: _build/nrf52840_xxaa_debug.out
text data bss dec hex filename
66460 276 45940 112676 1b824 _build/nrf52840_xxaa_debug.out
Preparing: _build/nrf52840_xxaa_debug.hex
Preparing: _build/nrf52840_xxaa_debug.bin

Generate basic settings:
bartek@iMac open_bootloader % nrfutil settings generate --family NRF52840 --application my_blink_mbr.hex --application-version 1 --bootloader-version 1
--bl-settings-version 1 settings.hex

Note: Generating a DFU settings page with backup page included.
This is only required for bootloaders from nRF5 SDK 15.1 and newer.
If you want to skip backup page generation, use --no-backup option.

Generated Bootloader DFU settings .hex file and stored it in: settings.hex

Bootloader DFU Settings:
* File: settings.hex
* Family: NRF52840
* Start Address: 0x000FF000
* CRC: 0xC9728D3D
* Settings Version: 0x00000001 (1)
* App Version: 0x00000001 (1)
* Bootloader Version: 0x00000001 (1)
* Bank Layout: 0x00000000
* Current Bank: 0x00000000
* Application Size: 0x00000744 (1860 bytes)
* Application CRC: 0x86FFD574
* Bank0 Bank Code: 0x00000001
* Softdevice Size: 0x00000000 (0 bytes)
* Boot Validation CRC: 0x00000000
* SD Boot Validation Type: 0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

generate the package:
bartek@iMac open_bootloader % nrfutil pkg generate --hw-version 52 --application-version 1 --application my_blink_mbr.hex --key-file private.key --sd-r
eq 0 my_blink_mbr.zip
Zip created at my_blink_mbr.zip

flash the mbr:
bartek@iMac open_bootloader % make flash_mbr

nrfjprog -f nrf52 --program ../support/sdk/nRF5_SDK_17.1.0_ddde560/components/softdevice/mbr/hex/mbr_nrf52_2.4.1_mbr.hex --sectorerase
Parsing image file.
Erasing page at address 0x0.
Applying system reset.
Checking that the area to write is not protected.
Programming device.
nrfjprog -f nrf52 --reset
Applying system reset.
Run.

flash the bootloader:
bartek@iMac open_bootloader % make flash
DONE nrf52840_xxaa_debug
Flashing: _build/nrf52840_xxaa_debug.hex
nrfjprog -f nrf52 --program _build/nrf52840_xxaa_debug.hex --sectorerase
Parsing image file.
Erasing page at address 0xE0000.
Erasing page at address 0xE1000.
Erasing page at address 0xE2000.
Erasing page at address 0xE3000.
Erasing page at address 0xE4000.
Erasing page at address 0xE5000.
Erasing page at address 0xE6000.
Erasing page at address 0xE7000.
Erasing page at address 0xE8000.
Erasing page at address 0xE9000.
Erasing page at address 0xEA000.
Erasing page at address 0xEB000.
Erasing page at address 0xEC000.
Erasing page at address 0xED000.
Erasing page at address 0xEE000.
Erasing page at address 0xEF000.
Erasing page at address 0xF0000.
WARNING: A UICR write operation has been requested but UICR has not been
WARNING: erased. Please verify that the result is correct.
Applying system reset.
Checking that the area to write is not protected.
Programming device.
nrfjprog -f nrf52 --reset
Applying system reset.
Run.

Load the package:
bartek@iMac open_bootloader % nrfutil dfu usb-serial -pkg my_blink_mbr.zip -p /dev/tty.usbmodemD28CF7D29DCC1 -b 115200 -fc 1
[------------------------------------] 0%
Traceback (most recent call last):
File "/usr/local/bin/nrfutil", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/nordicsemi/__main__.py", line 1023, in usb_serial
timeout)
File "/usr/local/lib/python3.7/site-packages/nordicsemi/__main__.py", line 978, in do_serial
dfu.dfu_send_images()
File "/usr/local/lib/python3.7/site-packages/nordicsemi/dfu/dfu.py", line 127, in dfu_send_images
self._dfu_send_image(self.manifest.application)
File "/usr/local/lib/python3.7/site-packages/nordicsemi/dfu/dfu.py", line 88, in _dfu_send_image
self.dfu_transport.open()
File "/usr/local/lib/python3.7/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 217, in open
self.__get_mtu()
File "/usr/local/lib/python3.7/site-packages/nordicsemi/dfu/dfu_transport_serial.py", line 366, in __get_mtu
self.mtu = struct.unpack('<H', bytearray(response))[0]
TypeError: 'NoneType' object is not iterable

And the RTT logs:
<info> app: Open USB bootloader started
<debug> app: In nrf_bootloader_init
<debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
<debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
<debug> nrf_dfu_settings: Using settings page.
<debug> nrf_dfu_settings: Copying forbidden parts from backup page.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<debug> app: Enter nrf_bootloader_fw_activate
<info> app: No firmware to activate.
<info> app: Boot validation failed. No valid app to boot.
<debug> app: DFU mode because app is not valid.
<info> nrf_bootloader_wdt: WDT is not enabled
<debug> app: in weak nrf_dfu_init_user
<debug> app: timer_stop (0x20000048)
<info> app: Entering DFU mode.
<info> app_timer: RTC: initialized.
<debug> app: Initializing transports (found: 1)
<debug> nrf_dfu_serial_usb: Initializing drivers.
<debug> nrf_dfu_serial_usb: Starting USB
<debug> nrf_dfu_serial_usb: USB Transport initialized
<debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
<debug> app: Enter main loop
<info> nrf_dfu_serial_usb: USB power detected
<info> nrf_dfu_serial_usb: USB ready
<warning> nrf_dfu_serial_usb: Could not read from CDC. Error: 0x92.


My configuration:
Board: NRF52840DK PCA10056
SDK: nRF5_SDK_17.1.0_ddde560
Compiler: gcc-arm-none-eabi-9-2019-q4-major-mac
OS: macOS Big Sur 11.3
Nrf Util: nrfutil version 6.1.3
Python: 3.7.12
IDE: VS code + GCC + SDK.
Softdevice: No Softdevice.

system_profiler SPUSBDataType USB:
Open DFU Bootloader:
Product ID: 0x521f
Vendor ID: 0x1915 (Nordic Semiconductor ASA)
Version: 1.00
Serial Number: D28CF7D29DCC
Speed: Up to 12 Mb/s
Manufacturer: Nordic Semiconductor
Location ID: 0x14320000 / 37
Current Available (mA): 500
Current Required (mA): 100
Extra Operating Current (mA): 0

Thank you in advance
  • Thank you for reply;

    Try updating your nrfjprog to the latest version (10.15.0). nRF Command Line Tools

    Updated:

    bartek@iMac open_bootloader % nrfjprog --version
    nrfjprog version: 10.15.0 external
    JLinkARM.dll version: 6.88a

    If, when you update nrfjprog, you still get the same error, are you sure you are using the correct serial port?

    bartek@iMac open_bootloader % system_profiler SPUSBDataType

    Open DFU Bootloader:

    Product ID: 0x521f
    Vendor ID: 0x1915 (Nordic Semiconductor ASA)
    Version: 1.00
    Serial Number: D28CF7D29DCC
    Speed: Up to 12 Mb/s
    Manufacturer: Nordic Semiconductor
    Location ID: 0x14320000 / 35
    Current Available (mA): 500
    Current Required (mA): 100
    Extra Operating Current (mA): 0

    bartek@iMac open_bootloader % ls /dev | grep D28
    cu.usbmodemD28CF7D29DCC1
    tty.usbmodemD28CF7D29DCC1

    bartek@iMac open_bootloader % ls /dev | grep usb
    cu.usbmodemD28CF7D29DCC1
    tty.usbmodemD28CF7D29DCC1

    These are ports related to the nrf USB (3), I am sure I am using proper port.

  • Ok, perhaps there is something else using the USB port? Do you have it selected in nRF Connect for Desktop, some USB terminal or something other than for nrfutil? Try power cycling the board right before you call the "nrfutil dfu usb-serial ..." command to make sure. Can you try using python 3.8? I see that you are currently using 3.7.

    BR,
    Edvin

  • I had to switch to other project, and today I came back to the bootloader, and everything worked fine. I have tried to do it in a number of different ways and no issues occurred.
    Maybe there was some MacOS update in the meanwhile, so seems it could be an OS issue.

    I have tried programming the nrf without merging bootloader with the settings:

    mergehex --merge settings.hex  _build/nrf52840_xxaa_debug.hex --output output.hex.

    Here is my question: what is the difference between these two approaches? I have only noticed the black memory blocks have different size:

    block sizes from top when using output.hex file (bootloader + settings): 135; 92; 135; 92 (described as MBR parameters);
    block sizes from top when using bootloader file without settings: 292; 92; 292; 92 (described as MBR parameters);

  • fizyk said:
    what is the difference between these two approaches?

    What exactly are "these two approaches"? Programming with and without merging? Or with or without settings?

    With or without merging shouldn't be a difference. It may be that nRF Connect for desktop is confused if they are written as one file or not when you read it back, but if you read back the hex file using "nrfjprog --readcode flashdump.hex", it shouldn't be any difference.

    With or without settings:

    If you don't program bootloader settings, then the bootloader will generate it's own settings. It may be that the size of the default settings is different from the settings generated from nrfutil.

    BR.
    Edvin

  • Thank you very much! I think this topic can be closed as solved. Cheers!

Related