correcting the standalone addons pathing.

adding some comments on standalone problematics
This commit is contained in:
iceman1001 2017-09-28 22:33:03 +02:00
parent a68887ce2d
commit 4dccc340ae
2 changed files with 30 additions and 6 deletions

View file

@ -21,6 +21,7 @@ APP_CFLAGS = -DWITH_CRC \
-DWITH_ISO14443a \ -DWITH_ISO14443a \
-DWITH_ICLASS \ -DWITH_ICLASS \
-DWITH_HFSNOOP \ -DWITH_HFSNOOP \
-DWITH_LF_SAMYRUN \
-fno-strict-aliasing -ffunction-sections -fdata-sections -fno-strict-aliasing -ffunction-sections -fdata-sections
### IMPORTANT - move the commented variable below this line ### IMPORTANT - move the commented variable below this line
# -DWITH_LCD \ # -DWITH_LCD \
@ -46,6 +47,8 @@ SRC_CRC = iso14443crc.c crc.c crc16.c crc32.c
SRC_EMV = tlv.c emvdataels.c emvutil.c emvcmd.c SRC_EMV = tlv.c emvdataels.c emvutil.c emvcmd.c
SRC_ICLASS = iclass.c optimized_cipher.c SRC_ICLASS = iclass.c optimized_cipher.c
SRC_LEGIC = legicrf.c legic_prng.c SRC_LEGIC = legicrf.c legic_prng.c
SRC_FLASH = flash.c
SRC_BEE = bee.c
#the FPGA bitstream files. Note: order matters! #the FPGA bitstream files. Note: order matters!
FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit
@ -78,8 +81,6 @@ THUMBSRC = start.c \
random.c \ random.c \
hfsnoop.c hfsnoop.c
# Standalone/hf_young.c \
# Standalone/lf_samyrun.c
# These are to be compiled in ARM mode # These are to be compiled in ARM mode
ARMSRC = fpgaloader.c \ ARMSRC = fpgaloader.c \
@ -91,7 +92,10 @@ ARMSRC = fpgaloader.c \
$(SRC_CRC) \ $(SRC_CRC) \
parity.c \ parity.c \
usb_cdc.c \ usb_cdc.c \
cmd.c cmd.c \
lf_samyrun.c \
# hf_young.c
# Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
include ../common/Makefile.common include ../common/Makefile.common

View file

@ -26,6 +26,9 @@
#include "LCD.h" #include "LCD.h"
#endif #endif
// Global var to determine if device is in standalone mode or not.
static int InStandAloneMode = 0;
//============================================================================= //=============================================================================
// A buffer where we can queue things up to be sent through the FPGA, for // A buffer where we can queue things up to be sent through the FPGA, for
// any purpose (fake tag, as reader, whatever). We go MSB first, since that // any purpose (fake tag, as reader, whatever). We go MSB first, since that
@ -360,6 +363,8 @@ void SendStatus(void) {
// Show some leds in a pattern to identify StandAlone mod is running // Show some leds in a pattern to identify StandAlone mod is running
void StandAloneMode(void) { void StandAloneMode(void) {
InStandAloneMode = 1;
DbpString("Stand-alone mode! No PC necessary."); DbpString("Stand-alone mode! No PC necessary.");
// Oooh pretty -- notify user we're in elite samy mode now // Oooh pretty -- notify user we're in elite samy mode now
LED(LED_RED, 200); LED(LED_RED, 200);
@ -375,9 +380,9 @@ void StandAloneMode(void) {
// detection of which Standalone Modes is installed // detection of which Standalone Modes is installed
// (iceman) // (iceman)
void printStandAloneModes(void) { void printStandAloneModes(void) {
#if defined(WITH_HF_YOUNG) || defined(WITH_LF_SAMYRUN)
DbpString("Installed StandAlone Mods"); DbpString("Installed StandAlone Mods");
#endif
#if defined(WITH_LF_ICERUN) #if defined(WITH_LF_ICERUN)
DbpString(" LF sniff/clone/simulation - aka IceRun (iceman)"); DbpString(" LF sniff/clone/simulation - aka IceRun (iceman)");
#endif #endif
@ -397,6 +402,9 @@ void printStandAloneModes(void) {
DbpString(" HF Mifare sniff/clone - aka MattyRun (Matta Real)"); DbpString(" HF Mifare sniff/clone - aka MattyRun (Matta Real)");
#endif #endif
DbpString("Running ");
Dbprintf(" Are we running standalone | %s", (InStandAloneMode)? "Yes" : "No");
//.. add your own standalone detection based on with compiler directive you are used. //.. add your own standalone detection based on with compiler directive you are used.
// don't "reuse" the already taken ones, this will make things easier when trying to detect the different modes // don't "reuse" the already taken ones, this will make things easier when trying to detect the different modes
// 2017-08-06 must adapt the makefile and have individual compilation flags for all mods // 2017-08-06 must adapt the makefile and have individual compilation flags for all mods
@ -1106,8 +1114,10 @@ void UsbPacketReceived(uint8_t *packet, int len) {
} }
void __attribute__((noreturn)) AppMain(void) { void __attribute__((noreturn)) AppMain(void) {
SpinDelay(100); SpinDelay(100);
clear_trace(); clear_trace();
if(common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) { if(common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
/* Initialize common area */ /* Initialize common area */
memset(&common_area, 0, sizeof(common_area)); memset(&common_area, 0, sizeof(common_area));
@ -1118,6 +1128,8 @@ void __attribute__((noreturn)) AppMain(void) {
LEDsoff(); LEDsoff();
// list with standalone refs.
// Init USB device // Init USB device
usb_enable(); usb_enable();
@ -1156,7 +1168,14 @@ void __attribute__((noreturn)) AppMain(void) {
} }
WDT_HIT(); WDT_HIT();
// Press button for one second to enter a possible standalone mode
if (BUTTON_HELD(1000) > 0) { if (BUTTON_HELD(1000) > 0) {
/*
* So this is the trigger to execute a standalone mod. Generic entrypoint by following the standalone/standalone.h headerfile
* All standalone mod "main loop" should be the RunMod() function.
* Since the standalone is either LF or HF, the somewhat bisarr defines below exists.
*/
#if defined (WITH_LF) && defined (WITH_LF_SAMYRUN) #if defined (WITH_LF) && defined (WITH_LF_SAMYRUN)
RunMod(); RunMod();
#endif #endif
@ -1164,7 +1183,8 @@ void __attribute__((noreturn)) AppMain(void) {
#if defined (WITH_ISO14443a) && defined (WITH_HF_YOUNG) #if defined (WITH_ISO14443a) && defined (WITH_HF_YOUNG)
RunMod(); RunMod();
#endif #endif
// when here, we are no longer in standalone mode.
InStandAloneMode = 0;
} }
} }
} }