From 3e641e217d1ed195c599d8e7c8de2fb1ef815869 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 25 Apr 2019 23:09:06 +0200 Subject: [PATCH 1/6] remove redundant def --- common/Makefile.hal | 1 - 1 file changed, 1 deletion(-) diff --git a/common/Makefile.hal b/common/Makefile.hal index d6f87a2e6..58311189f 100644 --- a/common/Makefile.hal +++ b/common/Makefile.hal @@ -75,7 +75,6 @@ PLATFORM_DEFS += \ # !! Choose only one !! PLATFORM_DEFS += -DWITH_STANDALONE_LF_SAMYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_LF_ICERUN -#PLATFORM_DEFS += -DWITH_STANDALONE_LF_SAMYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_LF_PROXBRUTE #PLATFORM_DEFS += -DWITH_STANDALONE_LF_HIDBRUTE #PLATFORM_DEFS += -DWITH_STANDALONE_HF_YOUNG From f90b04d4cf9eceeeb3d35b37d2e89620ac07a919 Mon Sep 17 00:00:00 2001 From: Iceman Date: Thu, 25 Apr 2019 23:20:33 +0200 Subject: [PATCH 2/6] Update readme.md --- armsrc/Standalone/readme.md | 64 +++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/armsrc/Standalone/readme.md b/armsrc/Standalone/readme.md index 85cbdb1ca..403134620 100644 --- a/armsrc/Standalone/readme.md +++ b/armsrc/Standalone/readme.md @@ -1,23 +1,32 @@ # StandAlone Modes -This contains functionality for different StandAlone modes. The fullimage will be built given the correct compiler flags used. Build targets for these files are contained in `armsrc/Makefile`. +This contains functionality for different StandAlone modes. The fullimage will be built given the correct compiler flags used. Build targets for these files are contained in `armsrc/Makefile` and `common/Makefile.hal` If you want to implement a new standalone mode, you need to implement the methods provided in `standalone.h`. -Have a look at the skeleton standalone mode called IceRun, in the files `lf_icerun.c lf_icerun.h`. +Have a look at the skeleton standalone mode called IceRun, in the files `lf_icerun.c lf_icerun.h`. + +As it is now, you can only have one standalone mode installed at the time. ## Implementing a standalone mode -Each standalone mod needs to have its own compiler flag to be added in `armsrc\makefile`. +We suggest you keep your standalone code inside the Armsrc/Standalone folder. And that you name your files according to your standalone mode name. + +The `standalone.h` states that you must have two function implemented. + +The ModInfo function, which is your identification of your standalone mode. This string will show when running the command `hw status` on the client. + +The RunMod function, which is your "main" function when running. You need to check for Usb commands, in order to let the pm3 client break the standalone mode. See this basic skeleton of main function RunMod() and Modinfo() below. -The RunMod function is your "main" function when running. You need to check for Usb commands, in order to let the pm3 client break the standalone mode. See this basic skeleton of main function RunMod(). ```` void ModInfo(void) { - DbpString(" HF good description of your mode - (my name)"); + DbpString(" LF good description of your mode - aka FooRun (my name)"); } void RunMod(void) { // led show StandAloneMode(); + + // Do you target LF or HF? FpgaDownloadAndGo(FPGA_BITSTREAM_LF); // main loop @@ -31,11 +40,24 @@ void RunMod(void) { } ```` -As it is now, you can only have one standalone mode installed at the time. +Each standalone mode needs to have its own compiler flag to be added in `armsrc\makefile`. -## Name -Use HF/LF to denote which frequence your mod is targeting. -Use you own github name/similar for perpetual honour to denote your mod +## Naming your standalone mode + +We suggest that you follow these guidelines, +- Use HF/LF to denote which frequence your mod is targeting. +- Use you own github name/similar for perpetual honour to denote your mode. + +sample: + `LF_FOORUN` + +Which indicates your mode targets LF and is called FOO. + +This leads to your next step, your DEFINE name needed in Makefile. +`WITH_STANDALONE_LF_FOORUN` + + +## Update COMMON/MAKEFILE.HAL Samples of directive flag used in the `common/Makefile.hal`: ``` @@ -49,24 +71,32 @@ Samples of directive flag used in the `common/Makefile.hal`: #PLATFORM_DEFS += -DWITH_STANDALONE_HF_COLIN #PLATFORM_DEFS += -DWITH_STANDALONE_HF_BOG ``` -Add your source code file like the following sample in the `armsrc/Makefile` + +## Update ARMSRC/MAKEFILE +Add your source code files like the following sample in the `armsrc/Makefile` ``` -# WITH_STANDALONE_HF_COLIN -ifneq (,$(findstring WITH_STANDALONE_HF_COLIN,$(APP_CFLAGS))) - SRC_STANDALONE = hf_colin.c vtsend.c -else - SRC_STANDALONE = +# WITH_STANDALONE_LF_FOO +ifneq (,$(findstring WITH_STANDALONE_LF_FOO,$(APP_CFLAGS))) + SRC_STANDALONE = lf_foo.c endif ``` -## Adding identification of your mode +## Adding identification string of your mode Do please add a identification string in a function called `ModInfo` inside your source code file. This will enable an easy way to detect on client side which standalone mods has been installed on the device. +```` +void ModInfo(void) { + DbpString(" LF good description of your mode - aka FooRun (my name)"); +} +```` + ## Compiling your standalone mode Once all this is done, you and others can now easily compile different standalone modes by just selecting one of the standalone modes in `common/Makefile.hal`, e.g.: ``` -PLATFORM_DEFS += -DWITH_STANDALONE_HF_COLIN +PLATFORM_DEFS += -DWITH_STANDALONE_LF_FOO ``` + +Remember only one can be selected at a time for now. From 1e797e17206a94c91027c91ea9b9b70a4c2fdc92 Mon Sep 17 00:00:00 2001 From: Iceman Date: Thu, 25 Apr 2019 23:20:54 +0200 Subject: [PATCH 3/6] Update readme.md --- armsrc/Standalone/readme.md | 1 - 1 file changed, 1 deletion(-) diff --git a/armsrc/Standalone/readme.md b/armsrc/Standalone/readme.md index 403134620..5a8dbde1d 100644 --- a/armsrc/Standalone/readme.md +++ b/armsrc/Standalone/readme.md @@ -63,7 +63,6 @@ Samples of directive flag used in the `common/Makefile.hal`: ``` #PLATFORM_DEFS += -DWITH_STANDALONE_LF_SAMYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_LF_ICERUN -#PLATFORM_DEFS += -DWITH_STANDALONE_LF_SAMYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_LF_PROXBRUTE #PLATFORM_DEFS += -DWITH_STANDALONE_LF_HIDBRUTE #PLATFORM_DEFS += -DWITH_STANDALONE_HF_YOUNG From 839a0ef9fb8b279d84c94315a98fcfa3adb52d77 Mon Sep 17 00:00:00 2001 From: Iceman Date: Thu, 25 Apr 2019 23:23:44 +0200 Subject: [PATCH 4/6] Update readme.md --- armsrc/Standalone/readme.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/armsrc/Standalone/readme.md b/armsrc/Standalone/readme.md index 5a8dbde1d..1bf1a385f 100644 --- a/armsrc/Standalone/readme.md +++ b/armsrc/Standalone/readme.md @@ -54,12 +54,13 @@ sample: Which indicates your mode targets LF and is called FOO. This leads to your next step, your DEFINE name needed in Makefile. + `WITH_STANDALONE_LF_FOORUN` ## Update COMMON/MAKEFILE.HAL -Samples of directive flag used in the `common/Makefile.hal`: +Samples of directive flag used in the `common/Makefile.ha` and your suggested DEFINE. ``` #PLATFORM_DEFS += -DWITH_STANDALONE_LF_SAMYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_LF_ICERUN @@ -69,12 +70,18 @@ Samples of directive flag used in the `common/Makefile.hal`: #PLATFORM_DEFS += -DWITH_STANDALONE_HF_MATTYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_HF_COLIN #PLATFORM_DEFS += -DWITH_STANDALONE_HF_BOG +#PLATFORM_DEFS += -DWITH_STANDALONE_LF_FOORUN ``` ## Update ARMSRC/MAKEFILE Add your source code files like the following sample in the `armsrc/Makefile` ``` +# WITH_STANDALONE_LF_ICERUN +ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS))) + SRC_STANDALONE = lf_icerun.c +endif + # WITH_STANDALONE_LF_FOO ifneq (,$(findstring WITH_STANDALONE_LF_FOO,$(APP_CFLAGS))) SRC_STANDALONE = lf_foo.c From 9a6ad6597f09f9cc628588b987dc5ae1eb7a78bb Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 25 Apr 2019 23:40:51 +0200 Subject: [PATCH 5/6] update standalone readme --- armsrc/Standalone/readme.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/armsrc/Standalone/readme.md b/armsrc/Standalone/readme.md index 1bf1a385f..c9f7946ad 100644 --- a/armsrc/Standalone/readme.md +++ b/armsrc/Standalone/readme.md @@ -9,17 +9,17 @@ As it is now, you can only have one standalone mode installed at the time. ## Implementing a standalone mode -We suggest you keep your standalone code inside the Armsrc/Standalone folder. And that you name your files according to your standalone mode name. +We suggest you keep your standalone code inside the `armsrc/Standalone` folder. And that you name your files according to your standalone mode name. -The `standalone.h` states that you must have two function implemented. +The `standalone.h` states that you must have two functions implemented. The ModInfo function, which is your identification of your standalone mode. This string will show when running the command `hw status` on the client. -The RunMod function, which is your "main" function when running. You need to check for Usb commands, in order to let the pm3 client break the standalone mode. See this basic skeleton of main function RunMod() and Modinfo() below. +The RunMod function, which is your "main" function when running. You need to check for Usb commands, in order to let the pm3 client break the standalone mode. See this basic skeleton of main function RunMod() and Modinfo() below. ```` void ModInfo(void) { - DbpString(" LF good description of your mode - aka FooRun (my name)"); + DbpString(" LF good description of your mode - aka FooRun (your name)"); } void RunMod(void) { @@ -40,27 +40,27 @@ void RunMod(void) { } ```` -Each standalone mode needs to have its own compiler flag to be added in `armsrc\makefile`. +Each standalone mode needs to have its own compiler flag to be added in `armsrc/Makefile`. ## Naming your standalone mode -We suggest that you follow these guidelines, -- Use HF/LF to denote which frequence your mod is targeting. +We suggest that you follow these guidelines: +- Use HF/LF to denote which frequency your mode is targeting. - Use you own github name/similar for perpetual honour to denote your mode. sample: - `LF_FOORUN` + `LF_FOO` Which indicates your mode targets LF and is called FOO. This leads to your next step, your DEFINE name needed in Makefile. -`WITH_STANDALONE_LF_FOORUN` +`WITH_STANDALONE_LF_FOO` ## Update COMMON/MAKEFILE.HAL -Samples of directive flag used in the `common/Makefile.ha` and your suggested DEFINE. +Add your suggested DEFINE to the samples of directive flag provided in the `common/Makefile.hal`. ``` #PLATFORM_DEFS += -DWITH_STANDALONE_LF_SAMYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_LF_ICERUN @@ -70,7 +70,7 @@ Samples of directive flag used in the `common/Makefile.ha` and your suggested DE #PLATFORM_DEFS += -DWITH_STANDALONE_HF_MATTYRUN #PLATFORM_DEFS += -DWITH_STANDALONE_HF_COLIN #PLATFORM_DEFS += -DWITH_STANDALONE_HF_BOG -#PLATFORM_DEFS += -DWITH_STANDALONE_LF_FOORUN +#PLATFORM_DEFS += -DWITH_STANDALONE_LF_FOO ``` ## Update ARMSRC/MAKEFILE @@ -90,11 +90,11 @@ endif ## Adding identification string of your mode Do please add a identification string in a function called `ModInfo` inside your source code file. -This will enable an easy way to detect on client side which standalone mods has been installed on the device. +This will enable an easy way to detect on client side which standalone mode has been installed on the device. ```` void ModInfo(void) { - DbpString(" LF good description of your mode - aka FooRun (my name)"); + DbpString(" LF good description of your mode - aka FooRun (your name)"); } ```` From 7d6f971db4ca1b9c06e166c223e87b8306b5da8e Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 26 Apr 2019 00:04:32 +0200 Subject: [PATCH 6/6] archive and fix hid-flasher --- .../flasher}/Info.plist | 0 .../flasher}/Makefile | 11 ++++------- .../flasher}/elf.h | 0 .../flasher}/flash.c | 2 +- .../flasher}/flash.h | 0 .../flasher}/flasher.c | 2 +- .../flasher}/obj/.dummy | 0 .../flasher}/proxendian.h | 0 .../flasher}/proxmark3.h | 0 .../flasher}/proxusb.c | 1 + .../flasher}/proxusb.h | 1 - .../flasher}/sleep.h | 0 .../flasher}/usb_cmd.h | 0 client/{ => deprecated-hid-flasher}/unbind-proxmark | 0 14 files changed, 7 insertions(+), 10 deletions(-) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/Info.plist (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/Makefile (73%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/elf.h (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/flash.c (99%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/flash.h (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/flasher.c (99%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/obj/.dummy (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/proxendian.h (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/proxmark3.h (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/proxusb.c (99%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/proxusb.h (97%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/sleep.h (100%) rename client/{hid-flasher => deprecated-hid-flasher/flasher}/usb_cmd.h (100%) rename client/{ => deprecated-hid-flasher}/unbind-proxmark (100%) diff --git a/client/hid-flasher/Info.plist b/client/deprecated-hid-flasher/flasher/Info.plist similarity index 100% rename from client/hid-flasher/Info.plist rename to client/deprecated-hid-flasher/flasher/Info.plist diff --git a/client/hid-flasher/Makefile b/client/deprecated-hid-flasher/flasher/Makefile similarity index 73% rename from client/hid-flasher/Makefile rename to client/deprecated-hid-flasher/flasher/Makefile index 90b29748f..bff511459 100644 --- a/client/hid-flasher/Makefile +++ b/client/deprecated-hid-flasher/flasher/Makefile @@ -3,26 +3,23 @@ # at your option, any later version. See the LICENSE.txt file for the text of # the license. #----------------------------------------------------------------------------- -include ../../common/Makefile.common CC=gcc CXX=g++ #COMMON_FLAGS = -m32 -VPATH = ../../common OBJDIR = obj +LDLIBS = -lreadline -lpthread +CFLAGS = -std=gnu99 -Wall -Wno-unused-function $(COMMON_FLAGS) -g -O3 ifeq ($(platform),Darwin) - LDLIBS = -L/opt/local/lib -L/usr/local/lib -lusb-1.0 -lreadline -lpthread - CFLAGS = -std=gnu99 -I. -I../include -I../common -I/usr/local/include -I/opt/local/include -Wall -Wno-unused-function $(COMMON_FLAGS) -g -O3 + LDLIBS += -lusb-1.0 else - LDLIBS = -L/opt/local/lib -L/usr/local/lib -lusb -lreadline -lpthread - CFLAGS = -std=gnu99 -I. -I../include -I../common -I/opt/local/include -Wall -Wno-unused-function $(COMMON_FLAGS) -g -O3 + LDLIBS += -lusb endif LDFLAGS = $(COMMON_FLAGS) CXXFLAGS = -QTLDLIBS = RM = rm -f BINS = flasher diff --git a/client/hid-flasher/elf.h b/client/deprecated-hid-flasher/flasher/elf.h similarity index 100% rename from client/hid-flasher/elf.h rename to client/deprecated-hid-flasher/flasher/elf.h diff --git a/client/hid-flasher/flash.c b/client/deprecated-hid-flasher/flasher/flash.c similarity index 99% rename from client/hid-flasher/flash.c rename to client/deprecated-hid-flasher/flasher/flash.c index 22f57a817..48d0f00de 100644 --- a/client/hid-flasher/flash.c +++ b/client/deprecated-hid-flasher/flasher/flash.c @@ -11,11 +11,11 @@ #include #include #include -#include "util_posix.h" #include "proxusb.h" #include "flash.h" #include "elf.h" #include "proxendian.h" +#include "sleep.h" #define FLASH_START 0x100000 #define FLASH_SIZE (256*1024) diff --git a/client/hid-flasher/flash.h b/client/deprecated-hid-flasher/flasher/flash.h similarity index 100% rename from client/hid-flasher/flash.h rename to client/deprecated-hid-flasher/flasher/flash.h diff --git a/client/hid-flasher/flasher.c b/client/deprecated-hid-flasher/flasher/flasher.c similarity index 99% rename from client/hid-flasher/flasher.c rename to client/deprecated-hid-flasher/flasher/flasher.c index 0cc800826..f9d5f49b7 100644 --- a/client/hid-flasher/flasher.c +++ b/client/deprecated-hid-flasher/flasher/flasher.c @@ -9,9 +9,9 @@ #include #include #include -#include "util_posix.h" #include "proxusb.h" #include "flash.h" +#include "sleep.h" static void usage(char *argv0) { fprintf(stderr, "Usage: %s [-b] image.elf [image.elf...]\n\n", argv0); diff --git a/client/hid-flasher/obj/.dummy b/client/deprecated-hid-flasher/flasher/obj/.dummy similarity index 100% rename from client/hid-flasher/obj/.dummy rename to client/deprecated-hid-flasher/flasher/obj/.dummy diff --git a/client/hid-flasher/proxendian.h b/client/deprecated-hid-flasher/flasher/proxendian.h similarity index 100% rename from client/hid-flasher/proxendian.h rename to client/deprecated-hid-flasher/flasher/proxendian.h diff --git a/client/hid-flasher/proxmark3.h b/client/deprecated-hid-flasher/flasher/proxmark3.h similarity index 100% rename from client/hid-flasher/proxmark3.h rename to client/deprecated-hid-flasher/flasher/proxmark3.h diff --git a/client/hid-flasher/proxusb.c b/client/deprecated-hid-flasher/flasher/proxusb.c similarity index 99% rename from client/hid-flasher/proxusb.c rename to client/deprecated-hid-flasher/flasher/proxusb.c index 7563429d8..71bb0708c 100644 --- a/client/hid-flasher/proxusb.c +++ b/client/deprecated-hid-flasher/flasher/proxusb.c @@ -9,6 +9,7 @@ // USB utilities //----------------------------------------------------------------------------- #include "proxusb.h" +#include "sleep.h" // It seems to be missing for mingw #ifndef ETIMEDOUT diff --git a/client/hid-flasher/proxusb.h b/client/deprecated-hid-flasher/flasher/proxusb.h similarity index 97% rename from client/hid-flasher/proxusb.h rename to client/deprecated-hid-flasher/flasher/proxusb.h index 69d47abd2..f79fd7e33 100644 --- a/client/hid-flasher/proxusb.h +++ b/client/deprecated-hid-flasher/flasher/proxusb.h @@ -22,7 +22,6 @@ #include #include "proxmark3.h" #include "usb_cmd.h" -#include "util_posix.h" extern unsigned char return_on_error; extern unsigned char error_occured; diff --git a/client/hid-flasher/sleep.h b/client/deprecated-hid-flasher/flasher/sleep.h similarity index 100% rename from client/hid-flasher/sleep.h rename to client/deprecated-hid-flasher/flasher/sleep.h diff --git a/client/hid-flasher/usb_cmd.h b/client/deprecated-hid-flasher/flasher/usb_cmd.h similarity index 100% rename from client/hid-flasher/usb_cmd.h rename to client/deprecated-hid-flasher/flasher/usb_cmd.h diff --git a/client/unbind-proxmark b/client/deprecated-hid-flasher/unbind-proxmark similarity index 100% rename from client/unbind-proxmark rename to client/deprecated-hid-flasher/unbind-proxmark