]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
minor cleanups
authormarshmellow42 <marshmellowrf@gmail.com>
Sun, 1 Nov 2015 03:12:42 +0000 (23:12 -0400)
committermarshmellow42 <marshmellowrf@gmail.com>
Sun, 1 Nov 2015 03:12:42 +0000 (23:12 -0400)
armsrc/appmain.c
armsrc/apps.h
armsrc/lfops.c
armsrc/lfsampling.c
client/cmdlft55xx.c
client/cmdlft55xx.h
common/lfdemod.h
common/protocols.h

index 6e08ba66f2ca2d22d2baeaa5b827a4ffb926afcb..b161043ffabead4c400ef96750fc90b600b15979 100644 (file)
@@ -946,7 +946,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        CmdIOdemodFSK(c->arg[0], 0, 0, 1);
                        break;
                case CMD_IO_CLONE_TAG:
-                       CopyIOtoT55x7(c->arg[0], c->arg[1], c->d.asBytes[0]);
+                       CopyIOtoT55x7(c->arg[0], c->arg[1]);
                        break;
                case CMD_EM410X_DEMOD:
                        CmdEM410xdemod(c->arg[0], 0, 0, 1);
index de32ef54a55c6dc5731714a8f811656342156ab4..563ab3b5023d1bf301154a58c71205203b0c84c4 100644 (file)
@@ -73,7 +73,7 @@ void CmdHIDdemodFSK(int findone, int *high, int *low, int ledcontrol);
 void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol); // Realtime demodulation mode for AWID26
 void CmdEM410xdemod(int findone, int *high, int *low, int ledcontrol);
 void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol);
-void CopyIOtoT55x7(uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an ioProx card to T5557/T5567
+void CopyIOtoT55x7(uint32_t hi, uint32_t lo); // Clone an ioProx card to T5557/T5567
 void SimulateTagLowFrequencyBidir(int divisor, int max_bitlen);
 void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT); // Clone an HID card to T5557/T5567
 void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo);
