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

UART bootloader fails at 1000000 baud with HWFC

I tried with the DK and my own USB-serial adapter and both fails at 1M with HWFC with this error:

nrfutil dfu serial -pkg bltest.zip --baud-rate 1000000 --flow-control 1 -p COM38

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.

I see many people saying it fails at 1M.  460800 works on the DK.  Is 1M supposed to work?  I set NRF_DFU_SERIAL_UART_RX_BUFFERS to 250 already.  In a test app I don't see any data corruption at 1M doing a loopback test.

  • I got it to work with these settings:

    In nrf_bootloader.c:

    #define SCHED_QUEUE_SIZE      128

    In sdk_config.h:

    #define NRF_DFU_SERIAL_UART_RX_BUFFERS 200

  • I'm not sure if change in nrf_bootloader.c is required. However, NRF_DFU_SERIAL_UART_RX_BUFFERS must be increased for higher baudrates.

    I run few tests with 1M baudrate and used profiler in app_scheduler (APP_SCHEDULER_WITH_PROFILER option) to figure out what was the maximal utilization. I’ve only increased number of RX buffers to 32 (NRF_DFU_SERIAL_UART_RX_BUFFERS). On my setup utilization was never higher than 21 (between 10 and 21 when running DFU few times).

  • The queue size should correspond to MTU and object size. In DFU object size is usually same to flash page size (4096B). 
    For example if your MTU == 64B the amount of buffers in queue needed is 4096/64 = 64 or more. This will buffer all DFU packets in RAM untill Object execute command received and DFU will have time to write all buffers to flash. Another solution could be playing with PRN and sending GetCRC requests by DFU host to give more time DFU target to sync. 
    If SD used in bootloader the NRF_FSTORAGE_SD_QUEUE_SIZE also should be increased to make DFU work on high baudrates. 
    For my case: 
    MTU = 128 B
    #define SCHED_QUEUE_SIZE  36

    #define NRF_DFU_SERIAL_UART_RX_BUFFERS 36

    #define  NRF_FSTORAGE_SD_QUEUE_SIZE 36


    The future plan is to find way to activate RTS from upper layer when few free buffers left and deactivate RTS when once all buffers processed. This will should work good on devices with limited RAM.  

Related