ESP32 Bootloader - Response size larger than expected

ns1668
Posts: 50
Joined: Tue Mar 16, 2021 2:00 pm

ESP32 Bootloader - Response size larger than expected

Postby ns1668 » Thu Sep 23, 2021 8:25 am

I am currently working on a serial flasher for ESP32, this is based on the official esp-serial-flasher source code.

When getting responses from the ESP32 BL I expect the following (based on https://github.com/espressif/esp-serial ... comm_prv.h)

Code: Select all

typedef struct __attribute__((packed))
{
    uint8_t direction;
    uint8_t command;    // One of command_t
    uint16_t size;
    uint32_t value;
} common_response_t;

typedef struct __attribute__((packed))
{
    uint8_t failed;
    uint8_t error;
} response_status_t;

typedef struct __attribute__((packed))
{
    common_response_t common;
    response_status_t status;
} response_t;
This is a total of 10 bytes for each response. The responses I get from the ESP32 are not 10 bytes, they are all 12 bytes (14 including the 0xC0 delimiters.

For example, the chip detect response is C0 01 0A 04 00 83 1D F0 00 00 00 00 00 C0.

What is going on here?

ns1668
Posts: 50
Joined: Tue Mar 16, 2021 2:00 pm

Re: ESP32 Bootloader - Response size larger than expected

Postby ns1668 » Thu Sep 23, 2021 9:50 am

After considering it for a moment I think possibly there is an issue whereby the bootloader is using unpacked structs for the responses.
This would cause the response status to be padded to the native 32-bit word length (resulting in an extra two bytes being appended).

Any thoughts on this?

Who is online

Users browsing this forum: Baidu [Spider] and 124 guests