]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Implemented 'hw status' and 'hw ping', put back client-side cacheing of 'hw version'
authorMartin Holst Swende <martin@swende.se>
Tue, 21 Jul 2015 21:18:51 +0000 (23:18 +0200)
committerMartin Holst Swende <martin@swende.se>
Tue, 21 Jul 2015 21:18:51 +0000 (23:18 +0200)
armsrc/BigBuf.c
armsrc/BigBuf.h
armsrc/appmain.c
armsrc/fpgaloader.c
armsrc/fpgaloader.h
armsrc/lfsampling.c
armsrc/lfsampling.h
armsrc/mifareutil.h
client/cmdhw.c
client/lualibs/commands.lua
include/usb_cmd.h

index 510f7befe720a3628432086273ff537a25a85d0e..a938d5c68db9a193463700f315564ca45dfd3267 100644 (file)
@@ -88,6 +88,16 @@ void BigBuf_free_keep_EM(void)
        }
 }
 
        }
 }
 
+void BigBuf_print_status(void)
+{
+       Dbprintf("Memory");
+       Dbprintf("  BIGBUF_SIZE.............%d", BIGBUF_SIZE);
+       Dbprintf("  BigBuf_hi  .............%d", BigBuf_hi);
+       Dbprintf("Tracing");
+       Dbprintf("  tracing ................%d", tracing);
+       Dbprintf("  traceLen ...............%d", traceLen);
+}
+
 
 // return the maximum trace length (i.e. the unallocated size of BigBuf)
 uint16_t BigBuf_max_traceLen(void)
 
 // return the maximum trace length (i.e. the unallocated size of BigBuf)
 uint16_t BigBuf_max_traceLen(void)
index 0e2f174479b5db5a2110fe057f80bf5dba31d638..05b4180e4b21c77b1604734035b5478216b7918d 100644 (file)
@@ -28,7 +28,7 @@ extern void BigBuf_Clear(void);
 extern uint8_t *BigBuf_malloc(uint16_t);
 extern void BigBuf_free(void);
 extern void BigBuf_free_keep_EM(void);
 extern uint8_t *BigBuf_malloc(uint16_t);
 extern void BigBuf_free(void);
 extern void BigBuf_free_keep_EM(void);
-
+extern void BigBuf_print_status(void);
 extern uint16_t BigBuf_get_traceLen(void);
 extern void clear_trace();
 extern void set_tracing(bool enable);
 extern uint16_t BigBuf_get_traceLen(void);
 extern void clear_trace();
 extern void set_tracing(bool enable);
index 7aa353b2404a7401f57d1b216ee9f256e760ee34..2354080631032fce47d07d189acef12302dec9ae 100644 (file)
@@ -25,6 +25,7 @@
 #include <hitag2.h>
 #include "lfsampling.h"
 #include "BigBuf.h"
 #include <hitag2.h>
 #include "lfsampling.h"
 #include "BigBuf.h"
+#include "mifareutil.h"
 #ifdef WITH_LCD
  #include "LCD.h"
 #endif
 #ifdef WITH_LCD
  #include "LCD.h"
 #endif
@@ -297,6 +298,19 @@ void SendVersion(void)
        uint32_t compressed_data_section_size = common_area.arg1;
        cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, 0, VersionString, strlen(VersionString));
 }
        uint32_t compressed_data_section_size = common_area.arg1;
        cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, 0, VersionString, strlen(VersionString));
 }
+/**
+  * Prints runtime information about the PM3.
+**/
+void SendStatus(void)
+{
+       BigBuf_print_status();
+       Fpga_print_status();
+       printConfig(); //LF Sampling config
+       Dbprintf("Various");
+       Dbprintf("  MF_DBGLEVEL......%d", MF_DBGLEVEL);
+       Dbprintf("  ToSendMax........%d",ToSendMax);
+       Dbprintf("  ToSendBit........%d",ToSendBit);
+}
 
 #if defined(WITH_ISO14443a_StandAlone) || defined(WITH_LF)
 
 
 #if defined(WITH_ISO14443a_StandAlone) || defined(WITH_LF)
 
@@ -1143,7 +1157,12 @@ void UsbPacketReceived(uint8_t *packet, int len)
                case CMD_VERSION:
                        SendVersion();
                        break;
                case CMD_VERSION:
                        SendVersion();
                        break;
-
+               case CMD_STATUS:
+                       SendStatus();
+                       break;
+               case CMD_PING:
+                       cmd_send(CMD_ACK,0,0,0,0,0);
+                       break;
 #ifdef WITH_LCD
                case CMD_LCD_RESET:
                        LCDReset();
 #ifdef WITH_LCD
                case CMD_LCD_RESET:
                        LCDReset();
index 16fed7c52469b857437a3d58474a1dd4d892f4b4..308dda8c09e6ebf8fd0a691df91ccb0c0c3189d2 100644 (file)
@@ -558,3 +558,11 @@ void SetAdcMuxFor(uint32_t whichGpio)
 
        HIGH(whichGpio);
 }
 
        HIGH(whichGpio);
 }
