fiddling with thinfilm, which suffers in simulation

This commit is contained in:
iceman1001 2023-12-18 22:18:21 +01:00
parent 2c20c0c647
commit 0eea4e31c4

View file

@ -101,7 +101,7 @@ static int EmSendCmdThinfilmRaw(const uint8_t *resp, uint16_t respLen) {
} }
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) { if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
b = (uint16_t)(AT91C_BASE_SSC->SSC_RHR); b = (uint8_t)(AT91C_BASE_SSC->SSC_RHR);
(void)b; (void)b;
} }
if (BUTTON_PRESS()) break; if (BUTTON_PRESS()) break;
@ -121,13 +121,12 @@ static int EmSendCmdThinfilmRaw(const uint8_t *resp, uint16_t respLen) {
} }
void SimulateThinFilm(uint8_t *data, size_t len) { void SimulateThinFilm(uint8_t *data, size_t len) {
Dbprintf("Simulate %i-bit Thinfilm tag", len * 8);
Dbhexdump(len, data, true);
int16_t status = PM3_SUCCESS;
CodeThinfilmAsTag(data, len);
FpgaDownloadAndGo(FPGA_BITSTREAM_HF); FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
Dbprintf("Simulate " _YELLOW_("%i-bit Thinfilm") " tag", len * 8);
Dbhexdump(len, data, true);
// Set up the synchronous serial port // Set up the synchronous serial port
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER); FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
@ -136,29 +135,38 @@ void SimulateThinFilm(uint8_t *data, size_t len) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_TAGSIM_MOD); FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_TAGSIM_MOD);
SpinDelay(100); SpinDelay(100);
// Start the timer
StartCountSspClk();
uint16_t hf_baseline = ReadReaderField(); uint16_t hf_baseline = ReadReaderField();
tosend_t *ts = get_tosend(); int16_t status = PM3_SUCCESS;
CodeThinfilmAsTag(data, len);
// Start the timer tosend_t *ts = get_tosend();
StartCountSspClk();
bool reader_detected = false; bool reader_detected = false;
LED_A_ON(); LED_A_ON();
for (;;) { for (;;) {
WDT_HIT(); WDT_HIT();
if (BUTTON_PRESS() || data_available()) { if (BUTTON_PRESS() || data_available()) {
status = PM3_EOPABORTED; status = PM3_EOPABORTED;
break; break;
} }
uint16_t hf_av = ReadReaderField(); uint16_t hf_av = ReadReaderField();
if (hf_av < hf_baseline)
if (hf_av < hf_baseline) {
hf_baseline = hf_av; hf_baseline = hf_av;
}
if (hf_av > hf_baseline + 10) { if (hf_av > hf_baseline + 10) {
EmSendCmdThinfilmRaw(ts->buf, ts->max); EmSendCmdThinfilmRaw(ts->buf, ts->max);
if (!reader_detected) {
if (reader_detected == false) {
LED_B_ON(); LED_B_ON();
//Dbprintf("Reader detected, start beaming data"); //Dbprintf("Reader detected, start beaming data");
reader_detected = true; reader_detected = true;
@ -166,7 +174,7 @@ void SimulateThinFilm(uint8_t *data, size_t len) {
} else { } else {
if (reader_detected) { if (reader_detected) {
LED_B_OFF(); LED_B_OFF();
//Dbprintf("Reader gone, stop beaming data"); // Dbprintf("Reader gone, stop beaming data");
reader_detected = false; reader_detected = false;
} }
} }