From: Martin Holst Swende Date: Sun, 14 Jun 2015 07:02:13 +0000 (+0200) Subject: Merge pull request #115 from marshmellow42/master X-Git-Tag: v2.1.0~4 X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/0f5b97d92cfd4e7a33eb79a226831753812c4ed5?hp=8e2e6c8eb0b762bba6e7cad2d257a219a51390ae Merge pull request #115 from marshmellow42/master add-ons and bug fixes --- diff --git a/COMPILING.txt b/COMPILING.txt index c894f0ff..1cc34a0f 100644 --- a/COMPILING.txt +++ b/COMPILING.txt @@ -81,7 +81,31 @@ Download the ProxSpace environment archive and extract it to C:\ = Mac OS X = ============ -macport stuff should do ;) +Tested on OSX 10.10 Yosemite + +1 - Install Xcode and Xcode Command Line Tools + +2 - Install Homebrew and dependencies + brew install readline + brew instal libusb + +3 - Download DevKitARM for OSX + http://sourceforge.net/projects/devkitpro/files/devkitARM/devkitARM_r44/ + Unpack devkitARM_r44-osx.tar.bz2 to proxmark3 directory. + +4 - Edit proxmark3/client/Makefile adding path to readline + + LDLIBS = -L/usr/local/Cellar/readline/6.3.8/lib/ -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lreadline -lpthread -lm + CFLAGS = -std=c99 -I/usr/local/Cellar/readline/6.3.8/include/ -I. -I../include -I../common -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4 + + Replace path /usr/local/Cellar/readline/6.3.8 with your actuall readline path. See homebrew manuals. + +5 - Set Environment + + export DEVKITPRO=$HOME/proxmark3/ + export DEVKITARM=$DEVKITPRO/devkitARM + export PATH=${PATH}:${DEVKITARM}/bin + ============ = Linux = diff --git a/armsrc/iso14443.c b/armsrc/iso14443.c index c7f49f14..c202e312 100644 --- a/armsrc/iso14443.c +++ b/armsrc/iso14443.c @@ -24,6 +24,9 @@ #define TAG_READER_BUFFER_SIZE 2048 #define DEMOD_DMA_BUFFER_SIZE 1024 */ + +#define RECEIVE_SAMPLES_TIMEOUT 2000 + //============================================================================= // An ISO 14443 Type B tag. We listen for commands from the reader, using // a UART kind of thing that's implemented in software. When we get a @@ -658,9 +661,6 @@ static void GetSamplesFor14443Demod(int weTx, int n, int quiet) // free all previous allocations first BigBuf_free(); - // The command (reader -> tag) that we're receiving. - uint8_t *receivedCmd = BigBuf_malloc(MAX_FRAME_SIZE); - // The response (tag -> reader) that we're receiving. uint8_t *receivedResponse = BigBuf_malloc(MAX_FRAME_SIZE); @@ -669,8 +669,6 @@ static void GetSamplesFor14443Demod(int weTx, int n, int quiet) // Set up the demodulator for tag -> reader responses. DemodInit(receivedResponse); - // Set up the demodulator for the reader -> tag commands - UartInit(receivedCmd); // Setup and start DMA. FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE); @@ -695,8 +693,8 @@ static void GetSamplesFor14443Demod(int weTx, int n, int quiet) ci = upTo[0]; cq = upTo[1]; upTo += 2; - if(upTo - dmaBuf > DMA_BUFFER_SIZE) { - upTo -= DMA_BUFFER_SIZE; + if(upTo >= dmaBuf + DMA_BUFFER_SIZE) { + upTo = dmaBuf; AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) upTo; AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE; } @@ -707,15 +705,12 @@ static void GetSamplesFor14443Demod(int weTx, int n, int quiet) samples += 2; - Handle14443UartBit(1); - Handle14443UartBit(1); - if(Handle14443SamplesDemod(ci, cq)) { gotFrame = 1; } } - if(samples > 2000) { + if(samples > n) { break; } } @@ -724,8 +719,8 @@ static void GetSamplesFor14443Demod(int weTx, int n, int quiet) //Tracing if (tracing && Demod.len > 0) { uint8_t parity[MAX_PARITY_SIZE]; - GetParity(Demod.output , Demod.len, parity); - LogTrace(Demod.output,Demod.len, 0, 0, parity, FALSE); + GetParity(Demod.output, Demod.len, parity); + LogTrace(Demod.output, Demod.len, 0, 0, parity, FALSE); } } @@ -934,7 +929,7 @@ void ReadSTMemoryIso14443(uint32_t dwLast) CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1)); // LED_A_ON(); - GetSamplesFor14443Demod(TRUE, 2000,TRUE); + GetSamplesFor14443Demod(TRUE, RECEIVE_SAMPLES_TIMEOUT, TRUE); // LED_A_OFF(); if (Demod.len == 0) { @@ -952,7 +947,7 @@ void ReadSTMemoryIso14443(uint32_t dwLast) CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1)); // LED_A_ON(); - GetSamplesFor14443Demod(TRUE, 2000,TRUE); + GetSamplesFor14443Demod(TRUE, RECEIVE_SAMPLES_TIMEOUT, TRUE); // LED_A_OFF(); if (Demod.len != 3) { Dbprintf("Expected 3 bytes from tag, got %d", Demod.len); @@ -976,7 +971,7 @@ void ReadSTMemoryIso14443(uint32_t dwLast) CodeAndTransmit14443bAsReader(cmd1, 3); // Only first three bytes for this one // LED_A_ON(); - GetSamplesFor14443Demod(TRUE, 2000,TRUE); + GetSamplesFor14443Demod(TRUE, RECEIVE_SAMPLES_TIMEOUT, TRUE); // LED_A_OFF(); if (Demod.len != 10) { Dbprintf("Expected 10 bytes from tag, got %d", Demod.len); @@ -1008,7 +1003,7 @@ void ReadSTMemoryIso14443(uint32_t dwLast) CodeAndTransmit14443bAsReader(cmd1, sizeof(cmd1)); // LED_A_ON(); - GetSamplesFor14443Demod(TRUE, 2000,TRUE); + GetSamplesFor14443Demod(TRUE, RECEIVE_SAMPLES_TIMEOUT, TRUE); // LED_A_OFF(); if (Demod.len != 6) { // Check if we got an answer from the tag DbpString("Expected 6 bytes from tag, got less..."); @@ -1118,10 +1113,10 @@ void RAMFUNC SnoopIso14443(void) cq = upTo[1]; upTo += 2; lastRxCounter -= 2; - if(upTo - dmaBuf > DMA_BUFFER_SIZE) { - upTo -= DMA_BUFFER_SIZE; + if(upTo >= dmaBuf + DMA_BUFFER_SIZE) { + upTo = dmaBuf; lastRxCounter += DMA_BUFFER_SIZE; - AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) upTo; + AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dmaBuf; AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE; } @@ -1237,8 +1232,8 @@ void SendRawCommand14443B(uint32_t datalen, uint32_t recv,uint8_t powerfield, ui if(recv) { + GetSamplesFor14443Demod(TRUE, RECEIVE_SAMPLES_TIMEOUT, TRUE); uint16_t iLen = MIN(Demod.len,USB_CMD_DATA_SIZE); - GetSamplesFor14443Demod(TRUE, 2000, TRUE); cmd_send(CMD_ACK,iLen,0,0,Demod.output,iLen); } if(!powerfield) diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 2b5a5b87..5abda060 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -1750,10 +1750,13 @@ int CmdHF14AMfCSave(const char *Cmd) { // get filename if (mfCGetBlock(0, buf, CSETBLOCK_SINGLE_OPER)) { PrintAndLog("Cant get block: %d", 0); - return 1; + len = sprintf(fnameptr, "dump"); + fnameptr += len; + } + else { + for (j = 0; j < 7; j++, fnameptr += 2) + sprintf(fnameptr, "%02x", buf[j]); } - for (j = 0; j < 7; j++, fnameptr += 2) - sprintf(fnameptr, "%02x", buf[j]); } else { memcpy(filename, Cmd, len); fnameptr += len;