From: marshmellow42 Date: Sat, 20 Feb 2016 15:07:44 +0000 (-0500) Subject: move the clear buffer outside of potentially time.. X-Git-Tag: v2.3.0~4^2~3 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/3cec706139a331d4405db6a7d71e17e0a1573c20?hp=-c move the clear buffer outside of potentially time.. ... sensitive routines see http://www.proxmark.org/forum/viewtopic.php?id=2820 --- 3cec706139a331d4405db6a7d71e17e0a1573c20 diff --git a/armsrc/BigBuf.c b/armsrc/BigBuf.c index da3b0ce2..851cf390 100644 --- a/armsrc/BigBuf.c +++ b/armsrc/BigBuf.c @@ -61,6 +61,10 @@ void BigBuf_Clear_ext(bool verbose) Dbprintf("Buffer cleared (%i bytes)",BIGBUF_SIZE); } +void BigBuf_Clear_keep_EM(void) +{ + memset(BigBuf,0,BigBuf_hi); +} // allocate a chunk of memory from BigBuf. We allocate high memory first. The unallocated memory // at the beginning of BigBuf is always for traces/samples diff --git a/armsrc/BigBuf.h b/armsrc/BigBuf.h index 13432e7e..11e02c7a 100644 --- a/armsrc/BigBuf.h +++ b/armsrc/BigBuf.h @@ -26,6 +26,7 @@ extern uint8_t *BigBuf_get_EM_addr(void); extern uint16_t BigBuf_max_traceLen(void); extern void BigBuf_Clear(void); extern void BigBuf_Clear_ext(bool verbose); +extern void BigBuf_Clear_keep_EM(void); extern uint8_t *BigBuf_malloc(uint16_t); extern void BigBuf_free(void); extern void BigBuf_free_keep_EM(void); diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 47fec7c2..bb298f79 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -37,6 +37,8 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint sample_config sc = { 0,0,1, divisor_used, 0}; setSamplingConfig(&sc); + //clear read buffer + BigBuf_Clear_keep_EM(void); /* Make sure the tag is reset */ FpgaDownloadAndGo(FPGA_BITSTREAM_LF); @@ -752,6 +754,9 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol) // Configure to go in 125Khz listen mode LFSetupFPGAForADC(95, true); + //clear read buffer + BigBuf_Clear_keep_EM(void); + while(!BUTTON_PRESS() && !usb_poll_validate_length()) { WDT_HIT(); @@ -837,6 +842,8 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol) uint8_t *dest = BigBuf_get_addr(); size_t size; int idx=0; + //clear read buffer + BigBuf_Clear_keep_EM(void); // Configure to go in 125Khz listen mode LFSetupFPGAForADC(95, true); @@ -927,6 +934,8 @@ void CmdEM410xdemod(int findone, int *high, int *low, int ledcontrol) int clk=0, invert=0, errCnt=0, maxErr=20; uint32_t hi=0; uint64_t lo=0; + //clear read buffer + BigBuf_Clear_keep_EM(void); // Configure to go in 125Khz listen mode LFSetupFPGAForADC(95, true); @@ -986,6 +995,8 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol) uint8_t version=0; uint8_t facilitycode=0; uint16_t number=0; + //clear read buffer + BigBuf_Clear_keep_EM(void); // Configure to go in 125Khz listen mode LFSetupFPGAForADC(95, true); diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index ab7c79dd..88df543f 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -124,7 +124,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag uint8_t *dest = BigBuf_get_addr(); int bufsize = BigBuf_max_traceLen(); - memset(dest, 0, bufsize); + //memset(dest, 0, bufsize); //creates issues with cmdread (marshmellow) if(bits_per_sample < 1) bits_per_sample = 1; if(bits_per_sample > 8) bits_per_sample = 8; diff --git a/armsrc/pcf7931.c b/armsrc/pcf7931.c index 3093a5e5..73f18768 100644 --- a/armsrc/pcf7931.c +++ b/armsrc/pcf7931.c @@ -29,6 +29,8 @@ int DemodPCF7931(uint8_t **outBlocks) { int num_blocks = 0; int lmin=128, lmax=128; uint8_t dir; + //clear read buffer + BigBuf_Clear_keep_EM(void); LFSetupFPGAForADC(95, true); DoAcquisition_default(0, true);