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