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
  • I have not change the bootloader code, the only thing I change is makefile and config file, due to there is no example for pca10100 usb with softdevice s140.and also I change the public_key
    I use nrfutil dfu usb-serial -pkg <.zip file> -p <serial port> -fc 0 to flash, and use nrfutil pkg generate --hw-version 52 --sd-req 0xCA --application-version 1 -- application <hex file> --key-file <priv.pen file> <output> to generate the package

  • So what bootloader project did you start with? I suggest you look into starting with the SDK17\examples\dfu\secure_bootloader\pca10056_usb,

    But you need to change the memory settings. 

    Does your bootloader and/or application support BLE as well as USB?

    Your dfu memory settings suggests that you have a softdevice, but your application does not.

    Let's assume you have a softdevice:

    You should change your application's ram to the same as your bootloader's to account for the softdevice.

    There are some other things you should change in the makefile as well. What does your preprocessor definitions and assembly flags look like? (CFLAGS and ASMFLAGS). Perhaps there are some of those that suggests you are using a different chip?

    Also, make sure to set the TARGETS := nrf52833_xxaa_s140.

    I assume you have checked, but are you 100% sure that you used the same key to generate the dfu image as you used in the bootloader? (that you are using the matching private key for the bootloader's public key).

  • Hi Weizhen, 

    I'm taking over Edvin as he is taking vacation. 
    Could you please explain a little bit what you want to do DFU ? Are you planning to do DFU for only application or application + softdevice. 
    I would suggest to test doing DFU with only application first. If you do that you don't need to specify the softdevice.
    You can follow my blog here: https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader

  • I tried, with the application only, the application is still not running

  • Have you tried to follow my blog ? Please try to update with a simple example first. 


    Please describe what exactly you observed? The DFU update run until 100% and you don't see any app running after that ? nor bootloader running ? 
    Please do what Edvin suggested and check the logging of the bootloader and the DFU master. 

  • first your blog is not working for me. let's make clear, this issue only happened on sdk 17, which released weeks ago. we have working uart dfu for nrf52832 which used sdk 14, and a working usb dfu for nrf52840 which used sdk 15. 

    so there is two things, one is a bootloader which I start from an ble bootloader example, and try to make it works for usb. it uses softdevice. it get the hash not match issue at the end of flash. the issue happened when it flashed 96%. after using the '-prn 256' it change to 98%.

    then I followed edvin suggested, to start from a usb bootloader with debug, and make it work for the chip I want to use, which is nrf52833. also I have no idea why you guys do not have the example code for that. then that works, that can flashed all the code, but then the application is not runing, I think I am clear here, it is the application not running, which means the bootloader is runing, I can get the "Inside main" print out. 

    then I check the memory usage by using nrf connect, found there is something wrong, first there is no softdevice detected. the code is there, but it detected as application. second, the softdevice start address is not right, I think right now 0x0 to 0x1000 is used for mbr, and sd start at 0x1000, but based the memory I get after dfu, it start at 0xFF8. I also checked when I flash the mbr, there is a 8 bytes start at 0xFF8, but when I flashed sd, the 8 bytes is not there.

  • from the debug version print, I get "app: Inside main" at the end, which means it should enter the application mode, but the application is not really run, and the code seems stopped.

Reply Children
  • Hi ,

    Hung is currently out of office on vacation but he will be back next week. Thanks for your patience.

  • Hi Weizhen, 
    I'm sorry for late response I was on vacation last week.

    Could you send us the bootloader that you made for the nRF52833 ? Are you using open bootloader or the secure one ? From which project did you modify the bootloader to ? Was it the one for nRF52832 or nRF52840 ? 


    The address 0xFF8 is used to store the start address of the bootloader in the MBR.  This is optional as the start address of the bootloader is also stored in the UICR.

  • pca10100_usb_debug.zippca10100_s140_ble_debug_usb.zip

    I also post my info here. https://devzone.nordicsemi.com/f/nordic-q-a/64101/nrf52833-usb-dfu-bootloader-does-not-go-to-the-application 

    the pca10100_usb_debug is the one I start from pca10100e_usb_debug, this one, I can flash, and the application and bootloader can be writed into memory, but the application is not run. then the pca10100_s140_ble_debug_usb is the one I start from pca10100_s140_ble_debug, this one the nrfutil do not give any problems, but after flash, the application is not on memory.

  • 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

  • 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?

Related