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

How to add buttonless_dfu and serial_dfu functions at the same time.

Now the code in the application part has added the buttonless_dfu function, which has also been successfully implemented. But I ’m not familiar with serial_dfu, I don’t know how to continue to add serial_dfu function. And how to achieve coexistence of ble_dfu and serial_dfu in bootload code?

Parents
  • Hi June, 

    You can have a look at this case: https://devzone.nordicsemi.com/f/nordic-q-a/35431/dfu-over-ble-and-usb

    I have an example for SDK v15.2 there. To find how to enter DFU bootloader mode from application, please study the ble_app_buttonless_dfu example. Check function enter_bootloader() and then ble_dfu_buttonless_bootloader_start_prepare(). The GPREGRET register is written before the application reset and enter bootloader. 

  • Hi Hung Bui,

    I have added the serial_dfu code with reference to this routine, and now I have a few questions:

    1、Does uart need flow control during serial dfu? I am currently turning off serial port flow control because my hardware does not have two pins for flow control

    2、In normal application operation, in addition to the buttonless method, I can also enter the upgrade mode by pressing the button. After pressing the button, I performed the following operations:

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    VERIFY_SUCCESS(err_code);
    
    err_code = sd_power_gpregret_set(0, BOOTLOADER_DFU_START);
    VERIFY_SUCCESS(err_code);
    
    // Signal that DFU mode is to be enter to the power management module
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    Is this correct?

    3、After entering the upgrade mode, what nrfutil command is used to upgrade the zip package into the chip?

  • Your example program is normal on the 52832DK board, but on the 52840DK board, once the HWFC is turned off, although I have reduced the baud rate to 9600 and executed the MSDDisable command, the upgrade will still fail

    Traceback (most recent call last):
      File "D:\Application\Python38\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==6.0.1', 'console_scripts', 'nrfutil')()
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 782, in main
        rv = self.invoke(ctx)
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\__main__.py", line 1055, in serial
        do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, True,
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\__main__.py", line 970, in do_serial
        dfu.dfu_send_images()
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu.py", line 100, in _dfu_send_image
        self.dfu_transport.send_firmware(data)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu_transport_serial.py", line 301, in send_firmware
        response['crc'] = self.__stream_data(data=data, crc=response['crc'], offset=i)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu_transport_serial.py", line 474, in __stream_data
        response = self.__calculate_checksum()
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu_transport_serial.py", line 412, in __calculate_checksum
        raise NordicSemiException('Did not receive checksum response from DFU target. '
    pc_ble_driver_py.exceptions.NordicSemiException: Did not receive checksum response from DFU target. If MSD is enabled on the target device, try to disable it ref. https://wiki.segger.com/index.php?title=J-Link-OB_SAM3U

  • I upgraded nrfutil to 6.1.0, and the problem still exists. Your SDK 15.2 program is normal for the 52832dk board, but once the hwfc is closed on the 52840dk board, the DFU fails. And the sdk15.3 program that I transplanted fails to DFU in any case. I don't think it's a hardware or nrfutil problem. Because in your sdk15.2-based program, the DFU of 52832dk board is normal under all conditions, and everything is normal when the hwfc of 52840dk board is not closed

  • Hi June, 
    I'm a little busy at the moment with some other tasks. Will try to port to v15.3 on Friday. 

Reply Children
  • Hi Hung,

    Thanks, I will wait your good news quietly.

  • By the way, I need the code to run properly at 52840dk !!!

  • Hi June, 
    I found that it was because of this definition NRF_DFU_PROTOCOL_REDUCED 1 in sdk_config.h in SDK v15.3 causing the issue. 

    Please set it to 0 if it's 1 in your sdk_config.h , after that it should work. 

    I attached here the hex file for bootloader and the Keil project in SDK v15.3 that I used. 

    It's the same private key as I sent earlier. pca10056_ble_uart_debug.zip

  • Hi Hung,

    Unfortunately, the problem still exists.

    Although I have executed MSDDisable, DFU still fails. The following is the error message, same as before:

    Traceback (most recent call last):
      File "D:\Application\Python38\Scripts\nrfutil-script.py", line 11, in <module>
        load_entry_point('nrfutil==6.0.1', 'console_scripts', 'nrfutil')()
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 829, in __call__
        return self.main(*args, **kwargs)
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 782, in main
        rv = self.invoke(ctx)
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 1259, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 1066, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "D:\Application\Python38\lib\site-packages\click-7.1.1-py3.8.egg\click\core.py", line 610, in invoke
        return callback(*args, **kwargs)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\__main__.py", line 1055, in serial
        do_serial(package, port, connect_delay, flow_control, packet_receipt_notification, baud_rate, serial_number, True,
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\__main__.py", line 970, in do_serial
        dfu.dfu_send_images()
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu.py", line 127, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu.py", line 100, in _dfu_send_image
        self.dfu_transport.send_firmware(data)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu_transport_serial.py", line 301, in send_firmware
        response['crc'] = self.__stream_data(data=data, crc=response['crc'], offset=i)
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu_transport_serial.py", line 474, in __stream_data
        response = self.__calculate_checksum()
      File "D:\Application\Python38\lib\site-packages\nrfutil-6.0.1-py3.8.egg\nordicsemi\dfu\dfu_transport_serial.py", line 412, in __calculate_checksum
        raise NordicSemiException('Did not receive checksum response from DFU target. '
    pc_ble_driver_py.exceptions.NordicSemiException: Did not receive checksum response from DFU target. If MSD is enabled on the target device, try to disable it ref. https://wiki.segger.com/index.php?title=J-Link-OB_SAM3U

    But at the same time SDK15.2 is normal (SDK 15.2 and SDK 15.3 are configured with 115200 baud rate and HWFC is turned on). By the way, I used your 15.3 code project to compile without any changes (just replaced the key.c that matches my environment), the problem is still not solved.

  • Please capture the RTT log as well. 

    Which baudrate did you test ? Have you tested with or without HWFC ? Could you test with very small image ? 

Related