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

BLE + Serial DFU bootloader SDK 14.0

Hi,

I'm trying to merge Serial and BLE DFU. I have followed this.

I have used BLE DFU example as base code and added Serial DFU dependencies.

I'm able to do BLE DFU but Serial DFU fails.

I have noticed that with BLE_STACK_SUPPORT_REQD flag, Serial DFU fails and also noticed without BLE_STACK_SUPPORT_REQD flag "BLE DFU" fails.

nrf_fstorage_init() is getting triggered with different parameters (nrf_fstorage_sd or nrf_fstorage_nvmc) for BLE or DFU resp. depending on BLE_STACK_SUPPORT_REQD.

When I set BLE_STACK_SUPPORT_REQD and do Serial DFU I get this <error> nrf_dfu_flash: !!! Failed storing 128 B at address: 0x00023080 error.

I tried do Serial DFU no flow control and baud rate set to 9600 still no luck.

Please let me know if I'm missing something.

Regards,

Hrishikesh D.

Parents Reply Children
  • Hi Bjorn,

    Thank you for the response.

    Yes, I'm initializing SoftDevice when I'm performing the serial DFU.

    Due to lack of time I tried one ugly trick, I did set a flag when we go in Bootloader mode from application and choose Serial or BLE transport layer depending on flag which worked well for me.

    Also one thing to mention, I was using default baud rate which is 115200 in sdk.config file which was failing without flow control.

    I had to configure baud rate to 9600 which is not mentioned here and then serial DFU success without flow control.

    Is there any way I can increase the baud rate without flow control? Is it hardware limitation or JLink issue?

    Will it work on custom board for higher baud rate?

    Thanks,

    Hrishikesh.

  • Hi Bjorn,

    In the free time I tried steps again mentioned here.

    I'm able to do DFU from serial (baudrate 9600 and HWFC disable).

    For higher Baudrate (115200) serial DFU is not working.

    When I disable the ble_transport and use nrf_fstorage_nvmc then I'm able to do DFU with Baudrate 115200 and HWFC enable.

    So I'm assuming BLE + Serial DFU will work for 9600 baud rate only? As BLE DFU will require ble_transport layer and nrf_fstorage_sd.

    Am I missing something?

    Thanks,

    Hrishikesh.

  • Hi Hrishikesh, 

    with HWFC enabled you should be able to use a higher baudrate than 9600. There could be a timing issue with using a higher baudrate and fstorage using the SoftDevice flash API instead of the NVMC directly. As far as I know we never tested this as we designed the serial bootloader to not be dependent on the SD. 

    Best regards

    Bjørn

  • Looks like it has timing issues. What I have observed is mention below.

    1) To work with baud rate more than 9600 we need to use NVMC flash API instead of SD Api.

    2)  HWFC enabled is must to enable both BLE + Serial DFU.

    3) SoftDevice must not be enable to work with baud rate more than 9600.

    Below is something I did on my setup.

    1) Set gpregret2 register (as I'm not using for other purposes) to 1 if serial dfu is requested from application.
    Use this register to ensure ble transport layer will not init in Bootloader mode

    2) Set gpregret2 register to 0 in main.c to iensure ble transport layer will init in Bootloader mode.

    3) Use NVMC flash backend for Serial DFU. Inside serial_dfu.c in uart_event_handler function use below snippet.

            case NRF_DRV_UART_EVT_RX_DONE:
                if (count == 0)
                {
                    (void)nrf_dfu_flash_init(false);
                    count = 1;
                }
                on_rx_complete((serial_dfu_t*)p_context, p_event->data.rxtx.p_data, p_event->data.rxtx.bytes);
                break;
    

    4) Check gpregret2 flag in ble_dfu.c and decide whether to enable SoftDevice or not.

    NOTE: for step 4 use NRF_POWER->GPREGRET2; to read GPREGRET2 flag instead of SD_api as we want to access this before enabling SoftDevice to decide if we want to enable SoftDevice.

Related