+
+void Fpga_print_status(void)
+{
+       Dbprintf("Fgpa");
+       if(downloaded_bitstream == FPGA_BITSTREAM_HF) Dbprintf("  mode.............HF");
+       else if(downloaded_bitstream == FPGA_BITSTREAM_LF) Dbprintf("  mode.............LF");
+       else Dbprintf("  mode.............%d", downloaded_bitstream);
+}
index 0bad38094b62d355dc6cd13fb427b8c3c9310876..52d6c67780388ab6f94b1893c337139af9f729de 100644 (file)
@@ -17,6 +17,7 @@ void FpgaGatherVersion(int bitstream_version, char *dst, int len);
 void FpgaSetupSsc(void);
 void SetupSpi(int mode);
 bool FpgaSetupSscDma(uint8_t *buf, int len);
 void FpgaSetupSsc(void);
 void SetupSpi(int mode);
 bool FpgaSetupSscDma(uint8_t *buf, int len);
+void Fpga_print_status();
 #define FpgaDisableSscDma(void)        AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS;
 #define FpgaEnableSscDma(void) AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTEN;
 void SetAdcMuxFor(uint32_t whichGpio);
 #define FpgaDisableSscDma(void)        AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS;
 #define FpgaEnableSscDma(void) AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTEN;
 void SetAdcMuxFor(uint32_t whichGpio);
