From 1dff8c42f5fd3f4d69137c92e5a22083d015d3ec Mon Sep 17 00:00:00 2001 From: skamkar Date: Mon, 13 Jul 2009 08:22:24 +0000 Subject: [PATCH] fix debug printing function, add readmem function --- armsrc/appmain.c | 22 ++++++++++++++++++---- armsrc/apps.h | 1 + winsrc/command.cpp | 11 ++++++++++- winsrc/prox.h | 1 + 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index a137a8fe..09f11f03 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -69,8 +69,8 @@ void ToSendStuffBit(int b) void DbpString(char *str) { /* this holds up stuff unless we're connected to usb */ - if (!usbattached) - return; +// if (!usbattached) +// return; UsbCommand c; c.cmd = CMD_DEBUG_PRINT_STRING; @@ -85,8 +85,8 @@ void DbpString(char *str) void DbpIntegers(int x1, int x2, int x3) { /* this holds up stuff unless we're connected to usb */ - if (!usbattached) - return; +// if (!usbattached) +// return; UsbCommand c; c.cmd = CMD_DEBUG_PRINT_INTEGERS; @@ -833,6 +833,9 @@ void UsbPacketReceived(BYTE *packet, int len) LCDReset(); break; #endif + case CMD_READ_MEM: + ReadMem(c->ext1); + break; case CMD_SWEEP_LF: SweepLFrange(); break; @@ -864,6 +867,17 @@ void UsbPacketReceived(BYTE *packet, int len) } } +void ReadMem(int addr) +{ + const DWORD *data = ((DWORD *)addr); + int i; + + DbpString("Reading memory at address"); + DbpIntegers(0, 0, addr); + for (i = 0; i < 8; i+= 2) + DbpIntegers(0, data[i], data[i+1]); +} + void AppMain(void) { memset(BigBuf,0,sizeof(BigBuf)); diff --git a/armsrc/apps.h b/armsrc/apps.h index 7e40fdd0..67f9349b 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -8,6 +8,7 @@ #define __APPS_H /// appmain.c +void ReadMem(int addr); void AppMain(void); void SamyRun(void); void DbpIntegers(int a, int b, int c); diff --git a/winsrc/command.cpp b/winsrc/command.cpp index eb4342fe..485eff52 100644 --- a/winsrc/command.cpp +++ b/winsrc/command.cpp @@ -2520,6 +2520,14 @@ static void CmdHIDsimTAG(char *str) SendCommand(&c, FALSE); } +static void CmdReadmem(char *str) +{ + UsbCommand c; + c.cmd = CMD_READ_MEM; + c.ext1 = atoi(str); + SendCommand(&c, FALSE); +} + static void CmdLcdReset(char *str) { UsbCommand c; @@ -2619,7 +2627,7 @@ static struct { {"hisamplest", CmdHi14readt,0, " Get samples HF, for testing"}, {"hisimlisten", CmdHisimlisten,0, " Get HF samples as fake tag"}, {"hpf", CmdHpf,1, " Remove DC offset from trace"}, - {"indalademod", CmdIndalademod,0, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"}, + {"indalademod", CmdIndalademod,0, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"}, {"lcd", CmdLcd,0, " -- Send command/data to LCD"}, {"lcdreset", CmdLcdReset,0, " Hardware reset LCD"}, {"load", CmdLoad,1, " -- Load trace (to graph window"}, @@ -2633,6 +2641,7 @@ static struct { {"norm", CmdNorm,1, " Normalize max/min to +/-500"}, {"plot", CmdPlot,1, " Show graph window"}, {"quit", CmdQuit,1, " Quit program"}, + {"readmem", CmdReadmem,0, " [address] Read memory at decimal address from flash"}, {"reset", CmdReset,0, " Reset the Proxmark3"}, {"save", CmdSave,1, " -- Save trace (from graph window)"}, {"scale", CmdScale,1, " -- Set cursor display scale"}, diff --git a/winsrc/prox.h b/winsrc/prox.h index a9f3a2ef..5550e595 100644 --- a/winsrc/prox.h +++ b/winsrc/prox.h @@ -42,6 +42,7 @@ static void CmdHi15tag(char *str); static void CmdHi14read_sim(char *str); static void CmdHi14readt(char *str); static void CmdHisimlisten(char *str); +static void CmdReadmem(char *str); static void CmdHi14sim(char *str); static void CmdHi14asim(char *str); static void CmdHi14snoop(char *str); -- 2.39.5