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

NRF52840 OTA over BLE

hai ,

   i tried nrf52840 ota over BLE from third party (ESP32).

As per the DFU protocol implemented logics and upto init packet (.dat file) getting expected response from nrf52840 to esp32.

after that for sending a bin file spllited  into 12 objects ,how to send each packet with calculation of crc matching .

i am using secure bootloader ble debug example .is there any example code to implement ota over ble.??

i am strucking in the place of sending a bin file .could you explain how to implement ?

or otherwise is this easy to start uart from esp32 to nrf52840 for ota .

from uart is there any example code to implement ota  from esp32 to nrf52840??

regards,

sowmiya

  • Hi Sowmiya, 

    I would suggest to have a look at my example here first. I provided an example of DFU master with UART and SPI. From that you would have an overview on what the DFU protocol on UART would look like and how you can send the binary , create object etc. 
    After that you would need to develop your own code to do BLE DFU based on this example and the BLE DFU protocol documentation .

  • hai ,

      i tried OTA over ble from esp32 to nrf52840

    here i have attached the log got from nrf52.

    STEP 1 :  extract zip file in cloud . as per the DFU protocol send a initial commamd and got proper response 

    STEP 2 : send a .dat file which is downloaded and stored in a file system of esp32 to nrf52 and calculation of crc was correct and signature verified successfully.

    STEP 3: downloaded a bin file in esp32 by http  and stored in file system and spllited the .bin file as 12 objects 

    each object as 4096 bytes ,  send as 144 bytes in a loop when completion of first object (4096)

    0x03 send for crc but i didnt get any data from nrf side.

    <info> app: Inside main
    <debug> app: In nrf_bootloader_init
    <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> nrf_dfu_settings: Settings OK
    <debug> app: Enter nrf_bootloader_fw_activate
    <info> app: No firmware to activate.
    <debug> app: Enter nrf_dfu_app_is_valid
    <debug> app: No valid app to boot.
    <debug> app: DFU mode because app is not valid.
    <info> nrf_bootloader_wdt: WDT is not enabled
    <debug> app: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x200057D4)
    <debug> app: timer_activate (0x200057D4)
    <info> app: Entering DFU mode.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_ble: Initializing BLE DFU transport
    <debug> nrf_dfu_ble: Setting up vector table: 0x000F1000
    <debug> nrf_dfu_ble: Enabling SoftDevice.
    <debug> nrf_dfu_ble: Configuring BLE stack.
    <debug> nrf_dfu_ble: Enabling the BLE stack.
    <debug> nrf_dfu_ble: No advertising name found
    <debug> nrf_dfu_ble: Using default advertising name
    <debug> nrf_dfu_ble: Advertising...
    <debug> nrf_dfu_ble: BLE DFU transport initialized.
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
    <debug> nrf_dfu_validation: PB: Init packet data len: 64
    <debug> app: Enter main loop
    <debug> nrf_dfu_ble: Connected
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST.
    <debug> nrf_dfu_ble: Received BLE_GAP_EVT_DATA_LENGTH_UPDATE (251, max_rx_time 2120).
    <debug> nrf_dfu_ble: Received BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST (request: 500, reply: 247).
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    <debug> app: timer_stop (0x200057D4)
    <debug> app: timer_activate (0x200057D4)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_ble: Buffer 0x2000910C acquired, len 141 (244)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_WRITE (command)
    <debug> nrf_dfu_ble: Freeing buffer 0x2000910C
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_CRC_GET (command)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_EXECUTE (command)
    <debug> nrf_dfu_validation: PB: Init packet data len: 64
    <info> nrf_dfu_validation: Signature required. Checking signature.
    <info> nrf_dfu_validation: Calculating init packet hash (init packet len: 64)
    <info> nrf_dfu_validation: Verify signature
    <info> nrf_dfu_validation: Image verified
    <debug> app: Enter nrf_dfu_cache_prepare()
    <debug> app: required_size: 0xBA50.
    <debug> app: single_bank: false.
    <debug> app: keep_app: false.
    <debug> app: keep_softdevice: true.
    <debug> app: SD_PRESENT: true.
    <debug> app: Bank contents:
    <debug> app: Bank 0 code: 0x00: Size: 0x0
    <debug> app: Bank 1 code: 0x00: Size: 0xBA50
    <debug> app: pass: 0.
    <debug> app: cache_address: 0x26000.
    <debug> app: cache_too_small: false.
    <debug> app: keep_firmware: false.
    <debug> app: delete_more: false.
    <debug> nrf_dfu_validation: Write address set to 0x00026000
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
    <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
    <debug> nrf_dfu_req_handler: Writing valid init command to flash.
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (data)
    <debug> nrf_dfu_req_handler: crc = 0x0, offset = 0x0, max_size = 0x1000
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (data)
    <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x00026000, len=1 pages), queue usage: 0
    <debug> nrf_dfu_req_handler: Creating object with size: 4096. Offset: 0x00000000, CRC: 0x00000000
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_flash: Flash erase success: addr=0x00026000, pending 0
    
    init packet(.dat file) getting properly not issues in that.

    why i am getting any data of .bin firmware file?

    how to send a bin file  which i extracted from cloud ??

  • I don't see the bootloader responding to CRC calculate request. Please try to debug the bootloader and have a look inside nrf_dfu_command_req() function. 

    Have you looked at my example ? 

    If you don't plan to try the UART DFU, another advice for you is to do DFU of the same file using our tool for example the app on the phone or NRF Connect app on PC. Then record a sniffer trace of that process. Doing that you can replicate the same procedure on the ESP and can find why it didn't work for you. 

  • yes , i go with your example but how to start ? and where to start in esp side with uart ?

    now i am trying ESP32 to nrf over BLE.  as you said i did the same , traced the log from nrf connect app and implemented logics for esp to nrf ,but i dont know whats missing in that, until the init packet i am getting as per the log taken from nrf connect app.

    could you explain on sending the firmware file procedure??

    regards,

    sowmiya

  • My example code is for updating a nRF52 from a nRF52 not from ESP. From that example you can have an overview of the DFU process. 

    I would suggest you to record sniffer trace, not just the log. 

    Please step into the bootloader and debug inside that , check why it doesn't receive CRC calculate request. You may need to change the optimization level to be able to step into the bootloader's code.  

Related