index ffccff83c07c9fdd6f790f6f49a18f88472f914d..5f21738a23962fe25c634414a6c7364efb13b816 100644 (file)
@@ -1113,6 +1113,9 @@ void T55xxWriteBit(int bit) {
 // Send T5577 reset command then read stream (see if we can identify the start of the stream)
 void T55xxResetRead(void) {
        LED_A_ON();
+       //clear buffer now so it does not interfere with timing later
+       BigBuf_Clear_ext(false);
+
        // Set up FPGA, 125kHz
        LFSetupFPGAForADC(95, true);
 
@@ -1128,7 +1131,7 @@ void T55xxResetRead(void) {
        TurnReadLFOn(READ_GAP);
 
        // Acquisition
-       doT55x7Acquisition(39999);
+       doT55x7Acquisition(BigBuf_max_traceLen());
 
        // Turn the field off
        FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
@@ -1266,7 +1269,7 @@ void T55xxWakeUp(uint32_t Pwd){
 void WriteT55xx(uint32_t *blockdata, uint8_t startblock, uint8_t numblocks) {
        // write last block first and config block last (if included)
        for (uint8_t i = numblocks+startblock; i > startblock; i--) {
-               Dbprintf("write- Blk: %d, d:%08X",i-1,blockdata[i-1]);
+               //Dbprintf("write- Blk: %d, d:%08X",i-1,blockdata[i-1]);
                T55xxWriteBlockExt(blockdata[i-1],i-1,0,0);
        }
 }
@@ -1319,7 +1322,7 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) {
        DbpString("DONE!");
 }
 
-void CopyIOtoT55x7(uint32_t hi, uint32_t lo, uint8_t longFMT) {
+void CopyIOtoT55x7(uint32_t hi, uint32_t lo) {
        uint32_t data[] = {T55x7_BITRATE_RF_64 | T55x7_MODULATION_FSK2a | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo};
 
        LED_D_ON();
index 4a968776a832b93b17ad1a7af9a8938a8cf1d9da..115d4b18ffaba74ef9c5da113cabb5444679375b 100644 (file)
@@ -255,7 +255,7 @@ uint32_t SnoopLF()
 **/
 void doT55x7Acquisition(size_t sample_size) {
 
-       #define T55xx_READ_UPPER_THRESHOLD 128+40  // 50
+       #define T55xx_READ_UPPER_THRESHOLD 128+40  // 40 grph
        #define T55xx_READ_TOL   5
 
        uint8_t *dest = BigBuf_get_addr();
@@ -264,8 +264,6 @@ void doT55x7Acquisition(size_t sample_size) {
        if ( bufsize > sample_size )
                bufsize = sample_size;
 
-       //memset(dest, 0, bufsize);
-               
        uint16_t i = 0;
        bool startFound = false;
        bool highFound = false;
@@ -282,7 +280,7 @@ void doT55x7Acquisition(size_t sample_size) {
                        curSample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
                        LED_D_OFF();
 
-                       // find first high sample
+                       // skip until the first high sample above threshold
                        if (!startFound && curSample > T55xx_READ_UPPER_THRESHOLD) {
                                if (curSample > firstSample) 
                                        firstSample = curSample;
@@ -292,15 +290,17 @@ void doT55x7Acquisition(size_t sample_size) {
                                continue;
                        }
 
-                       // skip until samples begin to change
+                       // skip until first high samples begin to change
                        if (startFound || curSample < firstSample-T55xx_READ_TOL){
-                               if (!startFound) 
+                               // if just found start - recover last sample
+                               if (!startFound) {
                                        dest[i++] = firstSample;
-                               startFound = true;
+                                       startFound = true;
+                               }
+                               // collect samples
                                dest[i++] = curSample;
                                if (i >= bufsize-1) break;
                        }
                }
-               //skipCnt++;
        }
 }
index b11a64945325166b97ad7db941349b6181e197e2..55b4ab65284a8f921f9199fa31f4bce894f810ac 100644 (file)
 // Default configuration\r
 t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00};\r
 \r
+t55xx_conf_block_t Get_t55xx_Config(){\r
+       return config;\r
+}\r
+void Set_t55xx_Config(t55xx_conf_block_t conf){\r
+       config = conf;\r
+}\r
+\r
 int usage_t55xx_config(){\r
        PrintAndLog("Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>]");\r
        PrintAndLog("Options:");\r
@@ -533,7 +540,7 @@ bool tryDetectModulation(){
 bool testModulation(uint8_t mode, uint8_t modread){\r
        switch( mode ){\r
                case DEMOD_FSK:\r
-                       if (modread > 3 && modread < 8) return TRUE;\r
+                       if (modread >= DEMOD_FSK1 && modread <= DEMOD_FSK2a) return TRUE;\r
                        break;\r
                case DEMOD_ASK:\r
                        if (modread == DEMOD_ASK) return TRUE;\r
@@ -1175,7 +1182,7 @@ int CmdResetRead(const char *Cmd) {
                return 0;\r
        }\r
 \r
-       uint8_t got[39999];\r
+       uint8_t got[BIGBUF_SIZE-1];\r
        GetFromBigBuf(got,sizeof(got),0);\r
        WaitForResponse(CMD_ACK,NULL);\r
        setGraphBuf(got, sizeof(got));\r
@@ -1187,12 +1194,12 @@ static command_t CommandTable[] =
   {"help",     CmdHelp,           1, "This help"},\r
   {"config",   CmdT55xxSetConfig, 1, "Set/Get T55XX configuration (modulation, inverted, offset, rate)"},\r
   {"detect",   CmdT55xxDetect,    0, "[1] Try detecting the tag modulation from reading the configuration block."},\r
-  {"read",     CmdT55xxReadBlock, 0, "b <block> p [password] [o] [1] -- Read T55xx block data (page 0) [optional password]"},\r
+  {"read",     CmdT55xxReadBlock, 0, "b <block> p [password] [o] [1] -- Read T55xx block data. Optional [p password], [override], [page1]"},\r
   {"resetread",CmdResetRead,      0, "Send Reset Cmd then lf read the stream to attempt to identify the start of it (needs a demod and/or plot after)"},\r
-  {"write",    CmdT55xxWriteBlock,0, "b <block> d <data> p [password] [1] -- Write T55xx block data (page 0) [optional password]"},\r
+  {"write",    CmdT55xxWriteBlock,0, "b <block> d <data> p [password] [1] -- Write T55xx block data. Optional [p password], [page1]"},\r
   {"trace",    CmdT55xxReadTrace, 0, "[1] Show T55xx traceability data (page 1/ blk 0-1)"},\r
   {"info",     CmdT55xxInfo,      0, "[1] Show T55xx configuration data (page 0/ blk 0)"},\r
-  {"dump",     CmdT55xxDump,      0, "[password] [o] Dump T55xx card block 0-7. [optional password]"},\r
+  {"dump",     CmdT55xxDump,      0, "[password] [o] Dump T55xx card block 0-7. Optional [password], [override]"},\r
   {"special",  special,           0, "Show block changes with 64 different offsets"},\r
   {"wakeup",   CmdT55xxWakeUp,    0, "Send AOR wakeup command"},\r
   {NULL, NULL, 0, NULL}\r
index cd50f99a4574b56885bd491f08b5af3b3a4c1a37..d513407987280dece9cebd78cf8905af3f5c09cb 100644 (file)
@@ -39,6 +39,9 @@ typedef struct {
                RF_128 = 0x07,\r
        } bitrate;\r
 } t55xx_conf_block_t;\r
+t55xx_conf_block_t Get_t55xx_Config();\r
+void Set_t55xx_Config(t55xx_conf_block_t conf);\r
+\r
 \r
 int CmdLFT55XX(const char *Cmd);\r
 int CmdT55xxSetConfig(const char *Cmd);\r
index 17fd3349fbb725706fea1b67adf87fceb0278474..e1a51856e59cf25258425cefafd7bf1633cce78e 100644 (file)
@@ -27,7 +27,6 @@ uint8_t  detectFSKClk(uint8_t *BitStream, size_t size, uint8_t fcHigh, uint8_t f
 int      DetectNRZClock(uint8_t dest[], size_t size, int clock);
 int      DetectPSKClock(uint8_t dest[], size_t size, int clock);
 int      DetectStrongAskClock(uint8_t dest[], size_t size, uint8_t high, uint8_t low);
-uint8_t  Em410xDecode(uint8_t *BitStream, size_t *size, size_t *startIdx, uint32_t *hi, uint64_t *lo);
 int      fskdemod(uint8_t *dest, size_t size, uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow);
 int      getHiLo(uint8_t *BitStream, size_t size, int *high, int *low, uint8_t fuzzHi, uint8_t fuzzLo);
 uint32_t manchesterEncode2Bytes(uint16_t datain);
@@ -42,13 +41,14 @@ void     psk1TOpsk2(uint8_t *BitStream, size_t size);
 size_t   removeParity(uint8_t *BitStream, size_t startIdx, uint8_t pLen, uint8_t pType, size_t bLen);
 
 //tag specific
-int FDXBdemodBI(uint8_t *dest, size_t *size);
 int AWIDdemodFSK(uint8_t *dest, size_t *size);
+uint8_t  Em410xDecode(uint8_t *BitStream, size_t *size, size_t *startIdx, uint32_t *hi, uint64_t *lo);
+int FDXBdemodBI(uint8_t *dest, size_t *size);
 int gProxII_Demod(uint8_t BitStream[], size_t *size);
 int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo);
 int IOdemodFSK(uint8_t *dest, size_t size);
 int indala26decode(uint8_t *bitStream, size_t *size, uint8_t *invert);
-int PyramiddemodFSK(uint8_t *dest, size_t *size);
 int ParadoxdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo);
+int PyramiddemodFSK(uint8_t *dest, size_t *size);
 
 #endif
index 251abd7d60e0c501926f6fd118a93c38046e04b7..d3e5f5d7d17b85f2239e9956692adf51bf55334b 100644 (file)
@@ -198,54 +198,54 @@ void printIclassDumpInfo(uint8_t* iclass_dump);
 void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *max_blk, uint8_t *app_areas, uint8_t *kb);
 
 /* T55x7 configuration register definitions */
-#define T55x7_POR_DELAY                        0x00000001
-#define T55x7_ST_TERMINATOR            0x00000008
-#define T55x7_PWD                      0x00000010
-#define T55x7_MAXBLOCK_SHIFT           5
-#define T55x7_AOR                      0x00000200
-#define T55x7_PSKCF_RF_2               0
-#define T55x7_PSKCF_RF_4               0x00000400
-#define T55x7_PSKCF_RF_8               0x00000800
-#define T55x7_MODULATION_DIRECT                0
-#define T55x7_MODULATION_PSK1          0x00001000
-#define T55x7_MODULATION_PSK2          0x00002000
-#define T55x7_MODULATION_PSK3          0x00003000
-#define T55x7_MODULATION_FSK1          0x00004000
-#define T55x7_MODULATION_FSK2          0x00005000
-#define T55x7_MODULATION_FSK1a         0x00006000
-#define T55x7_MODULATION_FSK2a         0x00007000
-#define T55x7_MODULATION_MANCHESTER    0x00008000
-#define T55x7_MODULATION_BIPHASE       0x00010000
-#define T55x7_MODULATION_DIPHASE       0x00018000
-#define T55x7_BITRATE_RF_8             0
-#define T55x7_BITRATE_RF_16            0x00040000
-#define T55x7_BITRATE_RF_32            0x00080000
-#define T55x7_BITRATE_RF_40            0x000C0000
-#define T55x7_BITRATE_RF_50            0x00100000
-#define T55x7_BITRATE_RF_64            0x00140000
-#define T55x7_BITRATE_RF_100           0x00180000
-#define T55x7_BITRATE_RF_128           0x001C0000
+#define T55x7_POR_DELAY             0x00000001
+#define T55x7_ST_TERMINATOR         0x00000008
+#define T55x7_PWD                   0x00000010
+#define T55x7_MAXBLOCK_SHIFT        5
+#define T55x7_AOR                   0x00000200
+#define T55x7_PSKCF_RF_2            0
+#define T55x7_PSKCF_RF_4            0x00000400
+#define T55x7_PSKCF_RF_8            0x00000800
+#define T55x7_MODULATION_DIRECT     0
+#define T55x7_MODULATION_PSK1       0x00001000
+#define T55x7_MODULATION_PSK2       0x00002000
+#define T55x7_MODULATION_PSK3       0x00003000
+#define T55x7_MODULATION_FSK1       0x00004000
+#define T55x7_MODULATION_FSK2       0x00005000
+#define T55x7_MODULATION_FSK1a      0x00006000
+#define T55x7_MODULATION_FSK2a      0x00007000
+#define T55x7_MODULATION_MANCHESTER 0x00008000
+#define T55x7_MODULATION_BIPHASE    0x00010000
+#define T55x7_MODULATION_DIPHASE    0x00018000
+#define T55x7_BITRATE_RF_8          0
+#define T55x7_BITRATE_RF_16         0x00040000
+#define T55x7_BITRATE_RF_32         0x00080000
+#define T55x7_BITRATE_RF_40         0x000C0000
+#define T55x7_BITRATE_RF_50         0x00100000
+#define T55x7_BITRATE_RF_64         0x00140000
+#define T55x7_BITRATE_RF_100        0x00180000
+#define T55x7_BITRATE_RF_128        0x001C0000
 
 /* T5555 (Q5) configuration register definitions */
-#define T5555_ST_TERMINATOR            0x00000001
-#define T5555_MAXBLOCK_SHIFT           0x00000001
-#define T5555_MODULATION_MANCHESTER    0
-#define T5555_MODULATION_PSK1          0x00000010
-#define T5555_MODULATION_PSK2          0x00000020
-#define T5555_MODULATION_PSK3          0x00000030
-#define T5555_MODULATION_FSK1          0x00000040
-#define T5555_MODULATION_FSK2          0x00000050
-#define T5555_MODULATION_BIPHASE       0x00000060
-#define T5555_MODULATION_DIRECT                0x00000070
-#define T5555_INVERT_OUTPUT            0x00000080
-#define T5555_PSK_RF_2                 0
-#define T5555_PSK_RF_4                 0x00000100
-#define T5555_PSK_RF_8                 0x00000200
-#define T5555_USE_PWD                  0x00000400
-#define T5555_USE_AOR                  0x00000800
-#define T5555_BITRATE_SHIFT            12
-#define T5555_FAST_WRITE               0x00004000
-#define T5555_PAGE_SELECT              0x00008000
+#define T5555_ST_TERMINATOR         0x00000001
+#define T5555_MAXBLOCK_SHIFT        0x00000001
+#define T5555_MODULATION_MANCHESTER 0
+#define T5555_MODULATION_PSK1       0x00000010
+#define T5555_MODULATION_PSK2       0x00000020
+#define T5555_MODULATION_PSK3       0x00000030
+#define T5555_MODULATION_FSK1       0x00000040
+#define T5555_MODULATION_FSK2       0x00000050
+#define T5555_MODULATION_BIPHASE    0x00000060
+#define T5555_MODULATION_DIRECT     0x00000070
+#define T5555_INVERT_OUTPUT         0x00000080
+#define T5555_PSK_RF_2              0
+#define T5555_PSK_RF_4              0x00000100
+#define T5555_PSK_RF_8              0x00000200
+#define T5555_USE_PWD               0x00000400
+#define T5555_USE_AOR               0x00000800
+#define T5555_BITRATE_SHIFT         12
+#define T5555_FAST_WRITE            0x00004000
+#define T5555_PAGE_SELECT           0x00008000
 
 uint32_t GetT55xxClockBit(uint32_t clock);
 
Impressum, Datenschutz