index 662ebf24a1b84702d37d6ffe3c31c79693a2d483..6e78376986daa167079608c83b2189d4c528ea42 100644 (file)
@@ -17,7 +17,7 @@ sample_config config = { 1, 8, 1, 95, 0 } ;
 
 void printConfig()
 {
 
 void printConfig()
 {
-       Dbprintf("Sampling config: ");
+       Dbprintf("LF Sampling config: ");
        Dbprintf("  [q] divisor:           %d ", config.divisor);
        Dbprintf("  [b] bps:               %d ", config.bits_per_sample);
        Dbprintf("  [d] decimation:        %d ", config.decimation);
        Dbprintf("  [q] divisor:           %d ", config.divisor);
        Dbprintf("  [b] bps:               %d ", config.bits_per_sample);
        Dbprintf("  [d] decimation:        %d ", config.decimation);
index 6c671ec8ca7a295b49a2d9200401a3ca69d49753..7d3925cddfff0d70e7032da25b3284276abd3e0d 100644 (file)
@@ -56,4 +56,8 @@ void LFSetupFPGAForADC(int divisor, bool lf_field);
 void setSamplingConfig(sample_config *sc);
 
 sample_config * getSamplingConfig();
 void setSamplingConfig(sample_config *sc);
 
 sample_config * getSamplingConfig();
+
+void printConfig();
+
+
 #endif // LFSAMPLING_H
 #endif // LFSAMPLING_H
index 85a34ef62104fa2445503eac3517436d43fa8438..7a09ce64cdac33707a13abdef1de3294d778cd58 100644 (file)
@@ -8,6 +8,7 @@
 //-----------------------------------------------------------------------------\r
 // code for work with mifare cards.\r
 //-----------------------------------------------------------------------------\r
 //-----------------------------------------------------------------------------\r
 // code for work with mifare cards.\r
 //-----------------------------------------------------------------------------\r
+#include "crapto1.h"\r
 \r
 #ifndef __MIFAREUTIL_H\r
 #define __MIFAREUTIL_H\r
 \r
 #ifndef __MIFAREUTIL_H\r
 #define __MIFAREUTIL_H\r
index 2b6f95187512a16c0e7fa8e9fda265d2aff457ad..23b6ce21b5af5cb1ffb87347b0c6320df8908a78 100644 (file)
@@ -405,33 +405,64 @@ int CmdTune(const char *Cmd)
 int CmdVersion(const char *Cmd)
 {
 
 int CmdVersion(const char *Cmd)
 {
 
+       clearCommandBuffer();
        UsbCommand c = {CMD_VERSION};
        UsbCommand c = {CMD_VERSION};
-       UsbCommand resp = {0, {0, 0, 0}};
+       static UsbCommand resp = {0, {0, 0, 0}};
 
 
-       SendCommand(&c);
-       if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
+       if (resp.arg[0] == 0 && resp.arg[1] == 0) { // no cached information available
+               SendCommand(&c);
+               if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
+                       PrintAndLog("Prox/RFID mark3 RFID instrument");
+                       PrintAndLog((char*)resp.d.asBytes);
+                       lookupChipID(resp.arg[0], resp.arg[1]);
+               }
+       } else {
+               PrintAndLog("[[[ Cached information ]]]\n");
                PrintAndLog("Prox/RFID mark3 RFID instrument");
                PrintAndLog((char*)resp.d.asBytes);
                lookupChipID(resp.arg[0], resp.arg[1]);
                PrintAndLog("Prox/RFID mark3 RFID instrument");
                PrintAndLog((char*)resp.d.asBytes);
                lookupChipID(resp.arg[0], resp.arg[1]);
+               PrintAndLog("");
        }
        }
+       return 0;
+}
 
 
+int CmdStatus(const char *Cmd)
+{
+       UsbCommand c = {CMD_STATUS};
+       SendCommand(&c);
+       return 0;
+}
+
+int CmdPing(const char *Cmd)
+{
+       clearCommandBuffer();
+       UsbCommand resp;
+       UsbCommand c = {CMD_PING};
+       SendCommand(&c);
+       if (WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
+               PrintAndLog("Ping successfull");
+       }else{
+               PrintAndLog("Ping failed");
+       }
        return 0;
 }
 
 static command_t CommandTable[] = 
 {
        return 0;
 }
 
 static command_t CommandTable[] = 
 {
-  {"help",          CmdHelp,        1, "This help"},
-  {"detectreader",  CmdDetectReader,0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},
-  {"fpgaoff",       CmdFPGAOff,     0, "Set FPGA off"},
-  {"lcd",           CmdLCD,         0, "<HEX command> <count> -- Send command/data to LCD"},
-  {"lcdreset",      CmdLCDReset,    0, "Hardware reset LCD"},
-  {"readmem",       CmdReadmem,     0, "[address] -- Read memory at decimal address from flash"},
-  {"reset",         CmdReset,       0, "Reset the Proxmark3"},
-  {"setlfdivisor",  CmdSetDivisor,  0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
-  {"setmux",        CmdSetMux,      0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},
-  {"tune",          CmdTune,        0, "Measure antenna tuning"},
-  {"version",       CmdVersion,     0, "Show version information about the connected Proxmark"},
-  {NULL, NULL, 0, NULL}
+       {"help",          CmdHelp,        1, "This help"},
+       {"detectreader",  CmdDetectReader,0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},
+       {"fpgaoff",       CmdFPGAOff,     0, "Set FPGA off"},
+       {"lcd",           CmdLCD,         0, "<HEX command> <count> -- Send command/data to LCD"},
+       {"lcdreset",      CmdLCDReset,    0, "Hardware reset LCD"},
+       {"readmem",       CmdReadmem,     0, "[address] -- Read memory at decimal address from flash"},
+       {"reset",         CmdReset,       0, "Reset the Proxmark3"},
+       {"setlfdivisor",  CmdSetDivisor,  0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
+       {"setmux",        CmdSetMux,      0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},
+       {"tune",          CmdTune,        0, "Measure antenna tuning"},
+       {"version",       CmdVersion,     0, "Show version information about the connected Proxmark"},
+       {"status",        CmdStatus,      0, "Show runtime status information about the connected Proxmark"},
+       {"ping",          CmdPing,        0, "Test if the pm3 is responsive"},
+       {NULL, NULL, 0, NULL}
 };
 
 int CmdHW(const char *Cmd)
 };
 
 int CmdHW(const char *Cmd)
index 127508e6381d96ea860600ca2b7afeaa18431e70..64f16e4491ab95769e358b9f685d727242ef789c 100644 (file)
@@ -20,7 +20,8 @@ local _commands = {
        CMD_BUFF_CLEAR =                                                     0x0105,
        CMD_READ_MEM =                                                       0x0106,
        CMD_VERSION =                                                        0x0107,
        CMD_BUFF_CLEAR =                                                     0x0105,
        CMD_READ_MEM =                                                       0x0106,
        CMD_VERSION =                                                        0x0107,
-
+       CMD_STATUS =                                                         0x0108,
+       CMD_PING =                                                           0x0109,
        --// For low-frequency tags
        CMD_READ_TI_TYPE =                                                   0x0202,
        CMD_WRITE_TI_TYPE =                                                  0x0203,
        --// For low-frequency tags
        CMD_READ_TI_TYPE =                                                   0x0202,
        CMD_WRITE_TI_TYPE =                                                  0x0203,
index e45bf35edd1f64a143504dfba794e1a1f892a675..f443e970ce02a8a792b80018dee3d87920e24302 100644 (file)
@@ -60,6 +60,8 @@ typedef struct{
 #define CMD_BUFF_CLEAR                                                    0x0105
 #define CMD_READ_MEM                                                      0x0106
 #define CMD_VERSION                                                       0x0107
 #define CMD_BUFF_CLEAR                                                    0x0105
 #define CMD_READ_MEM                                                      0x0106
 #define CMD_VERSION                                                       0x0107
+#define CMD_STATUS                                                                                                               0x0108
+#define CMD_PING                                                                                                                 0x0109
 
 // For low-frequency tags
 #define CMD_READ_TI_TYPE                                                  0x0202
 
 // For low-frequency tags
 #define CMD_READ_TI_TYPE                                                  0x0202
Impressum, Datenschutz