Wrapping AVR Commands

So to SEND an AVR command to the EDBG, it is wrapped as:

Table 1. AVR_CMD Command
Field Size Description
AVR_CMD 1 byte 0x80
FragmentInfo 1 byte Fragment number
Size 2 bytes, MSB first Number of bytes in the wrapped AVR packet
CommandPacket N bytes Enveloped AVR packet

Large packets must be chopped up according to the HID interface’s REPORT_SIZE. The fragment number envelope field is two 4-bit nibbles indicating a "packet m of n packets" relationship:

(packet_number << 4) | total_number_of_packets.

Each SEND fragment responds with:

Table 2. AVR_CMD Response
Field Size Description
AVR_CMD 1 byte 0x80
FragmentCode 1 byte

0x00: More fragments required (m < n)

0x01: Full packet received, will be processed (m == n)

This is not to be confused with the AVR_RSP, which is the response to the command itself, which is detailed next.

For example, to wrap a 100B AVR command packet when the REPORT_SIZE is 64B:
Table 3. AVR_CMD Example
Packet# Direction Data
1 PC to Tool 0x80 0x12 0x00 0x3C ...First 60B of AVR command packet...
2 Tool to PC 0x80 0x00
3 PC to Tool 0x80 0x22 0x00 0x28 ...Remaining 40B of AVR command packet...
4 Tool to PC 0x80 0x01