R&Y: Added DAY RTA Tapp Card and Additional BKK BEM Stored Value Card AIDs to `aid_de...
[RRG-proxmark3.git] / tools / deprecated-hid-flasher / flasher / usb_cmd.h
blob90a76a1be4244cff3e4b2fa8f29fb5e199a84763
1 //-----------------------------------------------------------------------------
2 // Jonathan Westhues, Mar 2006
3 // Edits by Gerhard de Koning Gans, Sep 2007
4 //
5 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
6 // at your option, any later version. See the LICENSE.txt file for the text of
7 // the license.
8 //-----------------------------------------------------------------------------
9 // Definitions for all the types of commands that may be sent over USB; our
10 // own protocol.
11 //-----------------------------------------------------------------------------
13 #ifndef __USB_CMD_H
14 #define __USB_CMD_H
16 #include "proxmark3.h"
18 typedef struct {
19 uint32_t cmd;
20 uint32_t arg[3];
21 union {
22 uint8_t asBytes[48];
23 uint32_t asDwords[12];
24 } d;
25 } PACKED PacketCommandOLD;
27 typedef struct {
28 uint32_t cmd;
29 uint32_t arg[3];
30 union {
31 uint8_t asBytes[48];
32 uint32_t asDwords[12];
33 } d;
34 } PACKED PacketResponseOLD;
36 // For the bootloader
37 #define CMD_DEVICE_INFO 0x0000
38 #define CMD_SETUP_WRITE 0x0001
39 #define CMD_FINISH_WRITE 0x0003
40 #define CMD_HARDWARE_RESET 0x0004
41 #define CMD_START_FLASH 0x0005
42 #define CMD_NACK 0x00fe
43 #define CMD_ACK 0x00ff
45 // For general mucking around
46 #define CMD_DEBUG_PRINT_STRING 0x0100
47 #define CMD_DEBUG_PRINT_INTEGERS 0x0101
48 #define CMD_DEBUG_PRINT_BYTES 0x0102
49 #define CMD_LCD_RESET 0x0103
50 #define CMD_LCD 0x0104
51 #define CMD_BUFF_CLEAR 0x0105
52 #define CMD_READ_MEM 0x0106
53 #define CMD_VERSION 0x0107
54 #define CMD_STATUS 0x0108
55 #define CMD_PING 0x0109
57 #define CMD_DOWNLOAD_EML_BIGBUF 0x0110
58 #define CMD_DOWNLOADED_EML_BIGBUF 0x0111
60 // RDV40, Flash memory operations
61 #define CMD_FLASHMEM_READ 0x0120
62 #define CMD_FLASHMEM_WRITE 0x0121
63 #define CMD_FLASHMEM_WIPE 0x0122
64 #define CMD_FLASHMEM_DOWNLOAD 0x0123
65 #define CMD_FLASHMEM_DOWNLOADED 0x0124
66 #define CMD_FLASHMEM_INFO 0x0125
68 // For low-frequency tags
69 #define CMD_LF_TI_READ 0x0202
70 #define CMD_LF_TI_WRITE 0x0203
71 #define CMD_LF_ACQ_RAW_ADC 0x0205
72 #define CMD_LF_MOD_THEN_ACQ_RAW_ADC 0x0206
73 #define CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K 0x0207
74 #define CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K 0x0208
75 #define CMD_LF_UPLOAD_SIM_SAMPLES 0x0209
76 #define CMD_LF_SIMULATE 0x020A
77 #define CMD_LF_HID_DEMOD 0x020B
78 #define CMD_LF_HID_SIMULATE 0x020C
79 #define CMD_LF_SET_DIVISOR 0x020D
80 #define CMD_LF_SIMULATE_BIDIR 0x020E
81 #define CMD_SET_ADC_MUX 0x020F
82 #define CMD_LF_HID_CLONE 0x0210
83 #define CMD_LF_EM410X_WRITE 0x0211
84 #define CMD_LF_INDALA_CLONE 0x0212
85 // for 224 bits UID
86 #define CMD_LF_INDALA224_CLONE 0x0213
87 #define CMD_LF_T55XX_READBL 0x0214
88 #define CMD_LF_T55XX_WRITEBL 0x0215
89 #define CMD_LF_T55XX_RESET_READ 0x0216
90 #define CMD_LF_T55XX_WAKEUP 0x0224
92 #define CMD_LF_PCF7931_READ 0x0217
93 #define CMD_LF_PCF7931_WRITE 0x0223
94 #define CMD_LF_EM4X_READWORD 0x0218
95 #define CMD_LF_EM4X_WRITEWORD 0x0219
96 #define CMD_LF_IO_DEMOD 0x021A
97 #define CMD_LF_IO_CLONE 0x021B
98 #define CMD_LF_EM410X_DEMOD 0x021c
99 // Sampling configuration for LF reader/sniffer
100 #define CMD_LF_SAMPLING_SET_CONFIG 0x021d
101 #define CMD_LF_FSK_SIMULATE 0x021E
102 #define CMD_LF_ASK_SIMULATE 0x021F
103 #define CMD_LF_PSK_SIMULATE 0x0220
104 #define CMD_LF_AWID_DEMOD 0x0221
105 #define CMD_LF_VIKING_CLONE 0x0222
106 #define CMD_LF_T55XX_WAKEUP 0x0224
107 #define CMD_LF_COTAG_READ 0x0225
108 #define CMD_LF_T55XX_SET_CONFIG 0x0226
110 /* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */
112 // For the 13.56 MHz tags
113 #define CMD_HF_ISO15693_ACQ_RAW_ADC 0x0300
114 #define CMD_HF_SRI_READ 0x0303
115 #define CMD_HF_ISO14443B_COMMAND 0x0305
116 #define CMD_HF_ISO15693_READER 0x0310
117 #define CMD_HF_ISO15693_SIMULATE 0x0311
118 #define CMD_HF_ISO15693_RAWADC 0x0312
119 #define CMD_HF_ISO15693_COMMAND 0x0313
120 #define CMD_HF_ISO15693_FINDAFI 0x0315
121 #define CMD_LF_SNIFF_RAW_ADC 0x0317
123 // For Hitag2 transponders
124 #define CMD_LF_HITAG_SNIFF 0x0370
125 #define CMD_LF_HITAG_SIMULATE 0x0371
126 #define CMD_LF_HITAG_READER 0x0372
128 // For HitagS
129 #define CMD_LF_HITAGS_SIMULATE 0x0368
130 #define CMD_LF_HITAGS_TEST_TRACES 0x0367
131 #define CMD_LF_HITAGS_READ 0x0373
132 #define CMD_LF_HITAGS_WRITE 0x0375
134 #define CMD_HF_ISO14443A_ANTIFUZZ 0x0380
135 #define CMD_HF_ISO14443B_SIMULATE 0x0381
136 #define CMD_HF_ISO14443B_SNIFF 0x0382
137 #define CMD_HF_ISO14443A_SNIFF 0x0383
138 #define CMD_HF_ISO14443A_SIMULATE 0x0384
139 #define CMD_HF_ISO14443A_READER 0x0385
141 #define CMD_HF_LEGIC_SIMULATE 0x0387
142 #define CMD_HF_LEGIC_READER 0x0388
143 #define CMD_HF_LEGIC_WRITER 0x0389
145 #define CMD_HF_EPA_COLLECT_NONCE 0x038A
146 #define CMD_HF_EPA_REPLAY 0x038B
148 #define CMD_HF_LEGIC_INFO 0x03BC
149 #define CMD_HF_LEGIC_ESET 0x03BD
151 #define CMD_HF_ICLASS_SNIFF 0x0392
152 #define CMD_HF_ICLASS_SIMULATE 0x0393
153 #define CMD_HF_ICLASS_READER 0x0394
154 #define CMD_HF_ICLASS_REPLAY 0x0395
155 #define CMD_ICLASS_ISO14443A_WRITE 0x0397
156 #define CMD_HF_ICLASS_EML_MEMSET 0x0398
158 // For measurements of the antenna tuning
159 #define CMD_MEASURE_ANTENNA_TUNING 0x0400
160 #define CMD_MEASURE_ANTENNA_TUNING_HF 0x0401
161 #define CMD_MEASURED_ANTENNA_TUNING 0x0410
162 #define CMD_LISTEN_READER_FIELD 0x0420
164 // For direct FPGA control
165 #define CMD_FPGA_MAJOR_MODE_OFF 0x0500
167 // For mifare commands
168 #define CMD_MIFARE_SET_DBGMODE 0x0600
169 #define CMD_HF_MIFARE_EML_MEMCLR 0x0601
170 #define CMD_HF_MIFARE_EML_MEMSET 0x0602
171 #define CMD_HF_MIFARE_EML_MEMGET 0x0603
172 #define CMD_HF_MIFARE_EML_LOAD 0x0604
174 // magic chinese card commands
175 #define CMD_HF_MIFARE_CSETBL 0x0605
176 #define CMD_HF_MIFARE_CGETBL 0x0606
177 #define CMD_HF_MIFARE_CIDENT 0x0607
179 #define CMD_HF_MIFARE_SIMULATE 0x0610
181 #define CMD_HF_MIFARE_READER 0x0611
182 #define CMD_HF_MIFARE_NESTED 0x0612
183 #define CMD_HF_MIFARE_ACQ_ENCRYPTED_NONCES 0x0613
186 #define CMD_HF_MIFARE_READBL 0x0620
187 #define CMD_HF_MIFAREU_READBL 0x0720
188 #define CMD_HF_MIFARE_READSC 0x0621
189 #define CMD_HF_MIFAREU_READCARD 0x0721
190 #define CMD_HF_MIFARE_WRITEBL 0x0622
191 #define CMD_HF_MIFAREU_WRITEBL 0x0722
193 #define CMD_HF_MIFARE_CHKKEYS 0x0623
194 #define CMD_HF_MIFARE_SETMOD 0x0624
196 #define CMD_HF_MIFARE_SNIFF 0x0630
197 //ultralightC
198 #define CMD_HF_MIFAREUC_AUTH 0x0724
199 //0x0725 and 0x0726 no longer used
200 #define CMD_HF_MIFAREUC_SETPWD 0x0727
203 // mifare desfire
204 #define CMD_HF_DESFIRE_READBL 0x0728
205 #define CMD_HF_DESFIRE_WRITEBL 0x0729
206 #define CMD_HF_DESFIRE_AUTH1 0x072a
207 #define CMD_HF_DESFIRE_AUTH2 0x072b
208 #define CMD_HF_DESFIRE_READER 0x072c
209 #define CMD_HF_DESFIRE_INFO 0x072d
210 #define CMD_HF_DESFIRE_COMMAND 0x072e
213 #define CMD_HF_SNIFF 0x0800
215 #define CMD_UNKNOWN 0xFFFF
217 //Mifare simulation flags
218 #define FLAG_INTERACTIVE 0x01
219 #define FLAG_4B_UID_IN_DATA 0x02
220 #define FLAG_7B_UID_IN_DATA 0x04
221 #define FLAG_10B_UID_IN_DATA 0x08
222 #define FLAG_UID_IN_EMUL 0x10
223 #define FLAG_NR_AR_ATTACK 0x20
225 //Iclass reader flags
226 //#define FLAG_ICLASS_READER_ONLY_ONCE 0x01
227 #define FLAG_ICLASS_READER_CC 0x02
228 #define FLAG_ICLASS_READER_CSN 0x04
229 #define FLAG_ICLASS_READER_CONF 0x08
230 #define FLAG_ICLASS_READER_AIA 0x10
231 #define FLAG_ICLASS_READER_ONE_TRY 0x20
234 // CMD_DEVICE_INFO response packet has flags in arg[0], flag definitions:
235 /* Whether a bootloader that understands the common_area is present */
236 #define DEVICE_INFO_FLAG_BOOTROM_PRESENT (1<<0)
238 /* Whether a osimage that understands the common_area is present */
239 #define DEVICE_INFO_FLAG_OSIMAGE_PRESENT (1<<1)
241 /* Set if the bootloader is currently executing */
242 #define DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM (1<<2)
244 /* Set if the OS is currently executing */
245 #define DEVICE_INFO_FLAG_CURRENT_MODE_OS (1<<3)
247 /* Set if this device understands the extend start flash command */
248 #define DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH (1<<4)
250 /* CMD_START_FLASH may have three arguments: start of area to flash,
251 end of area to flash, optional magic.
252 The bootrom will not allow to overwrite itself unless this magic
253 is given as third parameter */
255 #define START_FLASH_MAGIC 0x54494f44 // 'DOIT'
257 #endif