proxmark3/armsrc/Standalone/readme.md

144 lines
4.7 KiB
Markdown
Raw Normal View History

2019-06-17 15:38:50 +08:00
# Standalone Modes
2017-08-26 19:01:35 +08:00
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`
2017-08-26 19:01:35 +08:00
2017-10-22 23:00:53 +08:00
If you want to implement a new standalone mode, you need to implement the methods provided in `standalone.h`.
2019-04-26 05:20:33 +08:00
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.
2017-08-26 19:01:35 +08:00
2017-10-22 23:00:53 +08:00
## Implementing a standalone mode
2017-08-26 19:01:35 +08:00
2019-04-26 05:40:51 +08:00
We suggest you keep your standalone code inside the `armsrc/Standalone` folder. And that you name your files according to your standalone mode name.
2019-04-26 05:20:33 +08:00
2019-04-26 05:40:51 +08:00
The `standalone.h` states that you must have two functions implemented.
2019-04-26 05:20:33 +08:00
The ModInfo function, which is your identification of your standalone mode. This string will show when running the command `hw status` on the client.
2019-04-26 05:40:51 +08:00
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.
2018-09-04 04:36:43 +08:00
2018-09-04 04:45:01 +08:00
````
2019-04-26 03:50:55 +08:00
void ModInfo(void) {
2019-07-10 04:49:57 +08:00
DbpString(" LF good description of your mode - aka FooRun (your name)");
2019-04-26 03:50:55 +08:00
}
void RunMod(void) {
// led show
StandAloneMode();
2019-04-26 05:20:33 +08:00
// Do you target LF or HF?
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
// main loop
for (;;) {
WDT_HIT();
// exit from standalone mode, just send a usbcommand
if (data_available()) break;
// do your standalone stuff..
}
2018-09-04 04:45:01 +08:00
````
2017-08-26 19:01:35 +08:00
2019-04-26 05:20:33 +08:00
## Naming your standalone mode
2019-04-26 05:40:51 +08:00
We suggest that you follow these guidelines:
- Use HF/LF to denote which frequency your mode is targeting.
2019-04-26 05:20:33 +08:00
- Use you own github name/similar for perpetual honour to denote your mode.
sample:
2019-04-26 05:40:51 +08:00
`LF_FOO`
2017-10-22 23:00:53 +08:00
2019-04-26 05:20:33 +08:00
Which indicates your mode targets LF and is called FOO.
This leads to your next step, your DEFINE name needed in Makefile.
2019-04-26 05:23:44 +08:00
2019-04-26 05:40:51 +08:00
`WITH_STANDALONE_LF_FOO`
2019-04-26 05:20:33 +08:00
## Update MAKEFILE.HAL
2017-08-26 19:01:35 +08:00
Add your mode to the `Makefile.hal` help and modes list:
2018-09-04 04:45:01 +08:00
```
2019-06-01 06:23:38 +08:00
+==========================================================+
| STANDALONE | DESCRIPTION |
+==========================================================+
...
+----------------------------------------------------------+
| LF_FOO | My foobar mode will make you coffee |
+----------------------------------------------------------+
STANDALONE_MODES := LF_SAMYRUN LF_ICERUN LF_PROXBRUTE LF_HIDBRUTE LF_FOO
STANDALONE_MODES += HF_YOUNG HF_MATTYRUN HF_COLIN HF_BOG
2018-09-04 04:45:01 +08:00
```
If your mode is using one of the unique features of the RDV4, add it to the proper list:
```
STANDALONE_MODES_REQ_SMARTCARD :=
STANDALONE_MODES_REQ_FLASH := HF_COLIN HF_BOG
```
2019-04-26 05:20:33 +08:00
## Update MAKEFILE.INC
Add your source code files like the following sample in the `Makefile.inc`
2018-09-04 04:36:43 +08:00
```
2019-04-26 05:23:44 +08:00
# WITH_STANDALONE_LF_ICERUN
ifneq (,$(findstring WITH_STANDALONE_LF_ICERUN,$(APP_CFLAGS)))
2019-07-10 04:49:57 +08:00
SRC_STANDALONE = lf_icerun.c
2019-04-26 05:23:44 +08:00
endif
2019-04-26 05:20:33 +08:00
# WITH_STANDALONE_LF_FOO
ifneq (,$(findstring WITH_STANDALONE_LF_FOO,$(APP_CFLAGS)))
SRC_STANDALONE = lf_foo.c
2018-09-04 04:36:43 +08:00
endif
```
2019-04-26 05:20:33 +08:00
## Adding identification string of your mode
2019-04-26 03:50:55 +08:00
Do please add a identification string in a function called `ModInfo` inside your source code file.
2019-04-26 05:40:51 +08:00
This will enable an easy way to detect on client side which standalone mode has been installed on the device.
2018-09-04 04:36:43 +08:00
2019-04-26 05:20:33 +08:00
````
void ModInfo(void) {
2019-07-10 04:49:57 +08:00
DbpString(" LF good description of your mode - aka FooRun (your name)");
2019-04-26 05:20:33 +08:00
}
````
2019-04-26 03:50:55 +08:00
## 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 `Makefile.hal` or ) , e.g.:
2018-09-04 04:36:43 +08:00
2019-06-17 15:38:50 +08:00
- rename Makefile.platform.sample -> Makefile.platform
- edit the "STANDALONE" row inside Makefile.platform. You need to uncomment it and add your standalone mode name
Makefile.platform.sample
```
# If you want to use it, copy this file as Makefile.platform and adjust it to your needs
PLATFORM=PM3RDV4
#PLATFORM_EXTRAS=BTADDON
#STANDALONE=LF_SAMYRUN
```
2019-06-17 15:38:50 +08:00
becomes
Makefile.platform
```
# If you want to use it, copy this file as Makefile.platform and adjust it to your needs
PLATFORM=PM3RDV4
#PLATFORM_EXTRAS=BTADDON
STANDALONE=LF_FOO
```
2019-04-26 05:20:33 +08:00
Remember only one can be selected at a time for now.
2019-06-17 15:38:50 +08:00
The final steps is to
- force recompilation of all code. ```make clean```
- compile ```make -j8```
- flash your device
- connect to your device
- press button long time to trigger ledshow and enter your new standalone mode
- if connected with usb / fpc , you can also see debug statements from your device in standalone mode. Useful for debugging :)
When compiling you will see a header showing what configurations your project compiled with.
Make sure it says your standalone mode name.
Happy hacking!