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

Extend Serial DFU

Hi,

as i mention in https://devzone.nordicsemi.com/f/nordic-q-a/44924/dfu-serial-failed i have f ramming error now and then when i do DFU over serial.

My idea was to write some code in nrf_dfu_serial_uart.c to make a better validation of data that was received, request a replay if the data was corrupted or send CRC back to the master and when the data is OK send it to the application. So in the uart_event_handler i would collect data and when the data is OK i would pass it to on_rx_complete.

That works fine. The issue i am having is:

  • on_rx_complete expects nrf_dfu_serial_t *p_transport which i don't have any more if i collect and validate the data in another part of the code. A workaround would be to save the last context in a global variable and send it to the function when the data is ready. Is this OK?
  • if the data is corrupted i would want to report this to the master but i could not send the message from uart_event_handler, i got error 17 from nrf_drv_uart_tx
  • I tried to implement UART driver with FIFO but then i have no UART context to send to on_rx_complete and nrf_dfu_serial_on_packet_received
  • if i would want to report the error from the main context i don't know where the application is at the point of the UART interrupt to send the message
  • if i use nrf_drv_uart_tx with buffer bigger then 1 and don't use nrf_delay_ms in between i get wrong bytes on the other end.

Do you have any suggestions?

I'm using nrf52840 with sdk15.2 and uart without HWFC.

Thanks

.

Parents Reply Children
  • So i guess it hangs here:

    Program received signal SIGTRAP, Trace/breakpoint trap.
    0x000ea3f6 in ?? ()
    (gdb) bt
    #0  0x000ea3f6 in ?? ()
    #1  <signal handler called>
    #2  0x0003ec6a in svci_nrf_dfu_set_adv_name_svci_async_init (p_async=0x2000ba34 <nrf_dfu_set_adv_name_svci_async_def>) at ../../../../submodules/firmware_nrf52_sdk_15_2/src/nRF5_SDK_15.2.0_9412b96/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c:61
    #3  0x0003ec7e in nrf_dfu_set_adv_name_svci_async_init (p_async=0x2000ba34 <nrf_dfu_set_adv_name_svci_async_def>) at ../../../../submodules/firmware_nrf52_sdk_15_2/src/nRF5_SDK_15.2.0_9412b96/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c:61
    #4  0x0003ec92 in nrf_dfu_set_adv_name_init () at ../../../../submodules/firmware_nrf52_sdk_15_2/src/nRF5_SDK_15.2.0_9412b96/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c:61
    #5  0x0003ee22 in ble_dfu_buttonless_async_svci_init () at ../../../../submodules/firmware_nrf52_sdk_15_2/src/nRF5_SDK_15.2.0_9412b96/components/ble/ble_services/ble_dfu/ble_dfu_unbonded.c:151
    #6  0x0003c016 in nordic_ble_dfu_buttonless_async_svci_init () at ../../../../submodules/firmware_nrf52_sdk_15_2_extended/src/nordic_ble_dfu.c:25
    #7  0x000310cc in BleCommon::BleCommon (this=0x20011628) at ../../../../submodules/firmware_nrf52_lib_ble/src/ble_common/ble_common.cpp:28
    #8  0x0003108c in BleCommon::getInstance () at ../../../../submodules/firmware_nrf52_lib_ble/src/ble_common/ble_common.cpp:16
    #9  0x0002d478 in main () at ../../../main.cpp:52
    (gdb) 

    IIt looks like NRF_SVCI_ASYNC_FUNC_DEFINE(NRF_DFU_SVCI_SET_ADV_NAME, nrf_dfu_set_adv_name, nrf_dfu_adv_name_t) never returned.

  • nrf_dfu_set_adv_name_init() should only be called if the bootloader supports DFU over BLE. For serial DFU you don't have to set up the SVC interface with the Bootloader.  

Related