From 87eee0cf5c963921b904368727c09e48e1a1dd2d Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 26 Apr 2019 13:07:45 +0200 Subject: [PATCH 1/4] text --- armsrc/appmain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 066f3a5d7..633d21a07 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -365,8 +365,8 @@ void SendVersion(void) { // measure the USB Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time. // Note: this mimics GetFromBigbuf(), i.e. we have the overhead of the UsbCommand structure included. void printUSBSpeed(void) { - DbpStringEx(FLAG_LOG|FLAG_ANSI, _BLUE_("USB Speed")); - Dbprintf(" Sending USB packets to client..."); + DbpStringEx(FLAG_LOG|FLAG_ANSI, _BLUE_("Transfer Speed")); + Dbprintf(" Sending packets to client..."); #define USB_SPEED_TEST_MIN_TIME 1500 // in milliseconds uint8_t *test_data = BigBuf_get_addr(); @@ -386,7 +386,7 @@ void printUSBSpeed(void) { Dbprintf(" Time elapsed............%dms", end_time - start_time); Dbprintf(" Bytes transferred.......%d", bytes_transferred); - Dbprintf(" USB Transfer Speed PM3 -> Client = %d Bytes/s", 1000 * bytes_transferred / (end_time - start_time)); + Dbprintf(" Transfer Speed PM3 -> Client = " _YELLOW_("%d") " bytes/s", 1000 * bytes_transferred / (end_time - start_time)); } /** From a1bb2ec10685e9c887e2e25c651f29660da9d19b Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 26 Apr 2019 22:17:26 +0200 Subject: [PATCH 2/4] Trying original SPI mode for 24MHz flash mem --- armsrc/flashmem.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/armsrc/flashmem.c b/armsrc/flashmem.c index e423805a2..331696dec 100644 --- a/armsrc/flashmem.c +++ b/armsrc/flashmem.c @@ -80,10 +80,14 @@ void FlashSetup(uint32_t baudrate) { uint8_t csaat = 1; uint32_t dlybct = 0; + uint8_t ncpha = 1; + uint8_t cpol = 0; if (baudrate > FLASH_MINFAST) { baudrate = FLASH_FASTBAUD; //csaat = 0; dlybct = 1500; + ncpha = 0; + cpol = 0; } AT91C_BASE_SPI->SPI_CSR[2] = @@ -119,9 +123,10 @@ void FlashSetup(uint32_t baudrate) { 1 0 1 1 clock normally low read on falling edge 2 1 0 0 clock normally high read on falling edge 3 1 1 1 clock normally high read on rising edge + Update: for 24MHz, writing is more stable with ncpha=1, else bitflips occur. */ - (0 << 1) | // Clock Phase data captured on leading edge, changes on following edge - (0 << 0); // Clock Polarity inactive state is logic 0 + (ncpha << 1) | // Clock Phase data captured on leading edge, changes on following edge + (cpol << 0); // Clock Polarity inactive state is logic 0 // read first, empty buffer if (AT91C_BASE_SPI->SPI_RDR == 0) {}; From 4a576efc44e503a76aed659824d016d534f51c59 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 26 Apr 2019 23:26:51 +0200 Subject: [PATCH 3/4] TestProxmark only if OpenProxmark returned pm3 present --- client/proxmark3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/proxmark3.c b/client/proxmark3.c index aef3c5979..a16a6a7a8 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -467,7 +467,7 @@ int main(int argc, char *argv[]) { if (port != NULL) usb_present = OpenProxmark(port, waitCOMPort, 20, false, speed); - if (TestProxmark() == 0) + if (usb_present && (TestProxmark() == 0)) usb_present = false; if (!usb_present) PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Check \"%s -h\" if it's not what you want.\n", exec_name); From 897632a7178bf641de0baf49fe5c0693ac4e5613 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 26 Apr 2019 23:30:03 +0200 Subject: [PATCH 4/4] rename usb_present --- client/proxgui.cpp | 8 ++++---- client/proxgui.h | 2 +- client/proxguiqt.h | 2 +- client/proxmark3.c | 28 ++++++++++++++-------------- client/proxmark3.h | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/client/proxgui.cpp b/client/proxgui.cpp index 9953c07ae..bc382d1c2 100644 --- a/client/proxgui.cpp +++ b/client/proxgui.cpp @@ -15,14 +15,14 @@ static ProxGuiQT *gui = NULL; static WorkerThread *main_loop_thread = NULL; -WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd, bool usb_present) : script_cmds_file(script_cmds_file), script_cmd(script_cmd), usb_present(usb_present) { +WorkerThread::WorkerThread(char *script_cmds_file, char *script_cmd, bool pm3_present) : script_cmds_file(script_cmds_file), script_cmd(script_cmd), pm3_present(pm3_present) { } WorkerThread::~WorkerThread() { } void WorkerThread::run() { - main_loop(script_cmds_file, script_cmd, usb_present); + main_loop(script_cmds_file, script_cmd, pm3_present); } extern "C" void ShowGraphWindow(void) { @@ -53,12 +53,12 @@ extern "C" void MainGraphics(void) { gui->MainLoop(); } -extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool usb_present) { +extern "C" void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool pm3_present) { #ifdef Q_WS_X11 if (getenv("DISPLAY") == NULL) return; #endif - main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, usb_present); + main_loop_thread = new WorkerThread(script_cmds_file, script_cmd, pm3_present); gui = new ProxGuiQT(argc, argv, main_loop_thread); } diff --git a/client/proxgui.h b/client/proxgui.h index 2c573f023..40fb1ce2d 100644 --- a/client/proxgui.h +++ b/client/proxgui.h @@ -22,7 +22,7 @@ void ShowGraphWindow(void); void HideGraphWindow(void); void RepaintGraphWindow(void); void MainGraphics(void); -void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool usb_present); +void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cmd, bool pm3_present); void ExitGraphics(void); #ifndef MAX_GRAPH_TRACE_LEN #define MAX_GRAPH_TRACE_LEN (40000 * 8) diff --git a/client/proxguiqt.h b/client/proxguiqt.h index 6d92c22e7..2685aecde 100644 --- a/client/proxguiqt.h +++ b/client/proxguiqt.h @@ -99,7 +99,7 @@ class WorkerThread : public QThread { private: char *script_cmds_file = NULL; char *script_cmd = NULL; - bool usb_present; + bool pm3_present; }; class ProxGuiQT : public QObject { diff --git a/client/proxmark3.c b/client/proxmark3.c index a16a6a7a8..0ada54e78 100644 --- a/client/proxmark3.c +++ b/client/proxmark3.c @@ -58,7 +58,7 @@ void __attribute__((force_align_arg_pointer)) #endif #endif -main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) { +main_loop(char *script_cmds_file, char *script_cmd, bool pm3_present) { char *cmd = NULL; bool execCommand = (script_cmd != NULL); @@ -68,7 +68,7 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) { PrintAndLogEx(DEBUG, "ISATTY/STDIN_FILENO == %s\n", (stdinOnPipe) ? "true" : "false"); - if (usb_present) { + if (pm3_present) { SetOffline(false); // cache Version information now: if (execCommand || script_cmds_file || stdinOnPipe) @@ -98,10 +98,10 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) { if ( IsOffline() ) { // sets the global variable, SP and offline) - usb_present = hookUpPM3(); + pm3_present = hookUpPM3(); // usb and the reader_thread is NULL, create a new reader thread. - if (usb_present && !IsOffline() ) { + if (pm3_present && !IsOffline() ) { rarg.run = 1; pthread_create(&reader_thread, NULL, &uart_receiver, &rarg); // cache Version information now: @@ -275,7 +275,7 @@ static void show_help(bool showFullHelp, char *exec_name) { int main(int argc, char *argv[]) { srand(time(0)); - bool usb_present = false; + bool pm3_present = false; bool waitCOMPort = false; bool addLuaExec = false; char *script_cmds_file = NULL; @@ -465,35 +465,35 @@ int main(int argc, char *argv[]) { // try to open USB connection to Proxmark if (port != NULL) - usb_present = OpenProxmark(port, waitCOMPort, 20, false, speed); + pm3_present = OpenProxmark(port, waitCOMPort, 20, false, speed); - if (usb_present && (TestProxmark() == 0)) - usb_present = false; - if (!usb_present) + if (pm3_present && (TestProxmark() == 0)) + pm3_present = false; + if (!pm3_present) PrintAndLogEx(INFO, "Running in " _YELLOW_("OFFLINE") "mode. Check \"%s -h\" if it's not what you want.\n", exec_name); #ifdef HAVE_GUI # ifdef _WIN32 - InitGraphics(argc, argv, script_cmds_file, script_cmd, usb_present); + InitGraphics(argc, argv, script_cmds_file, script_cmd, pm3_present); MainGraphics(); # else // for *nix distro's, check enviroment variable to verify a display char *display = getenv("DISPLAY"); if (display && strlen(display) > 1) { - InitGraphics(argc, argv, script_cmds_file, script_cmd, usb_present); + InitGraphics(argc, argv, script_cmds_file, script_cmd, pm3_present); MainGraphics(); } else { - main_loop(script_cmds_file, script_cmd, usb_present); + main_loop(script_cmds_file, script_cmd, pm3_present); } # endif #else - main_loop(script_cmds_file, script_cmd, usb_present); + main_loop(script_cmds_file, script_cmd, pm3_present); #endif // Clean up the port - if (usb_present) { + if (pm3_present) { CloseProxmark(); } diff --git a/client/proxmark3.h b/client/proxmark3.h index 52fe27385..5d5a49c9a 100644 --- a/client/proxmark3.h +++ b/client/proxmark3.h @@ -23,7 +23,7 @@ extern "C" { const char *get_my_executable_path(void); const char *get_my_executable_directory(void); -void main_loop(char *script_cmds_file, char *script_cmd, bool usb_present); +void main_loop(char *script_cmds_file, char *script_cmd, bool pm3_present); #ifdef __cplusplus }