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

USB Dfu cause hash not match issue.

hi,

I am working on nrf52833 dfu. right now I received an error 

raise NordicSemiException('Extended Error 0x{:02X}: {}'.format(resp[3], data))
pc_ble_driver_py.exceptions.NordicSemiException: Extended Error 0x0C: The hash of the received firmware image does not match the hash in the init packet.

it happened when 96% finished.

my dfu memory settings is :

FLASH (rx) : ORIGIN = 0x74000, LENGTH = 0xA000
RAM (rwx) : ORIGIN = 0x20002ae8, LENGTH = 0x1d518
uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
bootloader_settings_page (r) : ORIGIN = 0x0007F000, LENGTH = 0x1000
uicr_mbr_params_page (r) : ORIGIN = 0x10001018, LENGTH = 0x4
mbr_params_page (r) : ORIGIN = 0x0007E000, LENGTH = 0x1000

and my application is :

FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x4D000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000

Parents Reply
  • Hi Weizhen, 
    I have made an example for USB DFU on nRF52833. I attached the project (pca10100_usb_debug_833.zip) here. 
    It's made on SES and was modified from pca10100e_usb_debug. But should be straight forward to port to gcc. I would suggest to compare the .emProject file and the flash_placement.xml file to see my modification and apply the same to your gcc Makefile. Main changes were flash size and address, ram address and size, hard floating point. 

    I also attached the .hex file I used (mbr, bootloader and the dfu .zip file) so you can test on your side. 

    Before you test, please make sure to do a chip erase.
     833DFU.zip

Children
  • hi Hung Bui,

    I tested with the bootloader file you give me, it can flash the blink flash, and it can runned. but for usb debug package, it cannot flash, and return an error message.

    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 829, in __call__
    return self.main(*args, **kwargs)
    File "/usr/local/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
    File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
    File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
    File "/usr/local/lib/python3.7/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
    File "/usr/local/lib/python3.7/site-packages/nordicsemi/__main__.py", line 1015, in usb_serial
    timeout)
    File "/usr/local/lib/python3.7/site-packages/nordicsemi/__main__.py", line 964, in do_serial
    dfu = Dfu(zip_file_path = package, dfu_transport = serial_backend, connect_delay = connect_delay)
    File "/usr/local/lib/python3.7/site-packages/nordicsemi/dfu/dfu.py", line 69, in __init__
    self.manifest = Package.unpack_package(zip_file_path, self.unpacked_zip_path)
    File "/usr/local/lib/python3.7/site-packages/nordicsemi/dfu/package.py", line 650, in unpack_package
    with open(os.path.join(target_dir, Package.MANIFEST_FILENAME), 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/m9/th1fg8h54d33zsz93rypyvdc0000gn/T/nrf_dfu_6dmao_5m/unpacked_zip/manifest.json'

    also with serial window open, I have not see any debug message print out, are you using uart debug or rtt debug?

  • Hi Weizhen, 
    Could you explain what you meant by "but for usb debug package, it cannot flash, and return an error message" ? 

    You supposed to unzip pca10100_usb_debug_833.zip put that into the bootloader example in SDK and then compile the bootloader using Segger Embedded Studio . Do that you will get the bootloader .hex file. 

    If you want to compile using gcc you would need to modify your make file according to what I did in the .emProject  file and flash_placement.xml file. 

  • hi Hung Bui,

    after check the pca10100_usb_debug_833.zip you send to me. I switch the log mode I used from uart to rtt, and it works. then I do more test and found maybe there is some issues with uart log. based on my result, turn off the log or using rtt log both works, but using uart log causes the issue.

  • Hi Weizhen, 
    I'm sorry for the late response. 
    I have tested here and reproduced the issue. I dig a little bit more and I think I found the bug. 
    In nrf_bootloader_app_start() in nrf_bootloader_app_start.c we disable all interrupts and then we call NRF_LOG_FLUSH();

    This will cause a dead loop inside serial_tx() if you use  UART for logging. Resulting the app never executed. 
    if you call  NRF_LOG_FLUSH(); before disabling interrupts

    NVIC->ICER[0]=0xFFFFFFFF;
    NVIC->ICPR[0]=0xFFFFFFFF;

    it should work. 

  • Thanks, Bui, I think this fix works for me. but we also found another bug, which feels the usb dfu in this version do not clear NRF_POWER->GPREGRET after flash or time out. used when we working on nrf52832 with gpregret enter mode, the chip can go back to application after flash and time out, but now it stay in bootloader mode until power off the chip, which will reset the NRF_POWER->GPREGRET

Related