3.2.1.1.2 Unwrapping AVR Responses

To RECEIVE an AVR response from the EDBG, an AVR_RSP packet must be sent (i.e.: polling for responses).

Table 3-6. AVR_RSP Command
FieldSizeDescription
AVR_RSP1 byte0x81

The response to this send is:

Table 3-7. AVR_RSP Response
FieldSizeDescription
AVR_RSP1 byte0x81
FragmentInfo1 byteFragment number
Size2 byte, MSB firstNumber of response bytes
ResponseN bytesEnveloped AVR response

FragmentNumber 0x00 indicates that no response data is available, and the rest of the packet is ignored.

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.

Note that the "synchronous" nature of the AVR CMD-RSP functionality must be preserved even when running over this CMSIS-DAP wrapper. This means that every one command results in one and only one response, and that response must be read out before the following command can be issued.

For example, to read 80B AVR response packet when the REPORT_SIZE is 64B:

Table 3-8. AVR_RSP Example
Packet#DirectionData
1PC to Tool0x81
2Tool to PC0x81 0x00
3PC to Tool0x81
4Tool to PC0x81 0x00
5PC to Tool0x81
6Tool to PC0x81 0x12 0x00 0x3C ...First 60B of AVR response packet...
7PC to Tool0x81
8Tool to PC0x81 0x22 0x00 0x14 ...Remaining 20B of AVR response packet...