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

DFU bootloader Serial

Hi guys,

I am experimeting using the experimental_bootloader_secure_serial example, but I am not having luck with the example code. I tried using the BLE secure bootloader and all worksfine over BLE.I tried the same steps that I used for the BLE bootloader that are working for me, change the public key, private.pem

I had a wrong RX defined on the Board.h solved the said above.

Update:

I am trying to use the nRF52 DK to emulate a "Custom Board" instead of use the Jlink connection (Serial over USB) I am connecting a USB-Serial converter to the p0.6(tx) and p0.8(rx) to send the Serial DFU command but nothing happens. It works only when I have attached the DK module to the PC over Jlink.

I am using only two wires TX/RX so I disabled the HWFC on the bootloader nrf_serial_dfu.c settings and I did the same to the dfu_transport_serial nrfutil folder and python setup.py build to the changes make affect .Disabling flowcontroll

For the bootloader secure serial I noticed two things: 1)It example does not show a DFUtarg over BLE 2)when I tried nrfutil dfu serial -pkg example.zip -p COM1. The Softdevice and Bootloader serial are present on the nRF52 DK module it gets stuck on 0% for ever (the bootloader is running).

image description

An additional question are there a way to merge the DFU BLE + Serial on the same bootloader?

Thanks

  • A additional info I am running the nrfutil from thr souce code calling __main__.py if I made any change to the nrfutil code example disabling/enabling the HWFC does it have any effect calling directly the __main__.py or do I have to compile it before? Yes, you must compile it even though you're running it from source since it uses a static library that must be updated if you modify the source.

  • Hi Bjørn, I am still with no luck.

    if I let enabled the flow control on dfu_transport_serial.py and bootloader I got the following log:

    C:\DesktopHome\Nordic\pc-nrfutil-master>python nordicsemi/__main__.
    py dfu serial -pkg 1Normal_HWFC.zip -p COM15
      [####################################]  100%
    Device programmed.
    

    If I disable the flow control on dfu_transport_serial.py and bootloader I got the following log:

    C:\DesktopHome\Nordic\pc-nrfutil-master>python nordicsemi/__main__.
    py dfu serial -pkg 1Normal.zip -p COM15
      [------------------------------------]    0%
    Traceback (most recent call last):
      File "nordicsemi/__main__.py", line 681, in <module>
        cli()
      File "C:\Python27\lib\site-packages\click\core.py", line 722, in __call__
        return self.main(*args, **kwargs)
      File "C:\Python27\lib\site-packages\click\core.py", line 697, in main
        rv = self.invoke(ctx)
      File "C:\Python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "C:\Python27\lib\site-packages\click\core.py", line 1066, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "C:\Python27\lib\site-packages\click\core.py", line 895, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke
        return callback(*args, **kwargs)
      File "nordicsemi/__main__.py", line 584, in serial
        dfu.dfu_send_images()
      File "C:\DesktopHome\Nordic\pc-nrfutil-master\nordicsemi\dfu\dfu.
    py", line 122, in dfu_send_images
        self._dfu_send_image(self.manifest.application)
      File "C:\DesktopHome\Nordic\pc-nrfutil-master\nordicsemi\dfu\dfu.
    py", line 95, in _dfu_send_image
        self.dfu_transport.send_firmware(data)
      File "C:\DesktopHome\Nordic\pc-nrfutil-master\nordicsemi\dfu\dfu_
    transport_serial.py", line 277, in send_firmware
        response['crc'] = self.__stream_data(data=data, crc=response['crc'], offset=
    i)
      File "C:\DesktopHome\Nordic\pc-nrfutil-master\nordicsemi\dfu\dfu_
    transport_serial.py", line 389, in __stream_data
        response = self.__calculate_checksum()
      File "C:\DesktopHome\Nordic\pc-nrfutil-master\nordicsemi\dfu\dfu_
    transport_serial.py", line 334, in __calculate_checksum
        (offset, crc) = struct.unpack('<II', bytearray(response))
    TypeError: 'NoneType' object is not iterable
    

    at this point I dont know what I am doing wrong. I am compiling after each change dfu_transport_serial.py and verifing it sending printing messages on the command window. I keep the PCA10040 to all the codes, bootloader, app. Does this requiere CTS and RTS pins to works?

    In additional I noticed when I disable the flow control on the dfu_transport_serial.py and tried the serial DFU the LED2 and LED 3 turn on and after the it the device restarts and jump to the main aplication.

  • HI Mustafa, I just saw that there is an error in the UART configuration in my answer. It should be NRF_UART_HWFC_DISABLED and not NRF_UART_HWFC_ENABLED, i.e.

    nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
    
    uart_config.pseltxd            = TX_PIN_NUMBER;
    uart_config.pselrxd            = RX_PIN_NUMBER;
    uart_config.pselcts            = CTS_PIN_NUMBER;
    uart_config.pselrts            = RTS_PIN_NUMBER;
    uart_config.hwfc               = NRF_UART_HWFC_DISABLED;
    uart_config.baudrate           = 2576384; // Corresponds to 9600 baud
    uart_config.p_context          = &m_dfu;
    
  • Thanks Bjørn. It is working now, but it seems only to work when the baudrate is 9600 and the HWFC is false. If I tried baudrate 38k and HWFC false and it does not work. (the same changes are on dfu_transport_serial.py)

    Thanks again :)

  • Since you're not using HWFC(which the bootloader is designed for) then you need to send the data at a very low speed in order to avoid overflowing the receive buffer, i've only tested for 9600 baud.

Related