# Atmel EDBG-based Tools Protocols
AVR communication protocol

## Framing

This section outlines the general frame format used by all sub-protocols.

The protocol handler ID field identifies which sub-protocol to decode the packet by, and this which command handler to forward the packet to.

In general, `ID == 0x00` is used as a “query” function in order for the host to “discover” the feature set of the tool.

Table 44. Command frame format

Field | Size | Value
--- | --- | ---
SOF | 1 byte | 0x0E
Protocol version | 1 byte | 0x00 in this version (all packets)
Sequence ID | 2 bytes | Incrementing from 0x00 (least significant byte sent first)
Protocol handler ID | 1 byte | Destination sub-protocol handler ID
Payload | N bytes | Data

Table 45. Response frame format

Field | Size | Value
--- | --- | ---
SOF | 1 byte | 0x0E
Sequence ID | 2 bytes | Echo of incoming ID (least significant byte sent first)
Protocol handler ID | 1 byte | Source sub-protocol handler ID
Payload | N bytes | Data

Table 46. Event frame format

Field | Size | Value
--- | --- | ---
SOF | 1 byte | 0x0E
Protocol version | 1 byte | 0x00 in this version (all packets)
Sequence ID | 2 bytes | Incrementing from 0x00 (least significant byte sent first)
Protocol handler ID | 1 byte | Source sub-protocol handler ID
Payload | N bytes | Data

The protocol handler ID field identifies which sub-protocol to decode the packet by, and this which command handler to forward the packet to.

In general, `ID == 0x00` is used as a “query” function in order for the host to “discover” the feature set of the tool.

If there is a condition where the EDBG AVR command handler expects more data for a command than is available, then the next incoming command will be rejected and an error response (`RSP_FAILED` with failure code `FAILURE_USB_PREVIOUS_UNDERRUN`) will be returned . Note that such an underrun situation will result in unknown values for the parameters of the failing command and the host will have to do the necessary cleanup to undo any undesired behaviour. The underrun error reporting is done by transport layer and is independent of the sub-protocol being used.

Prev | Up | Next
| Home |