minor fixes regaring the newly released patches from the pm3 community
plus removed old comments in cmdmain.c
This commit is contained in:
@@ -169,13 +169,11 @@ int AvgAdc(int ch) // was static - merlok
|
||||
|
||||
void MeasureAntennaTuning(void)
|
||||
{
|
||||
uint8_t *dest = (uint8_t *)BigBuf + FREE_BUFFER_OFFSET;
|
||||
uint8_t LF_Results[256];
|
||||
int i, adcval = 0, peak = 0, peakv = 0, peakf = 0; //ptr = 0
|
||||
int vLf125 = 0, vLf134 = 0, vHf = 0; // in mV
|
||||
|
||||
LED_B_ON();
|
||||
DbpString("Measuring antenna characteristics, please wait...");
|
||||
memset(dest,0,FREE_BUFFER_SIZE);
|
||||
|
||||
/*
|
||||
* Sweeps the useful LF range of the proxmark from
|
||||
@@ -188,7 +186,7 @@ void MeasureAntennaTuning(void)
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
|
||||
for (i=255; i>19; i--) {
|
||||
for (i=255; i>=19; i--) {
|
||||
WDT_HIT();
|
||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, i);
|
||||
SpinDelay(20);
|
||||
@@ -198,15 +196,17 @@ void MeasureAntennaTuning(void)
|
||||
if (i==95) vLf125 = adcval; // voltage at 125Khz
|
||||
if (i==89) vLf134 = adcval; // voltage at 134Khz
|
||||
|
||||
dest[i] = adcval>>8; // scale int to fit in byte for graphing purposes
|
||||
if(dest[i] > peak) {
|
||||
LF_Results[i] = adcval>>8; // scale int to fit in byte for graphing purposes
|
||||
if(LF_Results[i] > peak) {
|
||||
peakv = adcval;
|
||||
peak = dest[i];
|
||||
peak = LF_Results[i];
|
||||
peakf = i;
|
||||
//ptr = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (i=18; i >= 0; i--) LF_Results[i] = 0;
|
||||
|
||||
LED_A_ON();
|
||||
// Let the FPGA drive the high-frequency antenna around 13.56 MHz.
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
@@ -216,14 +216,7 @@ void MeasureAntennaTuning(void)
|
||||
// can measure voltages up to 33000 mV
|
||||
vHf = (33000 * AvgAdc(ADC_CHAN_HF)) >> 10;
|
||||
|
||||
// c.cmd = CMD_MEASURED_ANTENNA_TUNING;
|
||||
// c.arg[0] = (vLf125 << 0) | (vLf134 << 16);
|
||||
// c.arg[1] = vHf;
|
||||
// c.arg[2] = peakf | (peakv << 16);
|
||||
|
||||
DbpString("Measuring complete, sending report back to host");
|
||||
cmd_send(CMD_MEASURED_ANTENNA_TUNING,vLf125|(vLf134<<16),vHf,peakf|(peakv<<16),0,0);
|
||||
// UsbSendPacket((uint8_t *)&c, sizeof(c));
|
||||
cmd_send(CMD_MEASURED_ANTENNA_TUNING,vLf125|(vLf134<<16),vHf,peakf|(peakv<<16),LF_Results,256);
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LED_A_OFF();
|
||||
LED_B_OFF();
|
||||
|
||||
@@ -1714,7 +1714,7 @@ int ReaderReceive(uint8_t *receivedAnswer, uint8_t *parity)
|
||||
* fills the uid pointer unless NULL
|
||||
* fills resp_data unless NULL */
|
||||
int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, uint32_t* cuid_ptr) {
|
||||
uint8_t halt[] = { 0x50 }; // HALT
|
||||
//uint8_t halt[] = { 0x50 }; // HALT
|
||||
uint8_t wupa[] = { 0x52 }; // WAKE-UP
|
||||
//uint8_t reqa[] = { 0x26 }; // REQUEST A
|
||||
uint8_t sel_all[] = { 0x93,0x20 };
|
||||
@@ -1725,30 +1725,29 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||
|
||||
byte_t uid_resp[4];
|
||||
size_t uid_resp_len;
|
||||
|
||||
uint8_t sak = 0x04; // cascade uid
|
||||
int cascade_level = 0;
|
||||
int len;
|
||||
uint8_t sak = 0x04; // cascade uid
|
||||
int cascade_level = 0;
|
||||
int len;
|
||||
|
||||
ReaderTransmit(halt,sizeof(halt), NULL);
|
||||
// test for the SKYLANDERS TOY.
|
||||
//ReaderTransmit(halt,sizeof(halt), NULL);
|
||||
|
||||
// Broadcast for a card, WUPA (0x52) will force response from all cards in the field
|
||||
ReaderTransmitBitsPar(wupa,7,0, NULL);
|
||||
// Broadcast for a card, WUPA (0x52) will force response from all cards in the field
|
||||
ReaderTransmitBitsPar(wupa,7,0, NULL);
|
||||
|
||||
// Receive the ATQA
|
||||
if(!ReaderReceive(resp, resp_par)) return 0;
|
||||
// Dbprintf("atqa: %02x %02x",resp[0],resp[1]);
|
||||
// Receive the ATQA
|
||||
if(!ReaderReceive(resp, resp_par)) return 0;
|
||||
|
||||
if(p_hi14a_card) {
|
||||
memcpy(p_hi14a_card->atqa, resp, 2);
|
||||
p_hi14a_card->uidlen = 0;
|
||||
memset(p_hi14a_card->uid,0,10);
|
||||
}
|
||||
|
||||
if(p_hi14a_card) {
|
||||
memcpy(p_hi14a_card->atqa, resp, 2);
|
||||
p_hi14a_card->uidlen = 0;
|
||||
memset(p_hi14a_card->uid,0,10);
|
||||
}
|
||||
|
||||
// clear uid
|
||||
if (uid_ptr) {
|
||||
memset(uid_ptr,0,10);
|
||||
}
|
||||
// clear uid
|
||||
if (uid_ptr) {
|
||||
memset(uid_ptr,0,10);
|
||||
}
|
||||
|
||||
// OK we will select at least at cascade 1, lets see if first byte of UID was 0x88 in
|
||||
// which case we need to make a cascade 2 request and select - this is a long UID
|
||||
@@ -1794,7 +1793,6 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||
}
|
||||
uid_resp_len = 4;
|
||||
|
||||
|
||||
// calculate crypto UID. Always use last 4 Bytes.
|
||||
if(cuid_ptr) {
|
||||
*cuid_ptr = bytes_to_num(uid_resp, 4);
|
||||
@@ -1811,17 +1809,11 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||
if (!ReaderReceive(resp, resp_par)) return 0;
|
||||
sak = resp[0];
|
||||
|
||||
//Dbprintf("SAK: %02x",resp[0]);
|
||||
|
||||
// Test if more parts of the uid are comming
|
||||
// Test if more parts of the uid are coming
|
||||
if ((sak & 0x04) /* && uid_resp[0] == 0x88 */) {
|
||||
// Remove first byte, 0x88 is not an UID byte, it CT, see page 3 of:
|
||||
// http://www.nxp.com/documents/application_note/AN10927.pdf
|
||||
// This was earlier:
|
||||
//memcpy(uid_resp, uid_resp + 1, 3);
|
||||
// But memcpy should not be used for overlapping arrays,
|
||||
// and memmove appears to not be available in the arm build.
|
||||
// Therefore:
|
||||
uid_resp[0] = uid_resp[1];
|
||||
uid_resp[1] = uid_resp[2];
|
||||
uid_resp[2] = uid_resp[3];
|
||||
@@ -1844,24 +1836,24 @@ int iso14443a_select_card(byte_t* uid_ptr, iso14a_card_select_t* p_hi14a_card, u
|
||||
p_hi14a_card->ats_len = 0;
|
||||
}
|
||||
|
||||
if( (sak & 0x20) == 0) {
|
||||
return 2; // non iso14443a compliant tag
|
||||
}
|
||||
if( (sak & 0x20) == 0) {
|
||||
return 2; // non iso14443a compliant tag
|
||||
}
|
||||
|
||||
// Request for answer to select
|
||||
AppendCrc14443a(rats, 2);
|
||||
ReaderTransmit(rats, sizeof(rats), NULL);
|
||||
// Request for answer to select
|
||||
AppendCrc14443a(rats, 2);
|
||||
ReaderTransmit(rats, sizeof(rats), NULL);
|
||||
|
||||
if (!(len = ReaderReceive(resp,resp_par))) return 0;
|
||||
if (!(len = ReaderReceive(resp, resp_par))) return 2;
|
||||
|
||||
if(p_hi14a_card) {
|
||||
memcpy(p_hi14a_card->ats, resp, sizeof(p_hi14a_card->ats));
|
||||
p_hi14a_card->ats_len = len;
|
||||
}
|
||||
if(p_hi14a_card) {
|
||||
memcpy(p_hi14a_card->ats, resp, sizeof(p_hi14a_card->ats));
|
||||
p_hi14a_card->ats_len = len;
|
||||
}
|
||||
|
||||
// reset the PCB block number
|
||||
iso14_pcb_blocknum = 0;
|
||||
return 1;
|
||||
// reset the PCB block number
|
||||
iso14_pcb_blocknum = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void iso14443a_setup(uint8_t fpga_minor_mode) {
|
||||
|
||||
Reference in New Issue
Block a user