mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08:00
removed all old usb calls
This commit is contained in:
parent
ecab772ed0
commit
6e82300dda
12 changed files with 144 additions and 92 deletions
|
@ -27,7 +27,6 @@ THUMBSRC = start.c \
|
|||
appmain.c printf.c \
|
||||
util.c \
|
||||
string.c \
|
||||
usb.c \
|
||||
usb_cdc.c \
|
||||
cmd.c
|
||||
|
||||
|
|
|
@ -387,8 +387,9 @@ void SamyRun()
|
|||
|
||||
for (;;)
|
||||
{
|
||||
UsbPoll(FALSE);
|
||||
WDT_HIT();
|
||||
// UsbPoll(FALSE);
|
||||
usb_poll();
|
||||
WDT_HIT();
|
||||
|
||||
// Was our button held down or pressed?
|
||||
int button_pressed = BUTTON_HELD(1000);
|
||||
|
@ -905,7 +906,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
|||
case CMD_SETUP_WRITE:
|
||||
case CMD_FINISH_WRITE:
|
||||
case CMD_HARDWARE_RESET: {
|
||||
USB_D_PLUS_PULLUP_OFF();
|
||||
usb_disable();
|
||||
SpinDelay(1000);
|
||||
SpinDelay(1000);
|
||||
AT91C_BASE_RSTC->RSTC_RCR = RST_CONTROL_KEY | AT91C_RSTC_PROCRST;
|
||||
|
@ -918,7 +919,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
|||
if(common_area.flags.bootrom_present) {
|
||||
common_area.command = COMMON_AREA_COMMAND_ENTER_FLASH_MODE;
|
||||
}
|
||||
USB_D_PLUS_PULLUP_OFF();
|
||||
usb_disable();
|
||||
AT91C_BASE_RSTC->RSTC_RCR = RST_CONTROL_KEY | AT91C_RSTC_PROCRST;
|
||||
for(;;);
|
||||
} break;
|
||||
|
@ -955,7 +956,6 @@ void __attribute__((noreturn)) AppMain(void)
|
|||
|
||||
// Init USB device
|
||||
usb_enable();
|
||||
UsbStart();
|
||||
// UsbStart();
|
||||
|
||||
// The FPGA gets its clock from us from PCK0 output, so set that up.
|
||||
|
|
|
@ -181,6 +181,10 @@ void SnoopHitag(uint32_t type);
|
|||
void SimulateHitagTag(bool tag_mem_supplied, byte_t* data);
|
||||
void ReaderHitag(hitag_function htf, hitag_data* htd);
|
||||
|
||||
// cmd.h
|
||||
bool cmd_receive(UsbCommand* cmd);
|
||||
bool cmd_send(uint32_t cmd, uint32_t arg0, uint32_t arg1, uint32_t arg2, byte_t* data, size_t len);
|
||||
|
||||
/// util.h
|
||||
|
||||
#endif
|
||||
|
|
|
@ -78,11 +78,12 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
memset(uid, 0x44, 4);
|
||||
LogTrace(uid, 4, 0, 0, TRUE);
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
memcpy(ack.d.asBytes, dataoutbuf, 16);
|
||||
// UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
// memcpy(ack.d.asBytes, dataoutbuf, 16);
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,isOK,0,0,0,0);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
|
||||
|
@ -170,17 +171,18 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
memset(uid, 0x44, 4);
|
||||
LogTrace(uid, 4, 0, 0, TRUE);
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
memcpy(ack.d.asBytes, dataoutbuf, 16 * 2);
|
||||
// UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
// memcpy(ack.d.asBytes, dataoutbuf, 16 * 2);
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
|
||||
SpinDelay(100);
|
||||
cmd_send(CMD_ACK,isOK,0,0,dataoutbuf,32);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
// SpinDelay(100);
|
||||
|
||||
memcpy(ack.d.asBytes, dataoutbuf + 16 * 2, 16 * 2);
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
// memcpy(ack.d.asBytes, dataoutbuf + 16 * 2, 16 * 2);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,isOK,0,0,dataoutbuf+32, 32);
|
||||
LED_B_OFF();
|
||||
|
||||
// Thats it...
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
@ -256,11 +258,12 @@ void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
memset(uid, 0x44, 4);
|
||||
LogTrace(uid, 4, 0, 0, TRUE);
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
// UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
cmd_send(CMD_ACK,isOK,0,0,0,0);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
|
||||
// Thats it...
|
||||
|
@ -301,7 +304,6 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
|||
nestedVector nvector[NES_MAX_INFO + 1][11];
|
||||
int nvectorcount[NES_MAX_INFO + 1];
|
||||
int ncount = 0;
|
||||
UsbCommand ack = {CMD_ACK, {0, 0, 0}};
|
||||
struct Crypto1State mpcs = {0, 0};
|
||||
struct Crypto1State *pcs;
|
||||
pcs = &mpcs;
|
||||
|
@ -468,6 +470,8 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
|||
memset(uid, 0x44, 4);
|
||||
LogTrace(uid, 4, 0, 0, TRUE);
|
||||
|
||||
// UsbCommand ack = {CMD_ACK, {0, 0, 0}};
|
||||
|
||||
for (i = 0; i < NES_MAX_INFO; i++) {
|
||||
if (nvectorcount[i] > 10) continue;
|
||||
|
||||
|
@ -475,34 +479,38 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
|||
ncount = nvectorcount[i] - j;
|
||||
if (ncount > 5) ncount = 5;
|
||||
|
||||
ack.arg[0] = 0; // isEOF = 0
|
||||
ack.arg[1] = ncount;
|
||||
ack.arg[2] = targetBlockNo + (targetKeyType * 0x100);
|
||||
memset(ack.d.asBytes, 0x00, sizeof(ack.d.asBytes));
|
||||
// ack.arg[0] = 0; // isEOF = 0
|
||||
// ack.arg[1] = ncount;
|
||||
// ack.arg[2] = targetBlockNo + (targetKeyType * 0x100);
|
||||
// memset(ack.d.asBytes, 0x00, sizeof(ack.d.asBytes));
|
||||
|
||||
memcpy(ack.d.asBytes, &cuid, 4);
|
||||
byte_t buf[48];
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
memcpy(buf, &cuid, 4);
|
||||
for (m = 0; m < ncount; m++) {
|
||||
memcpy(ack.d.asBytes + 8 + m * 8 + 0, &nvector[i][m + j].nt, 4);
|
||||
memcpy(ack.d.asBytes + 8 + m * 8 + 4, &nvector[i][m + j].ks1, 4);
|
||||
memcpy(buf + 8 + m * 8 + 0, &nvector[i][m + j].nt, 4);
|
||||
memcpy(buf + 8 + m * 8 + 4, &nvector[i][m + j].ks1, 4);
|
||||
}
|
||||
|
||||
LED_B_ON();
|
||||
SpinDelay(100);
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
// SpinDelay(100);
|
||||
cmd_send(CMD_ACK,0,ncount,targetBlockNo + (targetKeyType * 0x100),buf,48);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
}
|
||||
}
|
||||
|
||||
// finalize list
|
||||
ack.arg[0] = 1; // isEOF = 1
|
||||
ack.arg[1] = 0;
|
||||
ack.arg[2] = 0;
|
||||
memset(ack.d.asBytes, 0x00, sizeof(ack.d.asBytes));
|
||||
// ack.arg[0] = 1; // isEOF = 1
|
||||
// ack.arg[1] = 0;
|
||||
// ack.arg[2] = 0;
|
||||
// memset(ack.d.asBytes, 0x00, sizeof(ack.d.asBytes));
|
||||
|
||||
LED_B_ON();
|
||||
SpinDelay(300);
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
// SpinDelay(300);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||
LED_B_OFF();
|
||||
|
||||
if (MF_DBGLEVEL >= 4) DbpString("NESTED FINISHED");
|
||||
|
||||
|
@ -575,11 +583,12 @@ void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
|||
memset(uid, 0x44, 4);
|
||||
LogTrace(uid, 4, 0, 0, TRUE);
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
if (isOK) memcpy(ack.d.asBytes, datain + i * 6, 6);
|
||||
// UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
// if (isOK) memcpy(ack.d.asBytes, datain + i * 6, 6);
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
// Thats it...
|
||||
|
@ -612,12 +621,14 @@ void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain)
|
|||
}
|
||||
|
||||
void MifareEMemGet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain){
|
||||
UsbCommand ack = {CMD_ACK, {arg0, arg1, 0}};
|
||||
// UsbCommand ack = {CMD_ACK, {arg0, arg1, 0}};
|
||||
|
||||
emlGetMem(ack.d.asBytes, arg0, arg1); // data, block num, blocks count
|
||||
byte_t buf[48];
|
||||
emlGetMem(buf, arg0, arg1); // data, block num, blocks count
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,arg0,arg1,0,buf,48);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
}
|
||||
|
||||
|
@ -848,15 +859,16 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
|
|||
break;
|
||||
}
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
if (isOK) memcpy(ack.d.asBytes, uid, 4);
|
||||
// UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
// if (isOK) memcpy(ack.d.asBytes, uid, 4);
|
||||
|
||||
// add trace trailer
|
||||
memset(uid, 0x44, 4);
|
||||
LogTrace(uid, 4, 0, 0, TRUE);
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,isOK,0,0,uid,4);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
if ((workFlags & 0x10) || (!isOK)) {
|
||||
|
@ -938,15 +950,16 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
|
|||
break;
|
||||
}
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
if (isOK) memcpy(ack.d.asBytes, data, 18);
|
||||
// UsbCommand ack = {CMD_ACK, {isOK, 0, 0}};
|
||||
// if (isOK) memcpy(ack.d.asBytes, data, 18);
|
||||
|
||||
// add trace trailer
|
||||
memset(data, 0x44, 4);
|
||||
LogTrace(data, 4, 0, 0, TRUE);
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,isOK,0,0,data,18);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
if ((workFlags & 0x10) || (!isOK)) {
|
||||
|
|
|
@ -31,10 +31,11 @@ int MfSniffInit(void){
|
|||
}
|
||||
|
||||
int MfSniffEnd(void){
|
||||
UsbCommand ack = {CMD_ACK, {0, 0, 0}};
|
||||
// UsbCommand ack = {CMD_ACK, {0, 0, 0}};
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,0,0,0,0,0);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
return 0;
|
||||
|
@ -167,22 +168,24 @@ int intMfSniffSend() {
|
|||
|
||||
while (pckLen > 0) {
|
||||
pckSize = MIN(32, pckLen);
|
||||
UsbCommand ack = {CMD_ACK, {1, pckSize, pckNum}};
|
||||
memcpy(ack.d.asBytes, trace + traceLen - pckLen, pckSize);
|
||||
// UsbCommand ack = {CMD_ACK, {1, pckSize, pckNum}};
|
||||
// memcpy(ack.d.asBytes, trace + traceLen - pckLen, pckSize);
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
SpinDelay(20);
|
||||
cmd_send(CMD_ACK,1,pckSize,pckNum,trace + traceLen - pckLen,pckSize);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
// SpinDelay(20);
|
||||
LED_B_OFF();
|
||||
|
||||
pckLen -= pckSize;
|
||||
pckNum++;
|
||||
}
|
||||
|
||||
UsbCommand ack = {CMD_ACK, {2, 0, 0}};
|
||||
// UsbCommand ack = {CMD_ACK, {2, 0, 0}};
|
||||
|
||||
LED_B_ON();
|
||||
UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
cmd_send(CMD_ACK,2,0,0,0,0);
|
||||
// UsbSendPacket((uint8_t *)&ack, sizeof(UsbCommand));
|
||||
LED_B_OFF();
|
||||
|
||||
traceLen = 0;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include "usb_cdc.h"
|
||||
#include "util.h"
|
||||
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
@ -215,12 +216,26 @@ byte_t btConfiguration = 0;
|
|||
byte_t btConnection = 0;
|
||||
byte_t btReceiveBank = AT91C_UDP_RX_DATA_BK0;
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
//* \fn AT91F_USB_Disable
|
||||
//* \brief This function deactivates the USB device
|
||||
//*----------------------------------------------------------------------------
|
||||
void usb_disable() {
|
||||
// Disconnect and reconnect USB controller for 100ms
|
||||
AT91C_BASE_PIOA->PIO_ODR = AT91C_PIO_PA24;
|
||||
SpinDelay(100);
|
||||
|
||||
// Clear all lingering interrupts
|
||||
if(pUdp->UDP_ISR & AT91C_UDP_ENDBUSRES) {
|
||||
pUdp->UDP_ICR = AT91C_UDP_ENDBUSRES;
|
||||
}
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
//* \fn AT91F_USB_Enable
|
||||
//* \brief This function Activates the USB device
|
||||
//*----------------------------------------------------------------------------
|
||||
void usb_enable()
|
||||
{
|
||||
void usb_enable() {
|
||||
// Set the PLL USB Divider
|
||||
AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1 ;
|
||||
|
||||
|
@ -236,14 +251,23 @@ void usb_enable()
|
|||
|
||||
// Clear for set the Pul up resistor
|
||||
AT91C_BASE_PIOA->PIO_CODR = AT91C_PIO_PA16;
|
||||
|
||||
// Disconnect and USB device
|
||||
usb_disable();
|
||||
|
||||
// Wait for a short while
|
||||
SpinDelay(100);
|
||||
|
||||
// Reconnect USB reconnect
|
||||
AT91C_BASE_PIOA->PIO_SODR = AT91C_PIO_PA24;
|
||||
AT91C_BASE_PIOA->PIO_OER = AT91C_PIO_PA24;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------
|
||||
//* \fn AT91F_UDP_IsConfigured
|
||||
//* \brief Test if the device is configured and handle enumeration
|
||||
//*----------------------------------------------------------------------------
|
||||
bool usb_check()
|
||||
{
|
||||
bool usb_check() {
|
||||
AT91_REG isr = pUdp->UDP_ISR;
|
||||
|
||||
if (isr & AT91C_UDP_ENDBUSRES) {
|
||||
|
@ -274,8 +298,7 @@ bool usb_poll()
|
|||
//* \fn AT91F_UDP_Read
|
||||
//* \brief Read available data from Endpoint OUT
|
||||
//*----------------------------------------------------------------------------
|
||||
uint32_t usb_read(byte_t* data, size_t len)
|
||||
{
|
||||
uint32_t usb_read(byte_t* data, size_t len) {
|
||||
byte_t bank = btReceiveBank;
|
||||
uint32_t packetSize, nbBytesRcv = 0;
|
||||
uint32_t time_out = 0;
|
||||
|
@ -308,8 +331,7 @@ uint32_t usb_read(byte_t* data, size_t len)
|
|||
//* \fn AT91F_CDC_Write
|
||||
//* \brief Send through endpoint 2
|
||||
//*----------------------------------------------------------------------------
|
||||
uint32_t usb_write(const byte_t* data, const size_t len)
|
||||
{
|
||||
uint32_t usb_write(const byte_t* data, const size_t len) {
|
||||
size_t length = len;
|
||||
uint32_t cpt = 0;
|
||||
|
||||
|
@ -354,8 +376,7 @@ uint32_t usb_write(const byte_t* data, const size_t len)
|
|||
unsigned int csrTab[100];
|
||||
unsigned char csrIdx = 0;
|
||||
|
||||
static void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length)
|
||||
{
|
||||
static void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t length) {
|
||||
uint32_t cpt = 0;
|
||||
AT91_REG csr;
|
||||
|
||||
|
@ -394,8 +415,7 @@ static void AT91F_USB_SendData(AT91PS_UDP pUdp, const char *pData, uint32_t leng
|
|||
//* \fn AT91F_USB_SendZlp
|
||||
//* \brief Send zero length packet through the control endpoint
|
||||
//*----------------------------------------------------------------------------
|
||||
void AT91F_USB_SendZlp(AT91PS_UDP pUdp)
|
||||
{
|
||||
void AT91F_USB_SendZlp(AT91PS_UDP pUdp) {
|
||||
pUdp->UDP_CSR[0] |= AT91C_UDP_TXPKTRDY;
|
||||
while ( !(pUdp->UDP_CSR[0] & AT91C_UDP_TXCOMP) );
|
||||
pUdp->UDP_CSR[0] &= ~(AT91C_UDP_TXCOMP);
|
||||
|
@ -406,8 +426,7 @@ void AT91F_USB_SendZlp(AT91PS_UDP pUdp)
|
|||
//* \fn AT91F_USB_SendStall
|
||||
//* \brief Stall the control endpoint
|
||||
//*----------------------------------------------------------------------------
|
||||
void AT91F_USB_SendStall(AT91PS_UDP pUdp)
|
||||
{
|
||||
void AT91F_USB_SendStall(AT91PS_UDP pUdp) {
|
||||
pUdp->UDP_CSR[0] |= AT91C_UDP_FORCESTALL;
|
||||
while ( !(pUdp->UDP_CSR[0] & AT91C_UDP_ISOERROR) );
|
||||
pUdp->UDP_CSR[0] &= ~(AT91C_UDP_FORCESTALL | AT91C_UDP_ISOERROR);
|
||||
|
@ -418,8 +437,7 @@ void AT91F_USB_SendStall(AT91PS_UDP pUdp)
|
|||
//* \fn AT91F_CDC_Enumerate
|
||||
//* \brief This function is a callback invoked when a SETUP packet is received
|
||||
//*----------------------------------------------------------------------------
|
||||
void AT91F_CDC_Enumerate()
|
||||
{
|
||||
void AT91F_CDC_Enumerate() {
|
||||
byte_t bmRequestType, bRequest;
|
||||
uint16_t wValue, wIndex, wLength, wStatus;
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <common.h>
|
||||
|
||||
void usb_disable();
|
||||
void usb_enable();
|
||||
bool usb_check();
|
||||
bool usb_poll();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
# DO NOT use thumb mode in the phase 1 bootloader since that generates a section with glue code
|
||||
ARMSRC =
|
||||
THUMBSRC = usb.c bootrom.c
|
||||
THUMBSRC = usb_hid.c bootrom.c
|
||||
ASMSRC = ram-reset.s flash-reset.s
|
||||
|
||||
## There is a strange bug with the linker: Sometimes it will not emit the glue to call
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <proxmark3.h>
|
||||
#include "usb_hid.h"
|
||||
|
||||
struct common_area common_area __attribute__((section(".commonarea")));
|
||||
unsigned int start_addr, end_addr, bootrom_unlocked;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "proxmark3.h"
|
||||
#include "usb_hid.h"
|
||||
|
||||
#define min(a, b) (((a) > (b)) ? (b) : (a))
|
||||
|
29
bootrom/usb_hid.h
Normal file
29
bootrom/usb_hid.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef _USB_HID_H_
|
||||
#define _USB_HID_H_
|
||||
|
||||
#include <common.h>
|
||||
#include <proxmark3.h>
|
||||
|
||||
//--------------------------------
|
||||
// USB defines
|
||||
|
||||
#define USB_D_PLUS_PULLUP_ON() { \
|
||||
HIGH(GPIO_USB_PU); \
|
||||
AT91C_BASE_PIOA->PIO_OER = GPIO_USB_PU; \
|
||||
}
|
||||
#define USB_D_PLUS_PULLUP_OFF() AT91C_BASE_PIOA->PIO_ODR = GPIO_USB_PU
|
||||
|
||||
//--------------------------------
|
||||
// USB declarations
|
||||
|
||||
void UsbSendPacket(uint8_t *packet, int len);
|
||||
int UsbConnected();
|
||||
int UsbPoll(int blinkLeds);
|
||||
void UsbStart(void);
|
||||
|
||||
// This function is provided by the apps/bootrom, and called from UsbPoll
|
||||
// if data are available.
|
||||
void UsbPacketReceived(uint8_t *packet, int len);
|
||||
|
||||
#endif // _USB_HID_H_
|
||||
|
|
@ -67,12 +67,6 @@
|
|||
|
||||
//#define PACKED __attribute__((__packed__))
|
||||
|
||||
#define USB_D_PLUS_PULLUP_ON() { \
|
||||
HIGH(GPIO_USB_PU); \
|
||||
AT91C_BASE_PIOA->PIO_OER = GPIO_USB_PU; \
|
||||
}
|
||||
#define USB_D_PLUS_PULLUP_OFF() AT91C_BASE_PIOA->PIO_ODR = GPIO_USB_PU
|
||||
|
||||
#define LED_A_ON() HIGH(GPIO_LED_A)
|
||||
#define LED_A_OFF() LOW(GPIO_LED_A)
|
||||
#define LED_A_INV() INVBIT(GPIO_LED_A)
|
||||
|
@ -88,17 +82,6 @@
|
|||
#define RELAY_ON() HIGH(GPIO_RELAY)
|
||||
#define RELAY_OFF() LOW(GPIO_RELAY)
|
||||
#define BUTTON_PRESS() !(AT91C_BASE_PIOA->PIO_PDSR & GPIO_BUTTON)
|
||||
//--------------------------------
|
||||
// USB declarations
|
||||
|
||||
void UsbSendPacket(uint8_t *packet, int len);
|
||||
int UsbConnected();
|
||||
int UsbPoll(int blinkLeds);
|
||||
void UsbStart(void);
|
||||
|
||||
// This function is provided by the apps/bootrom, and called from UsbPoll
|
||||
// if data are available.
|
||||
void UsbPacketReceived(uint8_t *packet, int len);
|
||||
|
||||
#define VERSION_INFORMATION_MAGIC 0x56334d50
|
||||
struct version_information {
|
||||
|
|
Loading…
Reference in a new issue