diff --git a/armsrc/Makefile b/armsrc/Makefile index 7fee5c79b..6d3921084 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -68,41 +68,7 @@ else endif # Generic standalone Mode injection of source code - - -SRC_STANDALONE = placeholder.c -# WITH_STANDALONE_LF_ICERUN -ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS))) - SRC_STANDALONE = lf_icerun.c -endif -# WITH_STANDALONE_LF_SAMYRUN -ifneq (,$(findstring WITH_STANDALONE_LF_SAMYRUN,$(APP_CFLAGS))) - SRC_STANDALONE = lf_samyrun.c -endif -# WITH_STANDALONE_LF_PROXBRUTE -ifneq (,$(findstring WITH_STANDALONE_LF_PROXBRUTE,$(APP_CFLAGS))) - SRC_STANDALONE = lf_proxbrute.c -endif -# WITH_STANDALONE_LF_HIDBRUTE -ifneq (,$(findstring WITH_STANDALONE_LF_HIDBRUTE,$(APP_CFLAGS))) - SRC_STANDALONE = lf_hidbrute.c -endif -# WITH_STANDALONE_HF_YOUNG -ifneq (,$(findstring WITH_STANDALONE_HF_YOUNG,$(APP_CFLAGS))) - SRC_STANDALONE = hf_young.c -endif -# WITH_STANDALONE_HF_MATTYRUN -ifneq (,$(findstring WITH_STANDALONE_HF_MATTYRUN,$(APP_CFLAGS))) - SRC_STANDALONE = hf_mattyrun.c -endif -# WITH_STANDALONE_HF_COLIN -ifneq (,$(findstring WITH_STANDALONE_HF_COLIN,$(APP_CFLAGS))) - SRC_STANDALONE = vtsend.c hf_colin.c -endif -# WITH_STANDALONE_HF_BOG -ifneq (,$(findstring WITH_STANDALONE_HF_BOG,$(APP_CFLAGS))) - SRC_STANDALONE = hf_bog.c -endif +include Standalone/Makefile.inc #the FPGA bitstream files. Note: order matters! FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit diff --git a/armsrc/Standalone/Makefile.hal b/armsrc/Standalone/Makefile.hal new file mode 100644 index 000000000..6181b5072 --- /dev/null +++ b/armsrc/Standalone/Makefile.hal @@ -0,0 +1,46 @@ +# Default standalone if no standalone specified +DEFAULT_STANDALONE=LF_SAMYRUN +HELP_EXAMPLE_STANDALONE=HF_COLIN +# (you can set explicitly STANDALONE= to disable standalone modes) +STANDALONE?=$(DEFAULT_STANDALONE) + +define KNOWN_STANDALONE_DEFINITIONS ++==========================================================+ +| STANDALONE | DESCRIPTION | ++==========================================================+ +| | No standalone mode | ++----------------------------------------------------------+ +| LF_SAMYRUN (def)| HID26 read/clone/sim | +| | - Samy Kamkar | ++----------------------------------------------------------+ +| LF_ICERUN | standalone mode skeleton | +| | - iceman | ++----------------------------------------------------------+ +| LF_PROXBRUTE | HID ProxII bruteforce | +| | - Brad Antoniewicz | ++----------------------------------------------------------+ +| LF_HIDBRUTE | HID corporate 1000 bruteforce | +| | - Federico dotta & Maurizio Agazzini | ++----------------------------------------------------------+ +| HF_YOUNG | Mifare sniff/simulation | +| | - Craig Young | ++----------------------------------------------------------+ +| HF_MATTYRUN | Mifare sniff/clone | +| | - Matías A. Ré Medina | ++----------------------------------------------------------+ +| HF_COLIN | Mifare ultra fast sniff/sim/clone | +| | - Colin Brigato | ++----------------------------------------------------------+ +| HF_BOG | 14a sniff with ULC/ULEV1/NTAG auth | +| | storing in flashmem - Bogito | ++----------------------------------------------------------+ + +endef + +STANDALONE_MODES := LF_SAMYRUN LF_ICERUN LF_PROXBRUTE LF_HIDBRUTE +STANDALONE_MODES += HF_YOUNG HF_MATTYRUN HF_COLIN HF_BOG +ifneq ($(filter $(STANDALONE),$(STANDALONE_MODES)),) + STANDALONE_PLATFORM_DEFS += -DWITH_STANDALONE_$(STANDALONE) +else ifneq ($(STANDALONE),) + $(error Invalid STANDALONE: $(STANDALONE). $(KNOWN_DEFINITIONS)) +endif diff --git a/armsrc/Standalone/Makefile.inc b/armsrc/Standalone/Makefile.inc new file mode 100644 index 000000000..cc7221a73 --- /dev/null +++ b/armsrc/Standalone/Makefile.inc @@ -0,0 +1,36 @@ +# Generic standalone Mode injection of source code + +SRC_STANDALONE = placeholder.c +# WITH_STANDALONE_LF_ICERUN +ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS))) + SRC_STANDALONE = lf_icerun.c +endif +# WITH_STANDALONE_LF_SAMYRUN +ifneq (,$(findstring WITH_STANDALONE_LF_SAMYRUN,$(APP_CFLAGS))) + SRC_STANDALONE = lf_samyrun.c +endif +# WITH_STANDALONE_LF_PROXBRUTE +ifneq (,$(findstring WITH_STANDALONE_LF_PROXBRUTE,$(APP_CFLAGS))) + SRC_STANDALONE = lf_proxbrute.c +endif +# WITH_STANDALONE_LF_HIDBRUTE +ifneq (,$(findstring WITH_STANDALONE_LF_HIDBRUTE,$(APP_CFLAGS))) + SRC_STANDALONE = lf_hidbrute.c +endif +# WITH_STANDALONE_HF_YOUNG +ifneq (,$(findstring WITH_STANDALONE_HF_YOUNG,$(APP_CFLAGS))) + SRC_STANDALONE = hf_young.c +endif +# WITH_STANDALONE_HF_MATTYRUN +ifneq (,$(findstring WITH_STANDALONE_HF_MATTYRUN,$(APP_CFLAGS))) + SRC_STANDALONE = hf_mattyrun.c +endif +# WITH_STANDALONE_HF_COLIN +ifneq (,$(findstring WITH_STANDALONE_HF_COLIN,$(APP_CFLAGS))) + SRC_STANDALONE = vtsend.c hf_colin.c +endif +# WITH_STANDALONE_HF_BOG +ifneq (,$(findstring WITH_STANDALONE_HF_BOG,$(APP_CFLAGS))) + SRC_STANDALONE = hf_bog.c +endif + diff --git a/armsrc/Standalone/readme.md b/armsrc/Standalone/readme.md index 8d2420def..4ff83b9fd 100644 --- a/armsrc/Standalone/readme.md +++ b/armsrc/Standalone/readme.md @@ -1,6 +1,6 @@ # 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` and `common/Makefile.hal` +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 `Makefile.inc` and `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`. @@ -40,8 +40,6 @@ void RunMod(void) { } ```` -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: @@ -58,9 +56,9 @@ This leads to your next step, your DEFINE name needed in Makefile. `WITH_STANDALONE_LF_FOO` -## Update COMMON/MAKEFILE.HAL +## Update MAKEFILE.HAL -Add your mode to the `common/Makefile.hal` help and modes list: +Add your mode to the `Makefile.hal` help and modes list: ``` +==========================================================+ | STANDALONE | DESCRIPTION | @@ -74,8 +72,8 @@ STANDALONE_MODES := LF_SAMYRUN LF_ICERUN LF_PROXBRUTE LF_HIDBRUTE LF_FOO STANDALONE_MODES += HF_YOUNG HF_MATTYRUN HF_COLIN HF_BOG ``` -## Update ARMSRC/MAKEFILE -Add your source code files like the following sample in the `armsrc/Makefile` +## Update MAKEFILE.INC +Add your source code files like the following sample in the `Makefile.inc` ``` # WITH_STANDALONE_LF_ICERUN @@ -100,7 +98,7 @@ void ModInfo(void) { ```` ## 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 (list in `common/Makefile.hal` or ) , e.g.: +Once all this is done, you and others can now easily compile different standalone modes by just selecting one of the standalone modes (list in `Makefile.hal` or ) , e.g.: - rename Makefile.platform.sample -> Makefile.platform - edit the "STANDALONE" row inside Makefile.platform. You need to uncomment it and add your standalone mode name diff --git a/common/Makefile.hal b/common/Makefile.hal index ff3f83a4c..bf9231f5c 100644 --- a/common/Makefile.hal +++ b/common/Makefile.hal @@ -1,10 +1,14 @@ # Default platform if no platform specified PLATFORM?=PM3RDV4 -# Default standalone if no standalone specified -# (you can set explicitly STANDALONE= to disable standalone modes) -STANDALONE?=LF_SAMYRUN -define KNOWN_DEFINITIONS +# Standalone Mode info (path depends if make is called at top or from armsrc) +-include armsrc/Standalone/Makefile.hal +-include Standalone/Makefile.hal +ifndef DEFAULT_STANDALONE +$(error Could not find armsrc/Standalone/Makefile.hal) +endif + +define KNOWN_PLATFORM_DEFINITIONS Known definitions: @@ -30,39 +34,12 @@ Known definitions: | BTADDON | Proxmark3 rdv4 BT add-on | +----------------------------------------------------------+ -+==========================================================+ -| STANDALONE | DESCRIPTION | -+==========================================================+ -| | No standalone mode | -+----------------------------------------------------------+ -| LF_SAMYRUN (def)| HID26 read/clone/sim | -| | - Samy Kamkar | -+----------------------------------------------------------+ -| LF_ICERUN | standalone mode skeleton | -| | - iceman | -+----------------------------------------------------------+ -| LF_PROXBRUTE | HID ProxII bruteforce | -| | - Brad Antoniewicz | -+----------------------------------------------------------+ -| LF_HIDBRUTE | HID corporate 1000 bruteforce | -| | - Federico dotta & Maurizio Agazzini | -+----------------------------------------------------------+ -| HF_YOUNG | Mifare sniff/simulation | -| | - Craig Young | -+----------------------------------------------------------+ -| HF_MATTYRUN | Mifare sniff/clone | -| | - Matías A. Ré Medina | -+----------------------------------------------------------+ -| HF_COLIN | Mifare ultra fast sniff/sim/clone | -| | - Colin Brigato | -+----------------------------------------------------------+ -| HF_BOG | 14a sniff with ULC/ULEV1/NTAG auth | -| | storing in flashmem - Bogito | -+----------------------------------------------------------+ +endef +define HELP_DEFINITIONS Options to define platform, platform extras and/or standalone mode: (1) Run make with PLATFORM, PLATFORM_EXTRAS and/or STANDALONE as follows: -make PLATFORM=PM3EASY STANDALONE=HF_COLIN +make PLATFORM=PM3EASY STANDALONE=$(HELP_EXAMPLE_STANDALONE) (2) Save a file called Makefile.platform with contents: PLATFORM=PM3EASY @@ -71,11 +48,17 @@ or if you have a Proxmark 3 RDV4 with the BT add-on: PLATFORM=PM3RDV4 PLATFORM_EXTRAS=BTADDON -Default standalone mode is LF_SAMYRUN. +Default standalone mode is $(DEFAULT_STANDALONE). To disable standalone modes, set explicitly an empty STANDALONE: STANDALONE= endef +define KNOWN_DEFINITIONS +$(KNOWN_PLATFORM_DEFINITIONS) +$(KNOWN_STANDALONE_DEFINITIONS) +$(HELP_DEFINITIONS) +endef + PLTNAME = Unknown Platform ifeq ($(PLATFORM),PM3RDV4) @@ -131,13 +114,7 @@ PLATFORM_DEFS += \ -DWITH_HFSNIFF # Standalone mode -STANDALONE_MODES := LF_SAMYRUN LF_ICERUN LF_PROXBRUTE LF_HIDBRUTE -STANDALONE_MODES += HF_YOUNG HF_MATTYRUN HF_COLIN HF_BOG -ifneq ($(filter $(STANDALONE),$(STANDALONE_MODES)),) - PLATFORM_DEFS += -DWITH_STANDALONE_$(STANDALONE) -else ifneq ($(STANDALONE),) - $(error Invalid STANDALONE: $(STANDALONE). $(KNOWN_DEFINITIONS)) -endif +PLATFORM_DEFS+=$(STANDALONE_PLATFORM_DEFS) $(info $(findstring WITH_STANDALONE_*,$(PLATFORM_DEFS))) @@ -171,15 +148,6 @@ ifeq (,$(PLATFORM_DEFS_INFO_STANDALONE)) PLATFORM_DEFS_INFO_STANDALONE = No standalone mode selected endif -export PLATFORM -export PLATFORM_EXTRAS -export PLATFORM_EXTRAS_INFO -export PLTNAME -export MCU -export PLATFORM_DEFS -export PLATFORM_DEFS_INFO -export PLATFORM_DEFS_INFO_STANDALONE - PLATFORM_CHANGED=false ifneq ($(PLATFORM), $(CACHED_PLATFORM)) PLATFORM_CHANGED=true @@ -189,6 +157,16 @@ else ifneq ($(PLATFORM_DEFS), $(CACHED_PLATFORM_DEFS)) PLATFORM_CHANGED=true endif +export PLATFORM +export PLATFORM_EXTRAS +export PLATFORM_EXTRAS_INFO +export PLTNAME +export MCU +export PLATFORM_DEFS +export PLATFORM_DEFS_INFO +export PLATFORM_DEFS_INFO_STANDALONE +export PLATFORM_CHANGED + $(info ===================================================================) $(info Platform name: $(PLTNAME)) $(info PLATFORM: $(PLATFORM))