ADD: There were lot of calls to enable tracing, but very few to turn it of afterwards in the methods.

Don't know if it has some influence but can't hurt calling  "set_tracing(FALSE);"  when method returns.
This commit is contained in:
iceman1001 2015-10-11 19:14:17 +02:00
commit 5ee53a0e75
8 changed files with 96 additions and 67 deletions

View file

@ -907,7 +907,7 @@ void SnoopHitag(uint32_t type) {
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS; AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LED_A_OFF(); LED_A_OFF();
set_tracing(TRUE);
// Dbprintf("frame received: %d",frame_count); // Dbprintf("frame received: %d",frame_count);
// Dbprintf("Authentication Attempts: %d",(auth_table_len/8)); // Dbprintf("Authentication Attempts: %d",(auth_table_len/8));
// DbpString("All done"); // DbpString("All done");
@ -1096,7 +1096,7 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
DbpString("Sim Stopped"); DbpString("Sim Stopped");
set_tracing(TRUE);
} }
void ReaderHitag(hitag_function htf, hitag_data* htd) { void ReaderHitag(hitag_function htf, hitag_data* htd) {
@ -1168,6 +1168,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
default: { default: {
Dbprintf("Error, unknown function: %d",htf); Dbprintf("Error, unknown function: %d",htf);
set_tracing(FALSE);
return; return;
} break; } break;
} }
@ -1235,6 +1236,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
DbpString("Configured for hitag2 reader"); DbpString("Configured for hitag2 reader");
} else { } else {
Dbprintf("Error, unknown hitag reader type: %d",htf); Dbprintf("Error, unknown hitag reader type: %d",htf);
set_tracing(FALSE);
return; return;
} }
@ -1274,6 +1276,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
} break; } break;
default: { default: {
Dbprintf("Error, unknown function: %d",htf); Dbprintf("Error, unknown function: %d",htf);
set_tracing(FALSE);
return; return;
} break; } break;
} }
@ -1381,7 +1384,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS; AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS; AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
Dbprintf("frame received: %d",frame_count); Dbprintf("DONE: frame received: %d",frame_count);
DbpString("All done");
cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48); cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48);
set_tracing(FALSE);
} }

View file

