Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

OTA over serial failure| sdk 15.2

Hello Everyone,

I am using nrf52832 and sdk 15.2 for ota over serial. I have made bootloader for OTA over UART and tested same with nrfutil using my dfu package file. firmware is upgraded successfully and  working fine.

Now I need to upgrade firmware using host MCU. I tried sending dfu package file( .zip ) to nrf52832 over UART using slip librairy to upgrade firmware but it is not working.

Is there any compulsion to send Ping packet, PNR, MTU Packet, init packet, application and bootloader separately over UART?

Can we send directly dfu package created through nrfutil to nrf52832 from other MCU over UART?

Kindly suggest me right approach.

Parents Reply
  • It could be that the issue is due to flow control being disabled. It is a shot in the dark, but if the DFU target doesn't have time to write everything to flash, it may not be ready to receive new packets, and hence doesn't know what to reply to. Perhaps you can try to add some delay between all uart packets, to see whether or not this changes the behavior. 

    I don't think I have shown you this yet, but we have an unofficial project for an nRF working as a serial DFU master. You can find it in this blog, Section 5 "DFU Master code". I have not tested it myself, but perhaps you can look at that implementation.

    Best regards,

    Edvin

Children
  • I tried with the delay's but still same issue.

    I referred "DFU Master code" and implemented same.

    please see follwing code to send app.

    static void uart_send_application_image(uint8_t *data, uint32_t length)
    {
    
    	uint8_t CRC[] = {3};
    	uint32_t CRC_len = 1;
    	uint8_t execute[] = {4};
    	uint32_t exe_len = 1;
    	uint8_t create_obj[10];
    	uint32_t create_obj_len= 6;
    	uint32_t enc_data_len = 0;
    	size_t read_len =0;
    	uint8_t  RespData[100];
    	uint8_t enc_data[100];
    
    	//Create Object
    	create_obj[0]=0x01;
    	create_obj[1]=0x02;//Command Object
    	create_obj[2]=length;
    	create_obj[3]=length>>8;
    	create_obj[4]=length>>16;
    	create_obj[5]=length>>24;
    
    	memset(enc_data,0,sizeof(enc_data));
    	//CREATE COMMAND OBJECT
    	encode_slip(enc_data,&enc_data_len,create_obj,create_obj_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);
    
    	vTaskDelay(10);         //100ms
    	ESP_ERROR_CHECK(uart_get_buffered_data_len(UART_NUM_1,&read_len));
    	int readBytes = uart_read_bytes(UART_NUM_1, RespData,(uint32_t)read_len, 0);
    
        uint32_t encoded_slip_packet_length;
    
        while(length>0)
        {
            encoded_slip_packet[0]=0x08;//Write object opcode
    
            if (length>=MAX_ACTUAL_PAYLOAD)
            {
            	encode_slip( &encoded_slip_packet[1], &encoded_slip_packet_length, data, MAX_ACTUAL_PAYLOAD);
                length= length-MAX_ACTUAL_PAYLOAD;
                data = data+MAX_ACTUAL_PAYLOAD;
            }else
            {
            	encode_slip( &encoded_slip_packet[1], &encoded_slip_packet_length, data, length);
                length=0;
            }
    
            // send
    
            uart_flush(UART_NUM_1);
    		uart_write_bytes(UART_NUM_1,(char*) encoded_slip_packet, encoded_slip_packet_length+1);
    		uart_wait_tx_done(UART_NUM_1, 5);
        }
    
    	vTaskDelay(1);              //10ms
    	//CRC
    	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);
    
    	vTaskDelay(10);             //100ms
    	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);
    
    	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);
    
    	vTaskDelay(20);             //200ms
    	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);
    }
    

    Can you please explain in brief how to see logs on RTT viewer. not getting logs yet.

  • In order to see the logs, you must download Segger RTT Viewer (link in an earlier reply). Then open up your bootloader project, open sdk_config.h, and change the define:

    #define NRF_LOG_ENABLED 0
    to
    #define NRF_LOG_ENABLED 1

    You can also change

    #define NRF_LOG_DEFAULT_LOG_LEVEL 3
    to
    #define NRF_LOG_DEFAULT_LOG_LEVEL 4

    to increase the amount of logging.

    Now, if you don't change the default flash settings, the compiler will say something like there is not enough flash to fit the project in the chip, so change the flash start and size to ensure there is enough space for the logging module. Change it to something like the _debug bootloader project. 

    Then open RTT Viewer, and select the debugger that is connected to the nRF. You should see the log there.

    If you still can't see the log, please let me know where you are stuck. Are you able to compile with NRF_LOG_ENABLED set to 1? Are you able to flash the bootloader? Are you able to open the Segger RTT VIewer?

  • Hi @,

    As you said, by default this settings are enabled.

    I have compiled the code in SES and flashed in DK board to check whether it is working or not.

    I have opened RTT viewer and connected to board.

    Now I want to start dfu using nrfutil. right? and I'll get backend logs on rtt viewer.

    Please tell me how?

  • Hello ,

    Thank you very much for your support. OTA over serial is sucessfull. Relaxed

    The problem was in the init packet. I had used softdevice.dat file for init packet. I converted this file into hex by online hex converter. now I used application.dat file for the init packet and sent over serial and after that sent app file and OTA worked.

    Can you please tell me how to make init packet. please share init packet structure. I checked nrfutil code but its quit confusing for me. I have sent following packet.

    uint8_t init_packet1[] = {8, 10, 67, 8, 1, 18, 63, 8, 3, 16, 2, 26, 2, 175, 1, 32, 0, 40, 0, 48, 0, 56, 196, 93, 66, 36, 8, 3, 18, 32, 14, 112, 16, 50, 29, 176, 115, 77, 235, 99, 214, 61, 143, 198, 237, 176, 123, 34, 183, 203, 209, 236, 252, 234, 62, 106, 216, 241, 146, 51, 178, 154, 72, 0, 82};
    uint32_t init_packet1_len = 65;
    uint8_t init_packet2[] = {8, 4, 8, 1, 18, 0};
    uint32_t init_packet2_len = 6;

    Thanks a lot again!!

    Regards,

    Somesh

  • Hello ,

    I have a problem while upgrading firmware. I am upgrading firmware by sending init packet and then app file serially. In some condition init packet is sent successfull and executed using ( 0x04 ) command but while sending app file due to some reason not executed successfully and OTa over serial fails. 

    after that I tried again to do the same but init packet is not getting executed successfully becuase it was done before. so my question is, Is there any way to reset nrf bootloader so that after if ota fails then second time bootloader should start again( erase all files) from init packet.

    Please help me to handle this.

    Awaiting your quick response.

    With warm regards,

    Somesh Burkule

Related