The QUERY_DEVICE command (0x02) is a request from the host to determine the valid memory ranges that are allowed to be programmed, among other things about the microcontroller. This information can be obtained by the PC GUI application by sending the QUERY_DEVICE command, and then reading back the response packet which will describe the device’s programmable regions (ex: application firmware, EEPROM, and User ID programmable region addresses/size). The command when sent to the device firmware has no data payload.
Table: QUERY_DEVICE command format (when sent from the host to the device).
Packet Byte |
Content |
0 |
QUERY_DEVICE (0x02) |
1-63 |
(padding – init to 0x00) |
After the QUERY_DEVICE command packet has been sent to the device firmware, the device responds with an USB IN (that is, IN to the host) packet, with the format:
Table: QUERY_DEVICE response format (sent from USB device firmware to host PC GUI application)
Packet Byte |
Content |
0 |
QUERY_DEVICE (0x02) |
1 |
bytesPerPacket |
2 |
deviceFamily |
3 |
Type1 |
4-7 |
Address1 |
8-11 |
Size1 |
12 |
Type2 |
13-16 |
Address2 |
17-20 |
Size2 |
… |
… |
48 |
Type6 |
49-52 |
Address6 |
53-56 |
Size6 |
57 |
versionFlag |
58-63 |
(padding) |
The bytesPerPacket indicates how many data bytes are sent in the write or read command data payload section.
The deviceFamily parameter indicates which device family (ex: PIC18, PIC24, PIC32, etc.) that is the current target. Type1, Type2 etc. indicate the type of memory (ex: flash, EEPROM, User ID, config bits) that is targeted by this memory range description.
Address1, Address2 etc. is the 32-bit starting address of the data range (in little endian format). Size1, Size2 etc. is the size of memory range in bytes (in 32-bit unsigned integer, little endian format).
The versionFlag is an indicator that is used to tell the PC GUI program that the version is v1.01 or later, and that it supports the QUERY_EXTENDED_INFO command (v1.00 based bootloader firmware did not implement this particular command).
For each memory range a new range description is added. A total of 6 memory ranges will fit into the 64-byte packet. After the entry of the last valid data field, the Type parameter for the next entry should be 0xFF (End of List).
The padding bytes should be treated as reserved and should be initialized to 0x00.
Table: Parameters for QUERY_DEVICE response deviceFamily field
Value |
Family |
0x01 |
PIC18 |
0x02 |
PIC24F |
0x03 |
PIC32 |
0x04 |
PIC16 |
Table: Parameters for QUERY_DEVICE response type field
Value |
Family |
0x01 |
Program Memory |
0x02 |
Data EEPROM |
0x03 |
Config Words |
0x04 |
User ID |
0xFF |
End of list |
MLA - USB Library Help Version : 2.16
![]() |