From: iceman1001 Date: Sun, 11 Oct 2015 17:14:17 +0000 (+0200) Subject: ADD: There were lot of calls to enable tracing, but very few to turn it of afterwar... X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/5ee53a0e75c48de359108f5d21d4b829ed504467 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. --- diff --git a/armsrc/hitag2.c b/armsrc/hitag2.c index 7cc6b964..02dff46e 100644 --- a/armsrc/hitag2.c +++ b/armsrc/hitag2.c @@ -907,7 +907,7 @@ void SnoopHitag(uint32_t type) { AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS; FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LED_A_OFF(); - + set_tracing(TRUE); // Dbprintf("frame received: %d",frame_count); // Dbprintf("Authentication Attempts: %d",(auth_table_len/8)); // DbpString("All done"); @@ -1096,7 +1096,7 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); DbpString("Sim Stopped"); - + set_tracing(TRUE); } void ReaderHitag(hitag_function htf, hitag_data* htd) { @@ -1168,6 +1168,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) { default: { Dbprintf("Error, unknown function: %d",htf); + set_tracing(FALSE); return; } break; } @@ -1217,26 +1218,27 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) { lastbit = 1; bStop = false; - // Tag specific configuration settings (sof, timings, etc.) - if (htf < 10){ - // hitagS settings - reset_sof = 1; - t_wait = 200; - DbpString("Configured for hitagS reader"); - } else if (htf < 20) { - // hitag1 settings - reset_sof = 1; - t_wait = 200; - DbpString("Configured for hitag1 reader"); - } else if (htf < 30) { - // hitag2 settings - reset_sof = 4; - t_wait = HITAG_T_WAIT_2; - DbpString("Configured for hitag2 reader"); + // Tag specific configuration settings (sof, timings, etc.) + if (htf < 10){ + // hitagS settings + reset_sof = 1; + t_wait = 200; + DbpString("Configured for hitagS reader"); + } else if (htf < 20) { + // hitag1 settings + reset_sof = 1; + t_wait = 200; + DbpString("Configured for hitag1 reader"); + } else if (htf < 30) { + // hitag2 settings + reset_sof = 4; + t_wait = HITAG_T_WAIT_2; + DbpString("Configured for hitag2 reader"); } else { - Dbprintf("Error, unknown hitag reader type: %d",htf); - return; - } + Dbprintf("Error, unknown hitag reader type: %d",htf); + set_tracing(FALSE); + return; + } while(!bStop && !BUTTON_PRESS()) { // Watchdog hit @@ -1274,6 +1276,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) { } break; default: { Dbprintf("Error, unknown function: %d",htf); + set_tracing(FALSE); return; } break; } @@ -1381,7 +1384,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) { AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS; AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS; FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - Dbprintf("frame received: %d",frame_count); - DbpString("All done"); - cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48); -} + Dbprintf("DONE: frame received: %d",frame_count); + cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48); + set_tracing(FALSE); +} \ No newline at end of file diff --git a/armsrc/iclass.c b/armsrc/iclass.c index 9046d51b..38ccf5a4 100644 --- a/armsrc/iclass.c +++ b/armsrc/iclass.c @@ -816,6 +816,7 @@ done: LED_B_OFF(); LED_C_OFF(); LED_D_OFF(); + set_tracing(FALSE); } 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("Done..."); - + set_tracing(FALSE); } 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)); if(abort_after_read) { LED_A_OFF(); + set_tracing(FALSE); return; } - //Save that we already sent this.... - memcpy(last_csn, card_data, 8); + //Save that we already sent this.... + memcpy(last_csn, card_data, 8); } - } LED_B_OFF(); } cmd_send(CMD_ACK,0,0,0,card_data, 0); LED_A_OFF(); + set_tracing(FALSE); } void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { @@ -1818,20 +1820,20 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { uint8_t read_status = handshakeIclassTag(card_data); if(read_status < 2) continue; - //for now replay captured auth (as cc not updated) - memcpy(check+5,MAC,4); + //for now replay captured auth (as cc not updated) + memcpy(check+5,MAC,4); if(!sendCmdGetResponseWithRetries(check, sizeof(check),resp, 4, 5)) { - Dbprintf("Error: Authentication Fail!"); + Dbprintf("Error: Authentication Fail!"); continue; - } + } //first get configuration block (block 1) crc = block_crc_LUT[1]; - read[1]=1; - read[2] = crc >> 8; - read[3] = crc & 0xff; + read[1]=1; + read[2] = crc >> 8; + read[3] = crc & 0xff; if(!sendCmdGetResponseWithRetries(read, sizeof(read),resp, 10, 10)) { @@ -1839,12 +1841,12 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { continue; } - mem=resp[5]; - memory.k16= (mem & 0x80); - memory.book= (mem & 0x20); - memory.k2= (mem & 0x8); - memory.lockauth= (mem & 0x2); - memory.keyaccess= (mem & 0x1); + mem=resp[5]; + memory.k16= (mem & 0x80); + memory.book= (mem & 0x20); + memory.k2= (mem & 0x8); + memory.lockauth= (mem & 0x2); + memory.keyaccess= (mem & 0x1); cardsize = memory.k16 ? 255 : 32; WDT_HIT(); @@ -1857,15 +1859,15 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { read[1]= block; crc = block_crc_LUT[block]; - read[2] = crc >> 8; - read[3] = crc & 0xff; + read[2] = crc >> 8; + read[3] = crc & 0xff; if(sendCmdGetResponseWithRetries(read, sizeof(read), resp, 10, 10)) { - Dbprintf(" %02x: %02x %02x %02x %02x %02x %02x %02x %02x", - block, resp[0], resp[1], resp[2], - resp[3], resp[4], resp[5], - resp[6], resp[7]); + Dbprintf(" %02x: %02x %02x %02x %02x %02x %02x %02x %02x", + block, resp[0], resp[1], resp[2], + resp[3], resp[4], resp[5], + resp[6], resp[7]); //Fill up the buffer memcpy(card_data+stored_data_length,resp,8); @@ -1881,8 +1883,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { stored_data_length = 0; failedRead = 0; } - - }else{ + } else { failedRead = 1; stored_data_length +=8;//Otherwise, data becomes misaligned Dbprintf("Failed to dump block %d", block); @@ -1909,6 +1910,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) { card_data, 0); LED_A_OFF(); + set_tracing(FALSE); } void iClass_ReadCheck(uint8_t blockNo, uint8_t keyType) { diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 492e2d6d..22ada94f 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -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("traceLen=%d, Uart.output[0]=%08x", BigBuf_get_traceLen(), (uint32_t)Uart.output[0]); + + set_tracing(FALSE); } //----------------------------------------------------------------------------- @@ -1415,13 +1417,14 @@ void SimulateIso14443aTag(int tagType, int flags, byte_t* data) } FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + set_tracing(FALSE); BigBuf_free_keep_EM(); LED_A_OFF(); if (MF_DBGLEVEL >= 4){ - Dbprintf("-[ Wake ups after halt [%d]", happened); - Dbprintf("-[ Messages after halt [%d]", happened2); - Dbprintf("-[ Num of received cmd [%d]", cmdsRecvd); + Dbprintf("-[ Wake ups after halt [%d]", happened); + Dbprintf("-[ Messages after halt [%d]", happened2); + Dbprintf("-[ Num of received cmd [%d]", cmdsRecvd); } } @@ -2180,6 +2183,7 @@ void ReaderIso14443a(UsbCommand *c) } FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + set_tracing(FALSE); 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()); + + set_tracing(FALSE); } @@ -3187,4 +3193,5 @@ void RAMFUNC SniffMifare(uint8_t param) { MfSniffEnd(); LEDsoff(); Dbprintf("maxDataLen=%x, Uart.state=%x, Uart.len=%x", maxDataLen, Uart.state, Uart.len); + set_tracing(FALSE); } diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index 0ea66a8d..0b9962e1 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -479,6 +479,7 @@ void SimulateIso14443bTag(void) if (tracing) LogTrace(resp, respLen, 0, 0, parity, FALSE); } FpgaDisableSscDma(); + set_tracing(FALSE); } //============================================================================= @@ -1058,6 +1059,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast) if (Demod.len == 0) { DbpString("No response from tag"); + set_tracing(FALSE); return; } else { 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); if (Demod.len != 3) { Dbprintf("Expected 3 bytes from tag, got %d", Demod.len); + set_tracing(FALSE); return; } // Check the CRC of the answer: ComputeCrc14443(CRC_14443_B, Demod.output, 1 , &cmd1[2], &cmd1[3]); if(cmd1[2] != Demod.output[1] || cmd1[3] != Demod.output[2]) { DbpString("CRC Error reading select response."); + set_tracing(FALSE); return; } // Check response from the tag: should be the same UID as the command we just sent: if (cmd1[1] != Demod.output[0]) { Dbprintf("Bad response to SELECT from Tag, aborting: %02x %02x", cmd1[1], Demod.output[0]); + set_tracing(FALSE); return; } @@ -1095,6 +1100,7 @@ void ReadSTMemoryIso14443b(uint32_t dwLast) GetSamplesFor14443bDemod(RECEIVE_SAMPLES_TIMEOUT, TRUE); if (Demod.len != 10) { Dbprintf("Expected 10 bytes from tag, got %d", Demod.len); + set_tracing(FALSE); return; } // The check the CRC of the answer (use cmd1 as temporary variable): @@ -1142,6 +1148,8 @@ void ReadSTMemoryIso14443b(uint32_t dwLast) } i++; } + + set_tracing(FALSE); } @@ -1290,11 +1298,12 @@ void RAMFUNC SnoopIso14443b(void) } TagIsActive = (Demod.state > DEMOD_GOT_FALLING_EDGE_OF_SOF); } - } FpgaDisableSscDma(); LEDsoff(); + set_tracing(FALSE); + AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS; DbpString("Snoop statistics:"); Dbprintf(" Max behind by: %i", maxBehindBy); @@ -1337,6 +1346,7 @@ void SendRawCommand14443B(uint32_t datalen, uint32_t recv, uint8_t powerfield, u if(!powerfield) { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaDisableSscDma(); + set_tracing(FALSE); LED_D_OFF(); } } diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index aa4a57fc..928439aa 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -689,8 +689,8 @@ void RecordRawAdcSamplesIso15693(void) FpgaSetupSsc(); // Start from off (no field generated) - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - SpinDelay(200); + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + SpinDelay(200); SetAdcMuxFor(GPIO_MUXSEL_HIPKD); @@ -1022,8 +1022,8 @@ void ReaderIso15693(uint32_t parameter) FpgaSetupSsc(); // Start from off (no field generated) - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - SpinDelay(200); + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + SpinDelay(200); // Give the tags time to energize FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR); @@ -1124,7 +1124,7 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid) FpgaSetupSsc(); // Start from off (no field generated) - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); SpinDelay(200); LED_A_OFF(); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index f63d754d..0b75ebc3 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -723,7 +723,6 @@ void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t calibrate, uint8_t *dat dmax = davg + 2; 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); LEDsoff(); + set_tracing(FALSE); } //----------------------------------------------------------------------------- @@ -879,7 +879,8 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); - + set_tracing(FALSE); + // restore debug level 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); clear_trace(); - set_tracing(false); + set_tracing(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"); + 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)) { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); 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)) { FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); + set_tracing(FALSE); } } @@ -1261,11 +1265,10 @@ void MifareCollectNonces(uint32_t arg0, uint32_t arg1){ LED_B_OFF(); LED_C_OFF(); -iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); + iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); clear_trace(); set_tracing(TRUE); - - + for (int i = 0; i < iterations; i++) { WDT_HIT(); @@ -1308,6 +1311,7 @@ iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); } FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); + set_tracing(FALSE); } // diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c index 4d68bf5f..b1e035f9 100644 --- a/armsrc/mifaredesfire.c +++ b/armsrc/mifaredesfire.c @@ -494,6 +494,7 @@ void OnSuccess(){ ReaderTransmit(deselect_cmd, 3 , NULL); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); + set_tracing(FALSE); } void OnError(uint8_t reason){ @@ -503,4 +504,5 @@ void OnError(uint8_t reason){ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); cmd_send(CMD_ACK,0,reason,0,0,0); LEDsoff(); + set_tracing(FALSE); } diff --git a/client/cmdmain.c b/client/cmdmain.c index b0e1b2ef..d31147f9 100644 --- a/client/cmdmain.c +++ b/client/cmdmain.c @@ -204,9 +204,10 @@ void UsbCommandReceived(UsbCommand *UC) return; } break; - default: - storeCommand(UC); + default: { + storeCommand(UC); break; + } } }