PrintAndLog("");\r
return 0;\r
}\r
-\r
int usage_t55xx_dump(){\r
PrintAndLog("Usage: lf t55xx dump <password>");\r
PrintAndLog(" <password>, OPTIONAL password 4bytes (8 hex characters)");\r
PrintAndLog("");\r
return 0;\r
}\r
+\r
static int CmdHelp(const char *Cmd);\r
\r
int CmdReadBlk(const char *Cmd)\r
int errCnt;\r
size_t bitlen;\r
int maxErr = 100;\r
- uint8_t askAmp = 0;\r
+ //uint8_t askAmp = 0;\r
uint32_t blockData;\r
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r
\r
\r
bitlen = getFromGraphBuf(bits);\r
\r
- errCnt = askrawdemod(bits, &bitlen, &clk, &invert, maxErr, askAmp);\r
+ //errCnt = askrawdemod(bits, &bitlen, &clk, &invert, maxErr, askAmp);\r
+ errCnt = askmandemod(bits, &bitlen, &clk, &invert, maxErr);\r
\r
//throw away static - allow 1 and -1 (in case of threshold command first)\r
if ( errCnt == -1 || bitlen < 16 ){ \r
return 4;\r
}\r
\r
- blockData = PackBits(0, 32, bits);\r
+ blockData = PackBits(1, 32, bits);\r
\r
if ( block < 0)\r
- PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bits,32) );\r
+ PrintAndLog(" Decoded : 0x%08X %s", blockData, sprint_bin(bits+1,32) );\r
else\r
- PrintAndLog(" Block %d : 0x%08X %s", block, blockData, sprint_bin(bits,32) );\r
+ PrintAndLog(" Block %d : 0x%08X %s", block, blockData, sprint_bin(bits+1,32) );\r
\r
return 0;\r
}\r
\r
int CmdReadTrace(const char *Cmd)\r
{\r
- char cmdp = param_getchar(Cmd, 0);\r
+ int invert = 0;\r
+ int clk = 0;\r
+ int errCnt;\r
+ size_t bitlen;\r
+ int maxErr = 100;\r
+ uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r
\r
+ char cmdp = param_getchar(Cmd, 0);\r
+ \r
if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r
usage_t55xx_trace();\r
return 0;\r
SendCommand(&c);\r
WaitForResponse(CMD_ACK, NULL);\r
\r
- uint8_t data[LF_TRACE_BUFF_SIZE] = {0x00};\r
-\r
- GetFromBigBuf(data,LF_TRACE_BUFF_SIZE,0); //3560 -- should be offset..\r
- WaitForResponseTimeout(CMD_ACK,NULL, 1500);\r
-\r
- for (int j = 0; j < LF_TRACE_BUFF_SIZE; j++) {\r
- GraphBuffer[j] = ((int)data[j]);\r
- }\r
- GraphTraceLen = LF_TRACE_BUFF_SIZE;\r
+ CmdSamples("12000");\r
}\r
\r
- uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r
- uint8_t * bitstream = bits;\r
+ bitlen = getFromGraphBuf(bits);\r
+\r
+ //errCnt = askrawdemod(bits, &bitlen, &clk, &invert, maxErr, askAmp);\r
+ errCnt = askmandemod(bits, &bitlen, &clk, &invert, maxErr);\r
\r
- manchester_decode(GraphBuffer, LF_TRACE_BUFF_SIZE, bitstream, LF_BITSSTREAM_LEN);\r
+ //throw away static - allow 1 and -1 (in case of threshold command first)\r
+ if ( errCnt == -1 || bitlen < 16 ){ \r
+ PrintAndLog("no data found");\r
+ if (g_debugMode) \r
+ PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r
+ return 3;\r
+ }\r
+ if (g_debugMode) \r
+ PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d", clk, invert, bitlen);\r
+\r
+ //move bits back to DemodBuffer\r
+ setDemodBuf(bits, bitlen, 0);\r
+ \r
+ // bits has the manchester encoded data.\r
+ errCnt = manrawdecode(bits, &bitlen); \r
+ if ( errCnt == -1 || bitlen < 16 ){ \r
+ PrintAndLog("no data found");\r
+ if (g_debugMode) \r
+ PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r
+ return 4;\r
+ }\r
+\r
RepaintGraphWindow();\r
\r
uint8_t si = 5;\r
- uint32_t bl0 = PackBits(si, 32, bitstream);\r
- uint32_t bl1 = PackBits(si+32, 32, bitstream);\r
+ uint32_t bl0 = PackBits(si, 32, bits);\r
+ uint32_t bl1 = PackBits(si+32, 32, bits);\r
\r
- uint32_t acl = PackBits(si, 8, bitstream); si += 8;\r
- uint32_t mfc = PackBits(si, 8, bitstream); si += 8;\r
- uint32_t cid = PackBits(si, 5, bitstream); si += 5;\r
- uint32_t icr = PackBits(si, 3, bitstream); si += 3;\r
- uint32_t year = PackBits(si, 4, bitstream); si += 4;\r
- uint32_t quarter = PackBits(si, 2, bitstream); si += 2;\r
- uint32_t lotid = PackBits(si, 12, bitstream); si += 12;\r
- uint32_t wafer = PackBits(si, 5, bitstream); si += 5;\r
- uint32_t dw = PackBits(si, 15, bitstream); \r
+ uint32_t acl = PackBits(si, 8, bits); si += 8;\r
+ uint32_t mfc = PackBits(si, 8, bits); si += 8;\r
+ uint32_t cid = PackBits(si, 5, bits); si += 5;\r
+ uint32_t icr = PackBits(si, 3, bits); si += 3;\r
+ uint32_t year = PackBits(si, 4, bits); si += 4;\r
+ uint32_t quarter = PackBits(si, 2, bits); si += 2;\r
+ uint32_t lotid = PackBits(si, 12, bits); si += 12;\r
+ uint32_t wafer = PackBits(si, 5, bits); si += 5;\r
+ uint32_t dw = PackBits(si, 15, bits); \r
\r
PrintAndLog("");\r
PrintAndLog("-- T55xx Trace Information ----------------------------------");\r
PrintAndLog(" Die Number : %d", dw);\r
PrintAndLog("-------------------------------------------------------------");\r
PrintAndLog(" Raw Data - Page 1");\r
- PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bitstream+5,32) );\r
- PrintAndLog(" Block 0 : 0x%08X %s", bl1, sprint_bin(bitstream+37,32) );\r
+ PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bits+5,32) );\r
+ PrintAndLog(" Block 0 : 0x%08X %s", bl1, sprint_bin(bits+37,32) );\r
PrintAndLog("-------------------------------------------------------------");\r
/*\r
TRACE - BLOCK O\r