\r
int offline = 0;\r
HANDLE UsbHandle;\r
+extern unsigned int current_command;\r
\r
static void ShowError(void)\r
{\r
}\r
}\r
\r
-void SendCommand(UsbCommand *c, bool wantAck)\r
+void SendCommand(UsbCommand *c)\r
{\r
BYTE buf[65];\r
buf[0] = 0;\r
ShowError();\r
exit(-1);\r
}\r
+ current_command = c->cmd;\r
+}\r
\r
- if(wantAck) {\r
- UsbCommand ack;\r
- ReceiveCommand(&ack);\r
- if(ack.cmd != CMD_ACK) {\r
- printf("bad ACK\n");\r
- exit(-1);\r
- }\r
+void WaitForAck(void) {\r
+ UsbCommand ack;\r
+ ReceiveCommand(&ack);\r
+ if(ack.cmd != CMD_ACK) {\r
+ printf("bad ACK\n");\r
+ exit(-1);\r
}\r
}\r
\r
c.cmd = CMD_SETUP_WRITE;\r
memcpy(c.d.asBytes, QueuedToSend+i, 48);\r
c.arg[0] = (i/4);\r
- SendCommand(&c, TRUE);\r
+ SendCommand(&c);\r
+ WaitForAck();\r
}\r
\r
c.cmd = CMD_FINISH_WRITE;\r
}\r
printf("Flashing address: %08x\r", c.arg[0]);\r
memcpy(c.d.asBytes, QueuedToSend+240, 16);\r
- SendCommand(&c, TRUE);\r
-\r
+ SendCommand(&c);\r
+ WaitForAck();\r
+ \r
AllWritten = TRUE;\r
}\r
\r
} else {\r
c.arg[2] = 0;\r
}\r
- SendCommand(&c, TRUE);\r
+ SendCommand(&c);\r
+ WaitForAck();\r
translate = 0;\r
} else {\r
fprintf(stderr, "Warning: Your bootloader does not understand the new START_FLASH command\n");\r
\r
UsbCommand c;\r
c.cmd = CMD_DEVICE_INFO;\r
- SendCommand(&c, FALSE);\r
+ SendCommand(&c);\r
\r
UsbCommand resp;\r
ReceiveCommand(&resp);\r
* enter the bootrom on the next boot.\r
*/\r
c.cmd = CMD_START_FLASH;\r
- SendCommand(&c, FALSE);\r
+ SendCommand(&c);\r
fprintf(stderr,"(You don't have to do anything. Press and release the button only if you want to abort)\n");\r
fprintf(stderr,"Waiting for Proxmark to reappear on USB... ");\r
} else {\r
/* Old style handover: Ask the user to press the button, then reset the board */\r
c.cmd = CMD_HARDWARE_RESET;\r
- SendCommand(&c, FALSE);\r
+ SendCommand(&c);\r
fprintf(stderr,"(Press and hold down button NOW if your bootloader requires it)\n");\r
fprintf(stderr,"Waiting for Proxmark to reappear on USB... ");\r
}\r