diff --git a/armsrc/Makefile b/armsrc/Makefile index d0e080005..0e15a4034 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -21,6 +21,7 @@ APP_CFLAGS = -DWITH_CRC \ -DWITH_ISO14443a \ -DWITH_ICLASS \ -DWITH_HFSNOOP \ + -DWITH_LF_SAMYRUN \ -fno-strict-aliasing -ffunction-sections -fdata-sections ### IMPORTANT - move the commented variable below this line # -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_ICLASS = iclass.c optimized_cipher.c SRC_LEGIC = legicrf.c legic_prng.c +SRC_FLASH = flash.c +SRC_BEE = bee.c #the FPGA bitstream files. Note: order matters! FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit @@ -78,8 +81,6 @@ THUMBSRC = start.c \ random.c \ hfsnoop.c -# Standalone/hf_young.c \ -# Standalone/lf_samyrun.c # These are to be compiled in ARM mode ARMSRC = fpgaloader.c \ @@ -91,7 +92,10 @@ ARMSRC = fpgaloader.c \ $(SRC_CRC) \ parity.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 include ../common/Makefile.common diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 7aa2f9053..de431bb06 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -26,6 +26,9 @@ #include "LCD.h" #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 // 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 void StandAloneMode(void) { + + InStandAloneMode = 1; DbpString("Stand-alone mode! No PC necessary."); // Oooh pretty -- notify user we're in elite samy mode now LED(LED_RED, 200); @@ -375,9 +380,9 @@ void StandAloneMode(void) { // detection of which Standalone Modes is installed // (iceman) void printStandAloneModes(void) { - #if defined(WITH_HF_YOUNG) || defined(WITH_LF_SAMYRUN) + DbpString("Installed StandAlone Mods"); - #endif + #if defined(WITH_LF_ICERUN) DbpString(" LF sniff/clone/simulation - aka IceRun (iceman)"); #endif @@ -397,6 +402,9 @@ void printStandAloneModes(void) { DbpString(" HF Mifare sniff/clone - aka MattyRun (Matta Real)"); #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. // 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 @@ -1106,8 +1114,10 @@ void UsbPacketReceived(uint8_t *packet, int len) { } void __attribute__((noreturn)) AppMain(void) { + SpinDelay(100); clear_trace(); + if(common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) { /* Initialize common area */ memset(&common_area, 0, sizeof(common_area)); @@ -1118,6 +1128,8 @@ void __attribute__((noreturn)) AppMain(void) { LEDsoff(); + // list with standalone refs. + // Init USB device usb_enable(); @@ -1156,7 +1168,14 @@ void __attribute__((noreturn)) AppMain(void) { } WDT_HIT(); + // Press button for one second to enter a possible standalone mode 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) RunMod(); #endif @@ -1164,7 +1183,8 @@ void __attribute__((noreturn)) AppMain(void) { #if defined (WITH_ISO14443a) && defined (WITH_HF_YOUNG) RunMod(); #endif - + // when here, we are no longer in standalone mode. + InStandAloneMode = 0; } } }