@ -816,6 +816,7 @@ done:
LED_B_OFF(); LED_B_OFF();
LED_C_OFF(); LED_C_OFF();
LED_D_OFF(); LED_D_OFF();
set_tracing(FALSE);
} }
void rotateCSN(uint8_t* originalCSN, uint8_t* rotatedCSN) { void rotateCSN(uint8_t* originalCSN, uint8_t* rotatedCSN) {
@ -1040,7 +1041,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
Dbprintf("The mode is not implemented, reserved for future use"); Dbprintf("The mode is not implemented, reserved for future use");
} }
Dbprintf("Done..."); Dbprintf("Done...");
set_tracing(FALSE);
} }
void AppendCrc(uint8_t* data, int len) void AppendCrc(uint8_t* data, int len)
{ {
@ -1760,17 +1761,18 @@ void ReaderIClass(uint8_t arg0) {
cmd_send(CMD_ACK,result_status,0,0,card_data,sizeof(card_data)); cmd_send(CMD_ACK,result_status,0,0,card_data,sizeof(card_data));
if(abort_after_read) { if(abort_after_read) {
LED_A_OFF(); LED_A_OFF();
set_tracing(FALSE);
return; return;
} }
//Save that we already sent this.... //Save that we already sent this....
memcpy(last_csn, card_data, 8); memcpy(last_csn, card_data, 8);
} }
} }
LED_B_OFF(); LED_B_OFF();
} }
cmd_send(CMD_ACK,0,0,0,card_data, 0); cmd_send(CMD_ACK,0,0,0,card_data, 0);
LED_A_OFF(); LED_A_OFF();
set_tracing(FALSE);
} }
void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
@ -1881,7 +1883,6 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
stored_data_length = 0; stored_data_length = 0;
failedRead = 0; failedRead = 0;
} }
} else { } else {
failedRead = 1; failedRead = 1;
stored_data_length +=8;//Otherwise, data becomes misaligned stored_data_length +=8;//Otherwise, data becomes misaligned
@ -1909,6 +1910,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
card_data, 0); card_data, 0);
LED_A_OFF(); LED_A_OFF();
set_tracing(FALSE);
} }
void iClass_ReadCheck(uint8_t blockNo, uint8_t keyType) { void iClass_ReadCheck(uint8_t blockNo, uint8_t keyType) {

View file

@ -718,6 +718,8 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
Dbprintf("maxDataLen=%d, Uart.state=%x, Uart.len=%d", maxDataLen, Uart.state, Uart.len); Dbprintf("maxDataLen=%d, Uart.state=%x, Uart.len=%d", maxDataLen, Uart.state, Uart.len);
Dbprintf("traceLen=%d, Uart.output[0]=%08x", BigBuf_get_traceLen(), (uint32_t)Uart.output[0]); Dbprintf("traceLen=%d, Uart.output[0]=%08x", BigBuf_get_traceLen(), (uint32_t)Uart.output[0]);
set_tracing(FALSE);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1415,6 +1417,7 @@ void SimulateIso14443aTag(int tagType, int flags, byte_t* data)
} }
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
set_tracing(FALSE);
BigBuf_free_keep_EM(); BigBuf_free_keep_EM();
LED_A_OFF(); LED_A_OFF();
@ -2180,6 +2183,7 @@ void ReaderIso14443a(UsbCommand *c)
} }
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
set_tracing(FALSE);
LEDsoff(); LEDsoff();
} }
@ -3029,6 +3033,8 @@ void Mifare1ksim(uint8_t flags, uint8_t exitAfterNReads, uint8_t arg2, uint8_t *
} }
} }
if (MF_DBGLEVEL >= 1) Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", tracing, BigBuf_get_traceLen()); if (MF_DBGLEVEL >= 1) Dbprintf("Emulator stopped. Tracing: %d trace length: %d ", tracing, BigBuf_get_traceLen());
set_tracing(FALSE);
} }
@ -3187,4 +3193,5 @@ void RAMFUNC SniffMifare(uint8_t param) {
MfSniffEnd(); MfSniffEnd();
LEDsoff(); LEDsoff();
Dbprintf("maxDataLen=%x, Uart.state=%x, Uart.len=%x", maxDataLen, Uart.state, Uart.len); Dbprintf("maxDataLen=%x, Uart.state=%x, Uart.len=%x", maxDataLen, Uart.state, Uart.len);
set_tracing(FALSE);
} }

View file

@ -479,6 +479,7 @@ void SimulateIso14443bTag(void)
if (tracing) LogTrace(resp, respLen, 0, 0, parity, FALSE); if (tracing) LogTrace(resp, respLen, 0, 0, parity, FALSE);
} }
FpgaDisableSscDma(); FpgaDisableSscDma();
set_tracing(FALSE);
} }
//============================================================================= //=============================================================================
@ -1058,6 +1059,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
if (Demod.len == 0) { if (Demod.len == 0) {
DbpString("No response from tag"); DbpString("No response from tag");
set_tracing(FALSE);
return; return;
} else { } else {
Dbprintf("Randomly generated Chip ID (+ 2 byte CRC): %02x %02x %02x", Dbprintf("Randomly generated Chip ID (+ 2 byte CRC): %02x %02x %02x",
@ -1073,17 +1075,20 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE); GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
if (Demod.len != 3) { if (Demod.len != 3) {
Dbprintf("Expected 3 bytes from tag, got %d", Demod.len); Dbprintf("Expected 3 bytes from tag, got %d", Demod.len);
set_tracing(FALSE);
return; return;
} }
// Check the CRC of the answer: // Check the CRC of the answer:
ComputeCrc14443(CRC_14443_B, Demod.output, 1 , &cmd1[2], &cmd1[3]); ComputeCrc14443(CRC_14443_B, Demod.output, 1 , &cmd1[2], &cmd1[3]);
if(cmd1[2] != Demod.output[1] || cmd1[3] != Demod.output[2]) { if(cmd1[2] != Demod.output[1] || cmd1[3] != Demod.output[2]) {
DbpString("CRC Error reading select response."); DbpString("CRC Error reading select response.");
set_tracing(FALSE);
return; return;
} }
// Check response from the tag: should be the same UID as the command we just sent: // Check response from the tag: should be the same UID as the command we just sent:
if (cmd1[1] != Demod.output[0]) { if (cmd1[1] != Demod.output[0]) {
Dbprintf("Bad response to SELECT from Tag, aborting: %02x %02x", cmd1[1], Demod.output[0]); Dbprintf("Bad response to SELECT from Tag, aborting: %02x %02x", cmd1[1], Demod.output[0]);
set_tracing(FALSE);
return; return;
} }
@ -1095,6 +1100,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE); GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE);
if (Demod.len != 10) { if (Demod.len != 10) {
Dbprintf("Expected 10 bytes from tag, got %d", Demod.len); Dbprintf("Expected 10 bytes from tag, got %d", Demod.len);
set_tracing(FALSE);
return; return;
} }
// The check the CRC of the answer (use cmd1 as temporary variable): // The check the CRC of the answer (use cmd1 as temporary variable):
@ -1142,6 +1148,8 @@ void ReadSTMemoryIso14443b(uint32_t dwLast)
} }
i++; i++;
} }
set_tracing(FALSE);
} }
@ -1290,11 +1298,12 @@ void RAMFUNC SnoopIso14443b(void)
} }
TagIsActive = (Demod.state > DEMOD_GOT_FALLING_EDGE_OF_SOF); TagIsActive = (Demod.state > DEMOD_GOT_FALLING_EDGE_OF_SOF);
} }
} }
FpgaDisableSscDma(); FpgaDisableSscDma();
LEDsoff(); LEDsoff();
set_tracing(FALSE);
AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS; AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS;
DbpString("Snoop statistics:"); DbpString("Snoop statistics:");
Dbprintf(" Max behind by: %i", maxBehindBy); Dbprintf(" Max behind by: %i", maxBehindBy);
@ -1337,6 +1346,7 @@ void SendRawCommand14443B(uint32_t datalen, uint32_t recv, uint8_t powerfield, u
if(!powerfield) { if(!powerfield) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
FpgaDisableSscDma(); FpgaDisableSscDma();
set_tracing(FALSE);
LED_D_OFF(); LED_D_OFF();
} }
} }

