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

  • hello,

    i to started with serial from esp to nrf

    in that i can able to send upto create object  and getting responses but when i tried send a init packet but not getting response ,juts i converted my .dat file to hex  in online convertor and hardcoded the value in code.

    how to send the init packet??

  • <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 (0x20000024)
    <debug> app: timer_activate (0x20000024)
    <info> app: Entering DFU mode.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_serial_uart: serial_dfu_transport_init()
    <debug> nrf_dfu_serial_uart: serial_dfu_transport_init() completed
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> app: Enter main loop
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_serial: Received ping 1
    <info> nrf_dfu_serial_uart: Allocated buffer 2000378C
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_PING
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_serial: Sending Response: [0x9, 0x1]
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_serial: Set receipt notif target: 0
    <info> nrf_dfu_serial_uart: Allocated buffer 2000378C
    
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_RECEIPT_NOTIF_SET
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_serial: Sending Response: [0x2, 0x1]
    <debug> app: Shutting down transports (found: 1)
    <debug> nrf_dfu_serial: Received serial mtu
    <info> nrf_dfu_serial_uart: Allocated buffer 2000378C
    
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_MTU_GET
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_serial: Sending Response: [0x7, 0x1]
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 2000378C
    
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_SELECT (command)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_serial: Sending Response: [0x6, 0x1]
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 2000378C
    
    
    <debug> nrf_dfu_req_handler: Handle NRF_DFU_OP_OBJECT_CREATE (command)
    <debug> app: timer_stop (0x20000024)
    <debug> app: timer_activate (0x20000024)
    <debug> nrf_dfu_req_handler: Request handling complete. Result: 0x1
    <debug> nrf_dfu_serial: Sending Response: [0x1, 0x1]
    <debug> app: Shutting down transports (found: 1)
    <info> nrf_dfu_serial_uart: Allocated buffer 20003810
    

    waiting for your reply,

    test1_app.zip

    here is my bin and dat file ,

    same file is working by using application through BLE 

    but when used in uart not getting any response .i have debug the code .

    uint8_t create_obj[] = { 0x01, 0x01, 0x91, 0x00, 0x00, 0x00 };
    
    	uint32_t create_obj_len = 6;
    	uint8_t init_packet2[] = { 8, 4, 8, 1, 18, 0 };
    	uint32_t init_packet2_len = 6;
    
    
    uint8_t init_packet1[] = { 0x12, 0x8A, 0x01, 0x0A, 0x44, 0x08, 0x01, 0x12, 0x40, 0x08, 0x01, 0x10, 0x34, 0x1A, 0x02, 0xAE,
    			0x01, 0x20, 0x00, 0x28, 0x00, 0x30, 0x00, 0x38, 0xF4, 0xE0, 0x02, 0x42, 0x24, 0x08, 0x03, 0x12,
    			0x20, 0x9D, 0x45, 0x56, 0x3B, 0xF7, 0x9D, 0x44, 0x66, 0x5E, 0x69, 0x45, 0xB7, 0x9F, 0xAB, 0x2C,
    			0x32, 0xB0, 0x9F, 0x10, 0x31, 0x69, 0x5C, 0x64, 0x6D, 0xA1, 0x8F, 0xD9, 0xE2, 0x53, 0x12, 0x4A,
    			0x81, 0x48, 0x00, 0x52, 0x04, 0x08, 0x01, 0x12, 0x00, 0x10, 0x00, 0x1A, 0x40, 0x51, 0x1F, 0xE2,
    			0xD4, 0x31, 0xD3, 0x3C, 0x12, 0xCE, 0xF7, 0x98, 0x85, 0x59, 0xBB, 0x40, 0x92, 0x6B, 0x61, 0x70,
    			0x29, 0x8A, 0x13, 0x4B, 0xD5, 0x45, 0xA1, 0xEA, 0x05, 0xBA, 0x59, 0xB7, 0x21, 0x4E, 0xAE, 0x78,
    			0x43, 0x97, 0xE3, 0xD2, 0xE8, 0x82, 0x0F, 0x40, 0x39, 0xBC, 0x51, 0x2A, 0xA6, 0x18, 0x98, 0x6E,
    			0xD8, 0x40, 0xF1, 0x7E, 0x5A, 0x0B, 0xFF, 0x4E, 0x70, 0x88, 0x2E, 0xAA, 0xC2 };
    			uint32_t init_packet1_len = 141;
    			
    			memset(enc_data, 0, sizeof(enc_data));
    	//INIT PACKET 1
    encode_slip(enc_data,&enc_data_len,init_packet1,init_packet1_len);
    uart_flush(UART_NUM_1);
    uart_write_bytes(UART_NUM_1,(char*) enc_data, enc_data_len);
    uart_wait_tx_done(UART_NUM_1, 5);
    ESP_LOG_BUFFER_HEX_LEVEL( "INIT PACKET 1 -->", enc_data, enc_data_len, ESP_LOG_INFO );
    
    vTaskDelay(10);
    	memset(enc_data, 0, sizeof(enc_data));
    	//INIT PACKET 2
    	encode_slip(enc_data, &enc_data_len, init_packet2, init_packet2_len);
    	uart_flush(UART_NUM_1);
    	uart_write_bytes(UART_NUM_1, (char*) enc_data, enc_data_len);
    	uart_wait_tx_done(UART_NUM_1, 5);
    	ESP_LOG_BUFFER_HEX_LEVEL("INIT PACKET 2 -->", enc_data, enc_data_len,
    			ESP_LOG_INFO);
    
    	memset(enc_data, 0, sizeof(enc_data));
    	//REQUEST CHECKSUM
    	encode_slip(enc_data, &enc_data_len, CRC, CRC_len);
    	uart_flush(UART_NUM_1);
    	uart_write_bytes(UART_NUM_1, (char*) enc_data, enc_data_len);
    	uart_wait_tx_done(UART_NUM_1, 5);
    	ESP_LOG_BUFFER_HEX_LEVEL("CHECKSUM -->", enc_data, enc_data_len,
    			ESP_LOG_INFO);
    
    	vTaskDelay(20);
    	ESP_ERROR_CHECK(uart_get_buffered_data_len(UART_NUM_1, &read_len));
    	readBytes = uart_read_bytes(UART_NUM_1, RespData, (uint32_t) read_len, 0);
    	ESP_LOG_BUFFER_HEX_LEVEL("CHECKSUM Response <--", RespData, readBytes,
    			ESP_LOG_INFO);
    
    	memset(enc_data, 0, sizeof(enc_data));
    	//EXECUTE
    	encode_slip(enc_data, &enc_data_len, execute, exe_len);
    	uart_flush(UART_NUM_1);
    	uart_write_bytes(UART_NUM_1, (char*) enc_data, enc_data_len);
    	uart_wait_tx_done(UART_NUM_1, 5);
    	ESP_LOG_BUFFER_HEX_LEVEL("EXECUTE -->", enc_data, enc_data_len,
    			ESP_LOG_INFO);
    
    	vTaskDelay(10);
    	ESP_ERROR_CHECK(uart_get_buffered_data_len(UART_NUM_1, &read_len));
    	readBytes = uart_read_bytes(UART_NUM_1, RespData, (uint32_t) read_len, 0);
    	ESP_LOG_BUFFER_HEX_LEVEL("EXECUTE Response <--", RespData, readBytes,
    			ESP_LOG_INFO);
    	printf("RespData:%s", (char*) RespData);
    

    here is my code..

    whats the mistake here ?? could you explain ??

    regards,

    sowmiya

  • Hi Sowmiya, 


    Have you tried to compare with what the phone or the DFU tool on PC send when doing the same DFU ? 
    Please use the sniffer to capture a proper DFU from the phone or DFU tool on PC so that you can pin point what make it didn't work. 

    In addition you need to get the bootloader to run in debug mode and you would be able to debug when there is anything goes wrong on the bootloader side. 

Related