DFU over UART/Bootloader: Tracking SMP Protocol Bytes

Hi Nordic S .team,

Could you please help me analyze the following inconsistencies, and also provide the requested documentation?

I’m trying to interpret the AuTerm messages sent via UART in order to create my own DFU controller. But at the moment I can’t interpret the frames.

I’m following this description:

-. https://docs.zephyrproject.org/latest/services/device_mgmt/smp_protocol.html 

-. https://docs.zephyrproject.org/latest/services/device_mgmt/smp_transport.html?utm_source=chatgpt.com

                                        

Init packet (logic analyzer): 0x06, 0x09, 0x41, 0x42, 0x55, 0x44, 0x41, 0x41, 0x41, 0x4C, 0x41, 0x41, 0x47, 0x6E, 0x41, 0x62, 0x39, 0x69, 0x63, 0x6D, 0x4D, 0x41, 0x59, 0x32, 0x39, 0x6D, 0x5A, 0x67, 0x7A, 0x2F, 0x41, 0x4F, 0x34, 0x3D, 0x0A

Could you please confirm whether I’m defining all the bytes correctly? They don’t seem to have the correct values.

Start maker: 0x06 0x09

Res/Ver/OP: 0x41

Flags: 0x42 

Data lenght: 0x55 0x44

Group ID: 0x41 0x41

Sequence Num: 0x41

Command ID: 0x4C

Body: From 0x41 to 0x4F (Base64)

CRC16: 0x34 0x3D

End: 0x0A

 

Could you also confirm whether I’m calculating the CRC‑16 correctly?
I’m obtaining 0x36 0x6C instead of 0x34 0x3D.

polynomial = 0x1021  # ejemplo de polinomio tipo CRC‑CCITT
initial = 0x0000     # ejemplo de valor inicial
pad = True           # si quieres padding o no
Note: I found the next function in the Auterm driver (Version 0.36a test release).
uint16_t crc16(const QByteArray *src, size_t i, size_t len, uint16_t polynomial,
               uint16_t initial_value, bool pad)
{
    uint16_t crc = initial_value;
    size_t padding = pad ? sizeof(crc) : 0;
    size_t b;

    /* src length + padding (if required) */
    while (i < (len + padding))
    {
        for (b = 0; b < 8; b++) {
            uint16_t divide = crc & 0x8000UL;

            crc = (crc << 1U);

            /* choose input bytes or implicit trailing zeros */
            if (i < len) {
                crc |= !!(src->at(i) & (0x80U >> b));
            }

            if (divide != 0U) {
                crc = crc ^ polynomial;
            }
        }
        ++i;
    }

    return crc;
}

Note: My DFU over UART is working as expected. I performed the test using AuTerm.

 

Do you have any documentation with more details about SMP frames? I’m trying to track all the SMP frames to understand the protocol.

Best regards, 

Tania

Parents Reply Children
No Data
Related