View file

@ -723,7 +723,6 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
dmax = davg + 2; dmax = davg + 2;
LED_B_OFF(); LED_B_OFF();
} }
// ------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------
@ -815,6 +814,7 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -879,6 +879,7 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
// restore debug level // restore debug level
MF_DBGLEVEL = OLD_MF_DBGLEVEL; MF_DBGLEVEL = OLD_MF_DBGLEVEL;
@ -946,7 +947,7 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
clear_trace(); clear_trace();
set_tracing(false); set_tracing(TRUE);
bool isOK = true; bool isOK = true;
@ -1002,6 +1003,7 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
if (MF_DBGLEVEL >= 2) DbpString("EMUL FILL SECTORS FINISHED"); if (MF_DBGLEVEL >= 2) DbpString("EMUL FILL SECTORS FINISHED");
set_tracing(FALSE);
} }
@ -1128,6 +1130,7 @@ void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
if ((workFlags & 0x10) || (!isOK)) { if ((workFlags & 0x10) || (!isOK)) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
} }
} }
@ -1210,6 +1213,7 @@ void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
if ((workFlags & 0x10) || (!isOK)) { if ((workFlags & 0x10) || (!isOK)) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
} }
} }
@ -1265,7 +1269,6 @@ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
clear_trace(); clear_trace();
set_tracing(TRUE); set_tracing(TRUE);
for (int i = 0; i < iterations; i++) { for (int i = 0; i < iterations; i++) {
WDT_HIT(); WDT_HIT();
@ -1308,6 +1311,7 @@ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
} }
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
} }
// //

View file

@ -494,6 +494,7 @@ void OnSuccess(){
ReaderTransmit(deselect_cmd, 3 , NULL); ReaderTransmit(deselect_cmd, 3 , NULL);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
} }
void OnError(uint8_t reason){ void OnError(uint8_t reason){
@ -503,4 +504,5 @@ void OnError(uint8_t reason){
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
cmd_send(CMD_ACK,0,reason,0,0,0); cmd_send(CMD_ACK,0,reason,0,0,0);
LEDsoff(); LEDsoff();
set_tracing(FALSE);
} }

View file

@ -204,10 +204,11 @@ void UsbCommandReceived(UsbCommand *UC)
return; return;
} break; } break;
default: default: {
storeCommand(UC); storeCommand(UC);
break; break;
} }
}
} }