]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Increased buffer sizes for hi14snoop. Added blinking LED for feedback
authordaniel.boteanu <daniel.boteanu@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 9 Jan 2010 15:30:47 +0000 (15:30 +0000)
committerdaniel.boteanu <daniel.boteanu@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 9 Jan 2010 15:30:47 +0000 (15:30 +0000)
armsrc/iso14443.c

index b592742c9935cf7b437c58a89f714fa9d8c56ff6..dc1dbf12ae4d802344e580c3d1e628395318a49f 100644 (file)
 \r
 //static void GetSamplesFor14443(BOOL weTx, int n);\r
 \r
-#define DMA_BUFFER_SIZE 256\r
+#define DEMOD_TRACE_SIZE 4096\r
+#define READER_TAG_BUFFER_SIZE 2048\r
+#define TAG_READER_BUFFER_SIZE 2048\r
+#define DMA_BUFFER_SIZE 1024\r
 \r
 //=============================================================================\r
 // An ISO 14443 Type B tag. We listen for commands from the reader, using\r
@@ -1014,10 +1017,10 @@ void ReadSTMemoryIso14443(DWORD parameter,DWORD dwLast)
 //-----------------------------------------------------------------------------\r
 /*\r
  * Memory usage for this function, (within BigBuf)\r
- * 0-1023 : Demodulated samples receive (1024 bytes)\r
- * 1024-1535 : Last Received command, 512 bytes (reader->tag)\r
- * 1536-2047 : Last Received command, 512 bytes(tag->reader)\r
- * 2048-2304 : DMA Buffer, 256 bytes (samples)\r
+ * 0-4095 : Demodulated samples receive (4096 bytes) - DEMOD_TRACE_SIZE\r
+ * 4096-6143 : Last Received command, 2048 bytes (reader->tag) - READER_TAG_BUFFER_SIZE\r
+ * 6144-8191 : Last Received command, 2048 bytes(tag->reader) - TAG_READER_BUFFER_SIZE\r
+ * 8192-9215 : DMA Buffer, 1024 bytes (samples) - DMA_BUFFER_SIZE\r
  */\r
 void SnoopIso14443(void)\r
 {\r
@@ -1027,9 +1030,9 @@ void SnoopIso14443(void)
     BOOL triggered = FALSE;\r
 \r
     // The command (reader -> tag) that we're working on receiving.\r
-    BYTE *receivedCmd = (BYTE *)(BigBuf) + 1024;\r
+    BYTE *receivedCmd = (BYTE *)(BigBuf) + DEMOD_TRACE_SIZE;\r
     // The response (tag -> reader) that we're working on receiving.\r
-    BYTE *receivedResponse = (BYTE *)(BigBuf) + 1536;\r
+    BYTE *receivedResponse = (BYTE *)(BigBuf) + DEMOD_TRACE_SIZE + READER_TAG_BUFFER_SIZE;\r
 \r
     // As we receive stuff, we copy it from receivedCmd or receivedResponse\r
     // into trace, along with its length and other annotations.\r
@@ -1037,7 +1040,7 @@ void SnoopIso14443(void)
     int traceLen = 0;\r
 \r
     // The DMA buffer, used to stream samples from the FPGA.\r
-    SBYTE *dmaBuf = (SBYTE *)(BigBuf) + 2048;\r
+    SBYTE *dmaBuf = (SBYTE *)(BigBuf) + DEMOD_TRACE_SIZE + READER_TAG_BUFFER_SIZE + TAG_READER_BUFFER_SIZE;\r
     int lastRxCounter;\r
     SBYTE *upTo;\r
     int ci, cq;\r
@@ -1048,7 +1051,7 @@ void SnoopIso14443(void)
     int samples = 0;\r
 \r
     // Initialize the trace buffer\r
-    memset(trace, 0x44, 1024);\r
+    memset(trace, 0x44, DEMOD_TRACE_SIZE);\r
 \r
     // Set up the demodulator for tag -> reader responses.\r
     Demod.output = receivedResponse;\r
@@ -1061,6 +1064,17 @@ void SnoopIso14443(void)
     Uart.byteCntMax = 100;\r
     Uart.state = STATE_UNSYNCD;\r
 \r
+       // Print some debug information about the buffer sizes\r
+       Dbprintf("Snooping buffers initialized:");\r
+       Dbprintf("  Trace: %i bytes", DEMOD_TRACE_SIZE);\r
+       Dbprintf("  Reader -> tag: %i bytes", READER_TAG_BUFFER_SIZE);\r
+       Dbprintf("  tag -> Reader: %i bytes", TAG_READER_BUFFER_SIZE);\r
+       Dbprintf("  DMA: %i bytes", DMA_BUFFER_SIZE);\r
+       \r
+       // Use a counter for blinking the LED\r
+       long ledCount=0;\r
+       long ledFlashAt=200000;\r
+       \r
     // And put the FPGA in the appropriate mode\r
     // Signal field is off with the appropriate LED\r
     LED_D_OFF();\r
@@ -1076,6 +1090,16 @@ void SnoopIso14443(void)
     FpgaSetupSscDma((BYTE *)dmaBuf, DMA_BUFFER_SIZE);\r
     // And now we loop, receiving samples.\r
     for(;;) {\r
+               // Blink the LED while Snooping\r
+               ledCount++;\r
+               if (ledCount == ledFlashAt) {\r
+                       LED_D_ON();\r
+               }\r
+               if (ledCount >= 2*ledFlashAt) {\r
+                       LED_D_OFF();\r
+                       ledCount=0;\r
+               }\r
+               \r
        int behindBy = (lastRxCounter - AT91C_BASE_PDC_SSC->PDC_RCR) &\r
                                 (DMA_BUFFER_SIZE-1);\r
         if(behindBy > maxBehindBy) {\r
@@ -1102,6 +1126,7 @@ void SnoopIso14443(void)
 \r
 #define HANDLE_BIT_IF_BODY \\r
             if(triggered) { \\r
+                               ledFlashAt=30000; \\r
                 trace[traceLen++] = ((samples >>  0) & 0xff); \\r
                 trace[traceLen++] = ((samples >>  8) & 0xff); \\r
                 trace[traceLen++] = ((samples >> 16) & 0xff); \\r
@@ -1151,7 +1176,10 @@ void SnoopIso14443(void)
             trace[traceLen++] = Demod.len;\r
             memcpy(trace+traceLen, receivedResponse, Demod.len);\r
             traceLen += Demod.len;\r
-            if(traceLen > 1000) break;\r
+            if(traceLen > DEMOD_TRACE_SIZE) {          \r
+                               DbpString("Reached trace limit");\r
+                               goto done;\r
+                       }\r
 \r
             triggered = TRUE;\r
 \r
@@ -1168,11 +1196,13 @@ void SnoopIso14443(void)
         }\r
     }\r
 \r
-    DbpString("in done pt");\r
-    Dbprintf("%x %x %x", maxBehindBy, Uart.state, Uart.byteCnt);\r
-    Dbprintf("%x %x %x", Uart.byteCntMax, traceLen, 0x23);\r
-\r
 done:\r
        LED_D_OFF();\r
     AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS;\r
+       DbpString("Snoop statistics:");\r
+    Dbprintf("  Max behind by: %i", maxBehindBy);\r
+       Dbprintf("  Uart State: %x", Uart.state);\r
+       Dbprintf("  Uart ByteCnt: %i", Uart.byteCnt);\r
+       Dbprintf("  Uart ByteCntMax: %i", Uart.byteCntMax);\r
+       Dbprintf("  Trace length: %i", traceLen);\r
 }\r
Impressum, Datenschutz