From f6f14f82d48d7306492e356f5dd8d36db6ab2c83 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 19 Jul 2019 13:02:12 +0200 Subject: [PATCH] Add option -i to flasher to query Pm3 for its memory size, and some doc tuning --- CHANGELOG.md | 1 + client/flasher.c | 58 +++++++++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa26a2b3..45c2074b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] + - Add option -i to flasher to query Pm3 for its memory size (@doegox) - Add support for flashing 512K units (@slurdge) - Add a simple python tool to check the elf sizes (@slurdge) - Change: new keys for Vigik badges in default_keys.dict (@luminouw) diff --git a/client/flasher.c b/client/flasher.c index 8b6a87bf8..4caeab63b 100644 --- a/client/flasher.c +++ b/client/flasher.c @@ -24,15 +24,20 @@ #define ONE_KB 1024 static void usage(char *argv0) { - PrintAndLogEx(NORMAL, "Usage: %s [-b] image.elf [image.elf...]\n", argv0); - PrintAndLogEx(NORMAL, "\t-b\tEnable flashing of bootloader area (DANGEROUS)\n"); - PrintAndLogEx(NORMAL, "\nExample:\n\n\t %s "SERIAL_PORT_EXAMPLE_H" armsrc/obj/fullimage.elf", argv0); + PrintAndLogEx(NORMAL, "Usage: %s [-b] image.elf [image.elf...]", argv0); + PrintAndLogEx(NORMAL, " %s -i\n", argv0); + PrintAndLogEx(NORMAL, "\t-b\tEnable flashing of bootloader area (DANGEROUS)"); + PrintAndLogEx(NORMAL, "\t-i\tProbe the connected Proxmark3 to retrieve its memory size"); + PrintAndLogEx(NORMAL, "\nExamples:\n\t %s "SERIAL_PORT_EXAMPLE_H" -i", argv0); + PrintAndLogEx(NORMAL, "\t %s "SERIAL_PORT_EXAMPLE_H" armsrc/obj/fullimage.elf", argv0); #ifdef __linux__ - PrintAndLogEx(NORMAL, "\nNote (Linux): if the flasher gets stuck in 'Waiting for Proxmark3 to reappear on ',"); - PrintAndLogEx(NORMAL, " you need to blacklist Proxmark3 for modem-manager - see wiki for more details:\n"); - PrintAndLogEx(NORMAL, " https://github.com/Proxmark/proxmark3/wiki/Gentoo Linux\n"); - PrintAndLogEx(NORMAL, " https://github.com/Proxmark/proxmark3/wiki/Ubuntu Linux\n"); - PrintAndLogEx(NORMAL, " https://github.com/Proxmark/proxmark3/wiki/OSX\n"); + PrintAndLogEx(NORMAL, "\nNote (Linux):\nif the flasher gets stuck in 'Waiting for Proxmark3 to reappear on ',"); + PrintAndLogEx(NORMAL, "you need to blacklist Proxmark3 for modem-manager - see documentation for more details:"); + PrintAndLogEx(NORMAL, "* https://github.com/RfidResearchGroup/proxmark3/blob/master/doc/md/Installation_Instructions/ModemManager-Must-Be-Discarded.md"); + PrintAndLogEx(NORMAL, "\nMore info on flashing procedure from the official Proxmark3 wiki:"); + PrintAndLogEx(NORMAL, "* https://github.com/Proxmark/proxmark3/wiki/Gentoo%%20Linux"); + PrintAndLogEx(NORMAL, "* https://github.com/Proxmark/proxmark3/wiki/Ubuntu%%20Linux"); + PrintAndLogEx(NORMAL, "* https://github.com/Proxmark/proxmark3/wiki/OSX\n"); #endif } @@ -78,7 +83,7 @@ int main(int argc, char **argv) { int res; flash_file_t files[MAX_FILES]; char * filenames[MAX_FILES]; - + bool info = false; memset(files, 0, sizeof(files)); session.supports_colors = false; @@ -99,6 +104,8 @@ int main(int argc, char **argv) { if (argv[i][0] == '-') { if (!strcmp(argv[i], "-b")) { can_write_bl = 1; + } else if (!strcmp(argv[i], "-i")) { + info = true; } else { usage(argv[0]); return -1; @@ -133,24 +140,25 @@ int main(int argc, char **argv) { mem_avail = 256; //we default to a low value } - for (int i = 0 ; i < num_files; ++i){ - res = flash_load(&files[i], filenames[i], can_write_bl, mem_avail*ONE_KB); - if (res < 0) - return -1; + if (! info) { + for (int i = 0 ; i < num_files; ++i){ + res = flash_load(&files[i], filenames[i], can_write_bl, mem_avail*ONE_KB); + if (res < 0) + return -1; - PrintAndLogEx(NORMAL, ""); + PrintAndLogEx(NORMAL, ""); + } + + PrintAndLogEx(SUCCESS, "\n" _BLUE_("Flashing...")); + + for (int i = 0; i < num_files; i++) { + res = flash_write(&files[i]); + if (res < 0) + return -1; + flash_free(&files[i]); + PrintAndLogEx(NORMAL, "\n"); + } } - - PrintAndLogEx(SUCCESS, "\n" _BLUE_("Flashing...")); - - for (int i = 0; i < num_files; i++) { - res = flash_write(&files[i]); - if (res < 0) - return -1; - flash_free(&files[i]); - PrintAndLogEx(NORMAL, "\n"); - } - res = flash_stop_flashing(); if (res < 0) return -1;