mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
fpga
This commit is contained in:
parent
05299373fa
commit
57d1ff9316
1 changed files with 1120 additions and 1111 deletions
|
@ -277,7 +277,7 @@ void TransmitTo15693Tag(const uint8_t *cmd, int len, uint32_t *start_time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Transmit the command (to the reader) that was placed in cmd[].
|
// Transmit the tag response (to the reader) that was placed in cmd[].
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time, uint32_t slot_time, bool slow) {
|
void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time, uint32_t slot_time, bool slow) {
|
||||||
|
|
||||||
|
@ -368,7 +368,8 @@ typedef struct DecodeTag {
|
||||||
uint16_t max_len;
|
uint16_t max_len;
|
||||||
uint8_t *output;
|
uint8_t *output;
|
||||||
int len;
|
int len;
|
||||||
int sum1, sum2;
|
int sum1;
|
||||||
|
int sum2;
|
||||||
int threshold_sof;
|
int threshold_sof;
|
||||||
int threshold_half;
|
int threshold_half;
|
||||||
uint16_t previous_amplitude;
|
uint16_t previous_amplitude;
|
||||||
|
@ -655,7 +656,7 @@ int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeo
|
||||||
|
|
||||||
if(upTo >= dmaBuf + ISO15693_DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
|
if(upTo >= dmaBuf + ISO15693_DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
|
||||||
upTo = dmaBuf; // start reading the circular buffer from the beginning
|
upTo = dmaBuf; // start reading the circular buffer from the beginning
|
||||||
if (behindBy > (9*ISO15693_DMA_BUFFER_SIZE/10)) {
|
if (behindBy > (9 * ISO15693_DMA_BUFFER_SIZE / 10)) {
|
||||||
Dbprintf("About to blow circular buffer - aborted! behindBy=%d", behindBy);
|
Dbprintf("About to blow circular buffer - aborted! behindBy=%d", behindBy);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
|
@ -667,9 +668,9 @@ int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Handle15693SamplesFromTag(tagdata, &DecodeTag)) {
|
if (Handle15693SamplesFromTag(tagdata, &DecodeTag)) {
|
||||||
*eof_time = dma_start_time + samples*16 - DELAY_TAG_TO_ARM; // end of EOF
|
*eof_time = dma_start_time + (samples * 16) - DELAY_TAG_TO_ARM; // end of EOF
|
||||||
if (DecodeTag.lastBit == SOF_PART2) {
|
if (DecodeTag.lastBit == SOF_PART2) {
|
||||||
*eof_time -= 8*16; // needed 8 additional samples to confirm single SOF (iCLASS)
|
*eof_time -= (8 * 16); // needed 8 additional samples to confirm single SOF (iCLASS)
|
||||||
}
|
}
|
||||||
if (DecodeTag.len > DecodeTag.max_len) {
|
if (DecodeTag.len > DecodeTag.max_len) {
|
||||||
ret = -2; // buffer overflow
|
ret = -2; // buffer overflow
|
||||||
|
@ -686,22 +687,29 @@ int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeo
|
||||||
|
|
||||||
FpgaDisableSscDma();
|
FpgaDisableSscDma();
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("samples = %d, ret = %d, Decoder: state = %d, lastBit = %d, len = %d, bitCount = %d, posCount = %d",
|
|
||||||
samples, ret, DecodeTag.state, DecodeTag.lastBit, DecodeTag.len, DecodeTag.bitCount, DecodeTag.posCount);
|
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t sof_time = *eof_time
|
uint32_t sof_time = *eof_time
|
||||||
- DecodeTag.len * 8 * 8 * 16 // time for byte transfers
|
- DecodeTag.len * 8 * 8 * 16 // time for byte transfers
|
||||||
- 32 * 16 // time for SOF transfer
|
- 32 * 16 // time for SOF transfer
|
||||||
- (DecodeTag.lastBit != SOF_PART2?32*16:0); // time for EOF transfer
|
- (DecodeTag.lastBit != SOF_PART2?32*16:0); // time for EOF transfer
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("timing: sof_time = %d, eof_time = %d", sof_time, *eof_time);
|
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||||
|
Dbprintf("samples = %d, ret = %d, Decoder: state = %d, lastBit = %d, len = %d, bitCount = %d, posCount = %d",
|
||||||
|
samples,
|
||||||
|
ret,
|
||||||
|
DecodeTag.state,
|
||||||
|
DecodeTag.lastBit,
|
||||||
|
DecodeTag.len,
|
||||||
|
DecodeTag.bitCount,
|
||||||
|
DecodeTag.posCount
|
||||||
|
);
|
||||||
|
Dbprintf("timing: sof_time = %d, eof_time = %d", (sof_time * 4), (*eof_time * 4));
|
||||||
|
}
|
||||||
|
|
||||||
LogTrace(DecodeTag.output, DecodeTag.len, sof_time*4, *eof_time*4, NULL, false);
|
LogTrace(DecodeTag.output, DecodeTag.len, (sof_time * 4), (*eof_time * 4), NULL, false);
|
||||||
|
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
return DecodeTag.len;
|
return DecodeTag.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,9 +1103,7 @@ int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eo
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void AcquireRawAdcSamplesIso15693(void) {
|
void AcquireRawAdcSamplesIso15693(void) {
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
uint8_t *dest = BigBuf_malloc(4000);
|
||||||
//iceman: needs malloc
|
|
||||||
uint8_t *dest = BigBuf_get_addr();
|
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
|
||||||
|
@ -1298,8 +1304,7 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
|
||||||
Dbprintf(" Max behindBy: %d", max_behindBy);
|
Dbprintf(" Max behindBy: %d", max_behindBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the proxmark as iso15k reader
|
// Initialize Proxmark3 as ISO15693 reader
|
||||||
// (this might produces glitches that confuse some tags
|
|
||||||
void Iso15693InitReader(void) {
|
void Iso15693InitReader(void) {
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
|
@ -1319,6 +1324,10 @@ void Iso15693InitReader(void) {
|
||||||
|
|
||||||
// give tags some time to energize
|
// give tags some time to energize
|
||||||
SpinDelay(250);
|
SpinDelay(250);
|
||||||
|
|
||||||
|
set_tracing(true);
|
||||||
|
|
||||||
|
StartCountSspClk();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1378,11 +1387,8 @@ int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t
|
||||||
|
|
||||||
if (init) {
|
if (init) {
|
||||||
Iso15693InitReader();
|
Iso15693InitReader();
|
||||||
StartCountSspClk();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int answerLen = 0;
|
|
||||||
|
|
||||||
if (speed_fast) {
|
if (speed_fast) {
|
||||||
// high speed (1 out of 4)
|
// high speed (1 out of 4)
|
||||||
CodeIso15693AsReader(send, sendlen);
|
CodeIso15693AsReader(send, sendlen);
|
||||||
|
@ -1392,33 +1398,28 @@ int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t
|
||||||
}
|
}
|
||||||
|
|
||||||
TransmitTo15693Tag(ToSend, ToSendMax, &start_time);
|
TransmitTo15693Tag(ToSend, ToSendMax, &start_time);
|
||||||
uint32_t end_time = start_time + 32*(8*ToSendMax-4); // substract the 4 padding bits after EOF
|
uint32_t end_time = start_time + 32 * (8 * ToSendMax -4); // substract the 4 padding bits after EOF
|
||||||
LogTrace(send, sendlen, start_time*4, end_time*4, NULL, true);
|
LogTrace(send, sendlen, (start_time * 4), (end_time * 4), NULL, true);
|
||||||
|
|
||||||
// Now wait for a response
|
int res = 0;
|
||||||
if (recv != NULL) {
|
if (recv != NULL) {
|
||||||
answerLen = GetIso15693AnswerFromTag(recv, max_recv_len, timeout, eof_time);
|
res = GetIso15693AnswerFromTag(recv, max_recv_len, timeout, eof_time);
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
return answerLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SendDataTagEOF(uint8_t *recv, uint16_t max_recv_len, uint32_t start_time, uint16_t timeout, uint32_t *eof_time) {
|
int SendDataTagEOF(uint8_t *recv, uint16_t max_recv_len, uint32_t start_time, uint16_t timeout, uint32_t *eof_time) {
|
||||||
|
|
||||||
int answerLen = 0;
|
|
||||||
|
|
||||||
CodeIso15693AsReaderEOF();
|
CodeIso15693AsReaderEOF();
|
||||||
|
|
||||||
TransmitTo15693Tag(ToSend, ToSendMax, &start_time);
|
TransmitTo15693Tag(ToSend, ToSendMax, &start_time);
|
||||||
uint32_t end_time = start_time + 32*(8*ToSendMax-4); // substract the 4 padding bits after EOF
|
uint32_t end_time = start_time + 32 * (8 * ToSendMax - 4); // substract the 4 padding bits after EOF
|
||||||
LogTrace(NULL, 0, start_time*4, end_time*4, NULL, true);
|
LogTrace(NULL, 0, (start_time * 4), (end_time * 4), NULL, true);
|
||||||
|
|
||||||
// Now wait for a response
|
int res = 0;
|
||||||
if (recv != NULL) {
|
if (recv != NULL) {
|
||||||
answerLen = GetIso15693AnswerFromTag(recv, max_recv_len, timeout, eof_time);
|
res = GetIso15693AnswerFromTag(recv, max_recv_len, timeout, eof_time);
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
return answerLen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
@ -1551,10 +1552,22 @@ void ReaderIso15693(uint32_t parameter) {
|
||||||
|
|
||||||
// When SIM: initialize the Proxmark3 as ISO15693 tag
|
// When SIM: initialize the Proxmark3 as ISO15693 tag
|
||||||
void Iso15693InitTag(void) {
|
void Iso15693InitTag(void) {
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
|
||||||
|
// Start from off (no field generated)
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
LEDsoff();
|
||||||
|
SpinDelay(10);
|
||||||
|
|
||||||
|
// switch simulation FPGA
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_NO_MODULATION);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_NO_MODULATION);
|
||||||
|
|
||||||
|
// initialize SSC and select proper AD input
|
||||||
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_SIMULATOR);
|
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_SIMULATOR);
|
||||||
|
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||||
|
|
||||||
|
// turn on clock
|
||||||
StartCountSspClk();
|
StartCountSspClk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1562,7 +1575,6 @@ void Iso15693InitTag(void) {
|
||||||
// all demodulation performed in arm rather than host. - greg
|
// all demodulation performed in arm rather than host. - greg
|
||||||
void SimTagIso15693(uint8_t *uid) {
|
void SimTagIso15693(uint8_t *uid) {
|
||||||
|
|
||||||
LEDsoff();
|
|
||||||
Iso15693InitTag();
|
Iso15693InitTag();
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
@ -1721,7 +1733,6 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
|
||||||
}
|
}
|
||||||
reply_mix(CMD_ACK, recvlen, 0, 0, recvbuf, ISO15693_MAX_RESPONSE_LENGTH);
|
reply_mix(CMD_ACK, recvlen, 0, 0, recvbuf, ISO15693_MAX_RESPONSE_LENGTH);
|
||||||
|
|
||||||
|
|
||||||
if (DBGLEVEL >= DBG_EXTENDED) {
|
if (DBGLEVEL >= DBG_EXTENDED) {
|
||||||
Dbprintf("RECV:");
|
Dbprintf("RECV:");
|
||||||
if (recvlen > 0) {
|
if (recvlen > 0) {
|
||||||
|
@ -1729,8 +1740,6 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
|
||||||
DbdecodeIso15693Answer(recvlen, recvbuf);
|
DbdecodeIso15693Answer(recvlen, recvbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reply_mix(CMD_ACK, 1, 0, 0, 0, 0);
|
reply_mix(CMD_ACK, 1, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue