]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Add version command
authorhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Fri, 28 Aug 2009 00:37:28 +0000 (00:37 +0000)
committerhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Fri, 28 Aug 2009 00:37:28 +0000 (00:37 +0000)
armsrc/appmain.c
armsrc/apps.h
armsrc/fpgaloader.c
armsrc/util.c
include/usb_cmd.h
winsrc/command.cpp

index a3871eb64f7ab73558d62327901dc1cf7641acb8..551ee694e493a0742b4e3878595c7454caf9ceb5 100644 (file)
@@ -236,6 +236,14 @@ void ReadMem(int addr)
                DbpIntegers(0, data[i], data[i+1]);
 }
 
                DbpIntegers(0, data[i], data[i+1]);
 }
 
+void SendVersion(void)
+{
+       char temp[48]; /* Limited data payload in USB packets */
+       DbpString("Prox/RFID mark3 RFID instrument");
+       FpgaGatherVersion(temp, sizeof(temp));
+       DbpString(temp);
+}
+
 // samy's sniff and repeat routine
 void SamyRun()
 {
 // samy's sniff and repeat routine
 void SamyRun()
 {
@@ -616,6 +624,9 @@ void UsbPacketReceived(BYTE *packet, int len)
                case CMD_SET_LF_DIVISOR:
                        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->ext1);
                        break;
                case CMD_SET_LF_DIVISOR:
                        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->ext1);
                        break;
+               case CMD_VERSION:
+                       SendVersion();
+                       break;
 #ifdef WITH_LCD
                case CMD_LCD_RESET:
                        LCDReset();
 #ifdef WITH_LCD
                case CMD_LCD_RESET:
                        LCDReset();
index 878ec526333975b6eddeff6326a87861210e2a90..7605baa3c51f4a205329352fbb349440d72c4374 100644 (file)
@@ -30,6 +30,7 @@ extern DWORD BigBuf[];
 void FpgaSendCommand(WORD cmd, WORD v);\r
 void FpgaWriteConfWord(BYTE v);\r
 void FpgaDownloadAndGo(void);\r
 void FpgaSendCommand(WORD cmd, WORD v);\r
 void FpgaWriteConfWord(BYTE v);\r
 void FpgaDownloadAndGo(void);\r
+void FpgaGatherVersion(char *dst, int len);\r
 void FpgaSetupSsc(void);\r
 void SetupSpi(int mode);\r
 void FpgaSetupSscDma(BYTE *buf, int len);\r
 void FpgaSetupSsc(void);\r
 void SetupSpi(int mode);\r
 void FpgaSetupSscDma(BYTE *buf, int len);\r
@@ -104,6 +105,7 @@ int strlen(char *str);
 void *memcpy(void *dest, const void *src, int len);\r
 void *memset(void *dest, int c, int len);\r
 int memcmp(const void *av, const void *bv, int len);\r
 void *memcpy(void *dest, const void *src, int len);\r
 void *memset(void *dest, int c, int len);\r
 int memcmp(const void *av, const void *bv, int len);\r
+char *strncat(char *dest, const char *src, unsigned int n);\r
 void SpinDelay(int ms);\r
 void SpinDelayUs(int us);\r
 void LED(int led, int ms);\r
 void SpinDelay(int ms);\r
 void SpinDelayUs(int us);\r
 void LED(int led, int ms);\r
index e07c25420afd1a3fd22b2fdace468b6bb9c9d218..88fdc4cfc08a6517e092ef2aa892936fdb447285 100644 (file)
@@ -285,6 +285,37 @@ void FpgaDownloadAndGo(void)
                DownloadFPGA((DWORD *)0x2000, 10524, 1);\r
 }\r
 \r
                DownloadFPGA((DWORD *)0x2000, 10524, 1);\r
 }\r
 \r
+void FpgaGatherVersion(char *dst, int len)\r
+{\r
+       char *fpga_info; \r
+       unsigned int fpga_info_len;\r
+       dst[0] = 0;\r
+       if(!bitparse_find_section('e', (void**)&fpga_info, &fpga_info_len)) {\r
+               strncat(dst, "FPGA image: legacy image without version information", len-1);\r
+       } else {\r
+               strncat(dst, "FPGA image built", len-1);\r
+               /* USB packets only have 48 bytes data payload, so be terse */\r
+#if 0\r
+               if(bitparse_find_section('a', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {\r
+                       strncat(dst, " from ", len-1);\r
+                       strncat(dst, fpga_info, len-1);\r
+               }\r
+               if(bitparse_find_section('b', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {\r
+                       strncat(dst, " for ", len-1);\r
+                       strncat(dst, fpga_info, len-1);\r
+               }\r
+#endif\r
+               if(bitparse_find_section('c', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {\r
+                       strncat(dst, " on ", len-1);\r
+                       strncat(dst, fpga_info, len-1);\r
+               }\r
+               if(bitparse_find_section('d', (void**)&fpga_info, &fpga_info_len) && fpga_info[fpga_info_len-1] == 0 ) {\r
+                       strncat(dst, " at ", len-1);\r
+                       strncat(dst, fpga_info, len-1);\r
+               }\r
+       }\r
+}\r
+\r
 //-----------------------------------------------------------------------------\r
 // Send a 16 bit command/data pair to the FPGA.\r
 // The bit format is:  C3 C2 C1 C0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0\r
 //-----------------------------------------------------------------------------\r
 // Send a 16 bit command/data pair to the FPGA.\r
 // The bit format is:  C3 C2 C1 C0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0\r
index 8a3da63a898f5dae60299ef4f8502c50dd0c56b7..a102bbb5a461e52ba1cc870c777077e6fe5b1f02 100644 (file)
@@ -52,6 +52,19 @@ int strlen(char *str)
        return l;\r
 }\r
 \r
        return l;\r
 }\r
 \r
+char* strncat(char *dest, const char *src, unsigned int n)\r
+{\r
+       unsigned int dest_len = strlen(dest);\r
+       unsigned int i;\r
+       \r
+       for (i = 0 ; i < n && src[i] != '\0' ; i++)\r
+               dest[dest_len + i] = src[i];\r
+       dest[dest_len + i] = '\0';\r
+       \r
+       return dest;\r
+}\r
+\r
+\r
 void LEDsoff()\r
 {\r
        LED_A_OFF();\r
 void LEDsoff()\r
 {\r
        LED_A_OFF();\r
index 6818bb5e98991b0522b2521e5c6b0b76f60144a8..b5c438c66d20bb5290c89c26d33852a9e74dcdd1 100644 (file)
@@ -35,6 +35,7 @@ typedef struct {
 #define CMD_LCD                                                                                                                                                                0x0104\r
 #define CMD_BUFF_CLEAR                                                                                                                         0x0105\r
 #define CMD_READ_MEM                                                                                                                                   0x0106\r
 #define CMD_LCD                                                                                                                                                                0x0104\r
 #define CMD_BUFF_CLEAR                                                                                                                         0x0105\r
 #define CMD_READ_MEM                                                                                                                                   0x0106\r
+#define CMD_VERSION                                                                                                                                    0x0107\r
 \r
 // For low-frequency tags\r
 #define CMD_READ_TI_TYPE                                                                                                                       0x0202\r
 \r
 // For low-frequency tags\r
 #define CMD_READ_TI_TYPE                                                                                                                       0x0202\r
index 08feb3dd3ac872dfda717b4967a44a3976465e6d..3a858ddc7090800c9095210dd4a0a5d4210f3987 100644 (file)
@@ -2732,6 +2732,13 @@ static void CmdReadmem(char *str)
        SendCommand(&c, FALSE);\r
 }\r
 \r
        SendCommand(&c, FALSE);\r
 }\r
 \r
+static void CmdVersion(char *str)\r
+{\r
+       UsbCommand c;\r
+       c.cmd = CMD_VERSION;\r
+       SendCommand(&c, FALSE);\r
+}\r
+\r
 static void CmdLcdReset(char *str)\r
 {\r
        UsbCommand c;\r
 static void CmdLcdReset(char *str)\r
 {\r
        UsbCommand c;\r
@@ -2844,6 +2851,7 @@ static struct {
        {"tiwrite",                             CmdTIWrite,                                     0, "Write new data to a r/w TI 134 kHz tag"},\r
        {"threshold",                   CmdThreshold,                           1, "Maximize/minimize every value in the graph window depending on threshold"},\r
        {"tune",                                        CmdTune,                                                0, "Measure antenna tuning"},\r
        {"tiwrite",                             CmdTIWrite,                                     0, "Write new data to a r/w TI 134 kHz tag"},\r
        {"threshold",                   CmdThreshold,                           1, "Maximize/minimize every value in the graph window depending on threshold"},\r
        {"tune",                                        CmdTune,                                                0, "Measure antenna tuning"},\r
+       {"version",                     CmdVersion,                             0, "Show version inforation about the connected Proxmark"},\r
        {"vchdemod",                    CmdVchdemod,                            0, "['clone'] -- Demodulate samples for VeriChip"},\r
        {"zerocrossings",       CmdZerocrossings,               1, "Count time between zero-crossings"},\r
 };\r
        {"vchdemod",                    CmdVchdemod,                            0, "['clone'] -- Demodulate samples for VeriChip"},\r
        {"zerocrossings",       CmdZerocrossings,               1, "Count time between zero-crossings"},\r
 };\r
Impressum, Datenschutz