]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge pull request #109 from pwpiwi/image_shrink
authorpwpiwi <pwpiwi@users.noreply.github.com>
Wed, 24 Jun 2015 05:47:45 +0000 (07:47 +0200)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Wed, 24 Jun 2015 05:47:45 +0000 (07:47 +0200)
Compress FPGA configs and initialized data

1  2 
armsrc/Makefile
armsrc/appmain.c
armsrc/apps.h
client/Makefile

diff --combined armsrc/Makefile
index 502ab958c8aa3f6b3ab2ea35f3823122bcf4294c,78d67934b1c2c9bd84915ef46ccdf69c083ca84b..f21f106ce097442477aebb7fd06414a2f8179b15
@@@ -10,21 -10,38 +10,38 @@@ APP_INCLUDES = apps.
  
  #remove one of the following defines and comment out the relevant line
  #in the next section to remove that particular feature from compilation  
- APP_CFLAGS    = -DWITH_LF -DWITH_ISO15693 -DWITH_ISO14443a -DWITH_ISO14443b -DWITH_ICLASS -DWITH_LEGICRF -DWITH_HITAG  -DWITH_CRC -DON_DEVICE -fno-strict-aliasing -ffunction-sections -fdata-sections
+ APP_CFLAGS    = -DWITH_LF -DWITH_ISO15693 -DWITH_ISO14443a -DWITH_ISO14443b -DWITH_ICLASS -DWITH_LEGICRF -DWITH_HITAG  -DWITH_CRC -DON_DEVICE \
+                               -fno-strict-aliasing -ffunction-sections -fdata-sections
  #-DWITH_LCD 
  
  #SRC_LCD = fonts.c LCD.c
  SRC_LF = lfops.c hitag2.c lfsampling.c
  SRC_ISO15693 = iso15693.c iso15693tools.c
  SRC_ISO14443a = epa.c iso14443a.c mifareutil.c mifarecmd.c mifaresniff.c
 -SRC_ISO14443b = iso14443.c
 +SRC_ISO14443b = iso14443b.c
  SRC_CRAPTO1 = crapto1.c crypto1.c des.c aes.c 
- SRC_CRC = iso14443crc.c crc.c crc16.c crc32.c 
+ SRC_CRC = iso14443crc.c crc.c crc16.c crc32.c
  
+ #the FPGA bitstream files. Note: order matters!
+ FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit
+ #the zlib source files required for decompressing the fpga config at run time
+ SRC_ZLIB = inflate.c inffast.c inftrees.c adler32.c zutil.c
+ #additional defines required to compile zlib
+ ZLIB_CFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
+ APP_CFLAGS += $(ZLIB_CFLAGS)
+ # zlib includes:
+ APP_CFLAGS += -I../zlib
+ # stdint.h provided locally until GCC 4.5 becomes C99 compliant
+ APP_CFLAGS += -I.
+ # Compile these in thumb mode (small size)
  THUMBSRC = start.c \
        $(SRC_LCD) \
        $(SRC_ISO15693) \
        $(SRC_LF) \
+       $(SRC_ZLIB) \
        appmain.c \
        printf.c \
        util.c \
@@@ -45,50 -62,61 +62,61 @@@ ARMSRC = fpgaloader.c 
        BigBuf.c \
        optimized_cipher.c
  
- # stdint.h provided locally until GCC 4.5 becomes C99 compliant
- APP_CFLAGS += -I.
  # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
  include ../common/Makefile.common
  
- OBJS = $(OBJDIR)/osimage.s19 
- #$(OBJDIR)/fpgaimage.s19
+ OBJS = $(OBJDIR)/fullimage.s19 
+ FPGA_COMPRESSOR = ../client/fpga_compress
  
  all: $(OBJS)
  
- $(OBJDIR)/fpga_lf.o: fpga_lf.bit
-       $(OBJCOPY) -O elf32-littlearm -I binary -B arm --redefine-sym _binary____fpga_fpga_lf_bit_start=_binary_fpga_lf_bit_start --redefine-sym _binary____fpga_fpga_lf_bit_end=_binary_fpga_lf_bit_end --prefix-sections=fpga_lf_bit  $^ $@
+ $(OBJDIR)/fpga_all.o: $(OBJDIR)/fpga_all.bit.z
+       $(OBJCOPY) -O elf32-littlearm -I binary -B arm --prefix-sections=fpga_all_bit $^ $@
  
- $(OBJDIR)/fpga_hf.o: fpga_hf.bit
-       $(OBJCOPY) -O elf32-littlearm -I binary -B arm --redefine-sym _binary____fpga_fpga_hf_bit_start=_binary_fpga_hf_bit_start --redefine-sym _binary____fpga_fpga_hf_bit_end=_binary_fpga_hf_bit_end --prefix-sections=fpga_hf_bit  $^ $@
+ $(OBJDIR)/fpga_all.bit.z: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR)
+       $(FPGA_COMPRESSOR) $(filter %.bit,$^) $@  
  
- $(OBJDIR)/fullimage.elf: $(VERSIONOBJ) $(OBJDIR)/fpga_lf.o $(OBJDIR)/fpga_hf.o $(THUMBOBJ) $(ARMOBJ)
+ $(FPGA_COMPRESSOR):
+               make -C ../client $(notdir $(FPGA_COMPRESSOR))
+               
+ $(OBJDIR)/fullimage.stage1.elf: $(VERSIONOBJ) $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
        $(CC) $(LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
  
- #$(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fullimage.elf
- #     $(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@  
+ $(OBJDIR)/fullimage.nodata.bin: $(OBJDIR)/fullimage.stage1.elf
+       $(OBJCOPY) -O binary -I elf32-littlearm --remove-section .data $^ $@
+       
+ $(OBJDIR)/fullimage.nodata.o: $(OBJDIR)/fullimage.nodata.bin
+       $(OBJCOPY) -O elf32-littlearm -I binary -B arm --rename-section .data=stage1_image $^ $@
  
- $(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf
-       $(OBJCOPY) -F elf32-littlearm $^ $@
+ $(OBJDIR)/fullimage.data.bin: $(OBJDIR)/fullimage.stage1.elf
+       $(OBJCOPY) -O binary -I elf32-littlearm --only-section .data $^ $@
  
+ $(OBJDIR)/fullimage.data.bin.z: $(OBJDIR)/fullimage.data.bin $(FPGA_COMPRESSOR)
+       $(FPGA_COMPRESSOR) $(filter %.bin,$^) $@  
+       
+ $(OBJDIR)/fullimage.data.o: $(OBJDIR)/fullimage.data.bin.z
+       $(OBJCOPY) -O elf32-littlearm -I binary -B arm --rename-section .data=compressed_data $^ $@
+ $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o
+       $(CC) $(LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^
+       
  tarbin: $(OBJS)
        $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf)
  
  clean:
        $(DELETE) $(OBJDIR)$(PATHSEP)*.o
        $(DELETE) $(OBJDIR)$(PATHSEP)*.elf
        $(DELETE) $(OBJDIR)$(PATHSEP)*.s19
        $(DELETE) $(OBJDIR)$(PATHSEP)*.map
        $(DELETE) $(OBJDIR)$(PATHSEP)*.d
+       $(DELETE) $(OBJDIR)$(PATHSEP)*.z
+       $(DELETE) $(OBJDIR)$(PATHSEP)*.bin
        $(DELETE) version.c
  
  .PHONY: all clean help
  help:
        @echo Multi-OS Makefile, you are running on $(DETECTED_OS)
        @echo Possible targets:
-       @echo + all               - Make both:
-       @echo + $(OBJDIR)/osimage.s19   - The OS image
-       @echo + $(OBJDIR)/fpgaimage.s19 - The FPGA image
-       @echo + clean             - Clean $(OBJDIR)
+       @echo + all    - Build the full image $(OBJDIR)/fullimage.s19
+       @echo + clean  - Clean $(OBJDIR)
  
diff --combined armsrc/appmain.c
index 152f8a3ec2c6345c9a93d12afaa145beae905e19,263990468b3dbc06710a64bb5dc057c282a7918e..0cbfa2498e6ca7349f23766af663cd57ab70ac47
@@@ -250,6 -250,55 +250,6 @@@ void MeasureAntennaTuningHf(void
  }
  
  
 -void SimulateTagHfListen(void)
 -{
 -      // ToDo: historically this used the free buffer, which was 2744 Bytes long. 
 -      // There might be a better size to be defined:
 -      #define HF_14B_SNOOP_BUFFER_SIZE 2744
 -      uint8_t *dest = BigBuf_malloc(HF_14B_SNOOP_BUFFER_SIZE);
 -      uint8_t v = 0;
 -      int i;
 -      int p = 0;
 -
 -      // We're using this mode just so that I can test it out; the simulated
 -      // tag mode would work just as well and be simpler.
 -      FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
 -      FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR | FPGA_HF_READER_RX_XCORR_848_KHZ | FPGA_HF_READER_RX_XCORR_SNOOP);
 -
 -      // We need to listen to the high-frequency, peak-detected path.
 -      SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
 -
 -      FpgaSetupSsc();
 -
 -      i = 0;
 -      for(;;) {
 -              if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
 -                      AT91C_BASE_SSC->SSC_THR = 0xff;
 -              }
 -              if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
 -                      uint8_t r = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
 -
 -                      v <<= 1;
 -                      if(r & 1) {
 -                              v |= 1;
 -                      }
 -                      p++;
 -
 -                      if(p >= 8) {
 -                              dest[i] = v;
 -                              v = 0;
 -                              p = 0;
 -                              i++;
 -
 -                              if(i >= HF_14B_SNOOP_BUFFER_SIZE) {
 -                                      break;
 -                              }
 -                      }
 -              }
 -      }
 -      DbpString("simulate tag (now type bitsamples)");
 -}
 -
  void ReadMem(int addr)
  {
        const uint8_t *data = ((uint8_t *)addr);
  /* osimage version information is linked in */
  extern struct version_information version_information;
  /* bootrom version information is pointed to from _bootphase1_version_pointer */
- extern char *_bootphase1_version_pointer, _flash_start, _flash_end;
+ extern char *_bootphase1_version_pointer, _flash_start, _flash_end, _bootrom_start, _bootrom_end, __data_src_start__;
  void SendVersion(void)
  {
-       char temp[512]; /* Limited data payload in USB packets */
-       DbpString("Prox/RFID mark3 RFID instrument");
+       char temp[USB_CMD_DATA_SIZE]; /* Limited data payload in USB packets */
+       char VersionString[USB_CMD_DATA_SIZE] = { '\0' };
  
        /* Try to find the bootrom version information. Expect to find a pointer at
         * symbol _bootphase1_version_pointer, perform slight sanity checks on the
         */
        char *bootrom_version = *(char**)&_bootphase1_version_pointer;
        if( bootrom_version < &_flash_start || bootrom_version >= &_flash_end ) {
-               DbpString("bootrom version information appears invalid");
+               strcat(VersionString, "bootrom version information appears invalid\n");
        } else {
                FormatVersionInformation(temp, sizeof(temp), "bootrom: ", bootrom_version);
-               DbpString(temp);
+               strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
        }
  
        FormatVersionInformation(temp, sizeof(temp), "os: ", &version_information);
-       DbpString(temp);
+       strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
  
-       FpgaGatherVersion(temp, sizeof(temp));
-       DbpString(temp);
-       // Send Chip ID
-       cmd_send(CMD_ACK,*(AT91C_DBGU_CIDR),0,0,NULL,0);
+       FpgaGatherVersion(FPGA_BITSTREAM_LF, temp, sizeof(temp));
+       strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
+       FpgaGatherVersion(FPGA_BITSTREAM_HF, temp, sizeof(temp));
+       strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
+       // Send Chip ID and used flash memory
+       uint32_t text_and_rodata_section_size = (uint32_t)&__data_src_start__ - (uint32_t)&_flash_start;
+       uint32_t compressed_data_section_size = common_area.arg1;
+       cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, 0, VersionString, strlen(VersionString));
  }
  
  #ifdef WITH_LF
@@@ -733,17 -787,20 +738,17 @@@ void UsbPacketReceived(uint8_t *packet
  #endif
  
  #ifdef WITH_ISO14443b
 -              case CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443:
 -                      AcquireRawAdcSamplesIso14443(c->arg[0]);
 -                      break;
                case CMD_READ_SRI512_TAG:
 -                      ReadSTMemoryIso14443(0x0F);
 +                      ReadSTMemoryIso14443b(0x0F);
                        break;
                case CMD_READ_SRIX4K_TAG:
 -                      ReadSTMemoryIso14443(0x7F);
 +                      ReadSTMemoryIso14443b(0x7F);
                        break;
 -              case CMD_SNOOP_ISO_14443:
 -                      SnoopIso14443();
 +              case CMD_SNOOP_ISO_14443B:
 +                      SnoopIso14443b();
                        break;
 -              case CMD_SIMULATE_TAG_ISO_14443:
 -                      SimulateIso14443Tag();
 +              case CMD_SIMULATE_TAG_ISO_14443B:
 +                      SimulateIso14443bTag();
                        break;
                case CMD_ISO_14443B_COMMAND:
                        SendRawCommand14443B(c->arg[0],c->arg[1],c->arg[2],c->d.asBytes);
                case CMD_EPA_PACE_COLLECT_NONCE:
                        EPA_PACE_Collect_Nonce(c);
                        break;
 +              case CMD_EPA_PACE_REPLAY:
 +                      EPA_PACE_Replay(c);
 +                      break;
                        
                case CMD_READER_MIFARE:
                        ReaderMifare(c->arg[0]);
                case CMD_MIFARE_WRITEBL:
                        MifareWriteBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
                        break;
 -              case CMD_MIFAREU_WRITEBL_COMPAT:
 -                      MifareUWriteBlock(c->arg[0], c->d.asBytes);
 -                      break;
 +              //case CMD_MIFAREU_WRITEBL_COMPAT:
 +                      //MifareUWriteBlockCompat(c->arg[0], c->d.asBytes);
 +                      //break;
                case CMD_MIFAREU_WRITEBL:
 -                      MifareUWriteBlock_Special(c->arg[0], c->d.asBytes);
 +                      MifareUWriteBlock(c->arg[0], c->arg[1], c->d.asBytes);
                        break;
                case CMD_MIFARE_NESTED:
                        MifareNested(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
                        break;
  #endif
  
 -              case CMD_SIMULATE_TAG_HF_LISTEN:
 -                      SimulateTagHfListen();
 -                      break;
 -
                case CMD_BUFF_CLEAR:
                        BigBuf_Clear();
                        break;
diff --combined armsrc/apps.h
index a4144a91bc5d0dddb3868d301f146b6f8a171e5d,98be05a3c07b6355802a0379328978cdbef687e8..bb094b330521b08efbe4b57ff9fa8ee70fd8c250
@@@ -19,6 -19,7 +19,7 @@@
  #include "mifare.h"
  #include "../common/crc32.h"
  #include "BigBuf.h"
+ #include "fpgaloader.h"
  
  extern const uint8_t OddByteParity[256];
  extern int rsamples;   // = 0;
@@@ -50,60 -51,6 +51,6 @@@ void ListenReaderField(int limit)
  extern int ToSendMax;
  extern uint8_t ToSend[];
  
- /// fpga.h
- void FpgaSendCommand(uint16_t cmd, uint16_t v);
- void FpgaWriteConfWord(uint8_t v);
- void FpgaDownloadAndGo(int bitstream_version);
- int FpgaGatherBitstreamVersion();
- void FpgaGatherVersion(char *dst, int len);
- void FpgaSetupSsc(void);
- void SetupSpi(int mode);
- bool FpgaSetupSscDma(uint8_t *buf, int len);
- #define FpgaDisableSscDma(void)       AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTDIS;
- #define FpgaEnableSscDma(void) AT91C_BASE_PDC_SSC->PDC_PTCR = AT91C_PDC_RXTEN;
- void SetAdcMuxFor(uint32_t whichGpio);
- // Definitions for the FPGA commands.
- #define FPGA_CMD_SET_CONFREG                                  (1<<12)
- #define FPGA_CMD_SET_DIVISOR                                  (2<<12)
- #define FPGA_CMD_SET_USER_BYTE1                                       (3<<12)
- // Definitions for the FPGA configuration word.
- // LF
- #define FPGA_MAJOR_MODE_LF_ADC                                        (0<<5)
- #define FPGA_MAJOR_MODE_LF_EDGE_DETECT                        (1<<5)
- #define FPGA_MAJOR_MODE_LF_PASSTHRU                           (2<<5)
- // HF
- #define FPGA_MAJOR_MODE_HF_READER_TX                          (0<<5)
- #define FPGA_MAJOR_MODE_HF_READER_RX_XCORR                    (1<<5)
- #define FPGA_MAJOR_MODE_HF_SIMULATOR                          (2<<5)
- #define FPGA_MAJOR_MODE_HF_ISO14443A                          (3<<5)
- // BOTH
- #define FPGA_MAJOR_MODE_OFF                                   (7<<5)
- // Options for LF_ADC
- #define FPGA_LF_ADC_READER_FIELD                              (1<<0)
- // Options for LF_EDGE_DETECT
- #define FPGA_CMD_SET_EDGE_DETECT_THRESHOLD                    FPGA_CMD_SET_USER_BYTE1
- #define FPGA_LF_EDGE_DETECT_READER_FIELD                      (1<<0)
- #define FPGA_LF_EDGE_DETECT_TOGGLE_MODE                               (1<<1)
- // Options for the HF reader, tx to tag
- #define FPGA_HF_READER_TX_SHALLOW_MOD                         (1<<0)
- // Options for the HF reader, correlating against rx from tag
- #define FPGA_HF_READER_RX_XCORR_848_KHZ                               (1<<0)
- #define FPGA_HF_READER_RX_XCORR_SNOOP                         (1<<1)
- #define FPGA_HF_READER_RX_XCORR_QUARTER_FREQ                  (1<<2)
- // Options for the HF simulated tag, how to modulate
- #define FPGA_HF_SIMULATOR_NO_MODULATION                               (0<<0)
- #define FPGA_HF_SIMULATOR_MODULATE_BPSK                               (1<<0)
- #define FPGA_HF_SIMULATOR_MODULATE_212K                               (2<<0)
- #define FPGA_HF_SIMULATOR_MODULATE_424K                               (4<<0)
- #define FPGA_HF_SIMULATOR_MODULATE_424K_8BIT          0x5//101
- // Options for ISO14443A
- #define FPGA_HF_ISO14443A_SNIFFER                             (0<<0)
- #define FPGA_HF_ISO14443A_TAGSIM_LISTEN                               (1<<0)
- #define FPGA_HF_ISO14443A_TAGSIM_MOD                          (2<<0)
- #define FPGA_HF_ISO14443A_READER_LISTEN                               (3<<0)
- #define FPGA_HF_ISO14443A_READER_MOD                          (4<<0)
  
  /// lfops.h
  extern uint8_t decimation;
@@@ -141,10 -88,10 +88,10 @@@ void EM4xReadWord(uint8_t Address, uint
  void EM4xWriteWord(uint32_t Data, uint8_t Address, uint32_t Pwd, uint8_t PwdMode);
  
  /// iso14443.h
 -void SimulateIso14443Tag(void);
 -void AcquireRawAdcSamplesIso14443(uint32_t parameter);
 -void ReadSTMemoryIso14443(uint32_t);
 -void RAMFUNC SnoopIso14443(void);
 +void SimulateIso14443bTag(void);
 +void AcquireRawAdcSamplesIso14443b(uint32_t parameter);
 +void ReadSTMemoryIso14443b(uint32_t);
 +void RAMFUNC SnoopIso14443b(void);
  void SendRawCommand14443B(uint32_t, uint32_t, uint8_t, uint8_t[]);
  
  /// iso14443a.h
@@@ -160,7 -107,6 +107,7 @@@ void RAMFUNC SniffMifare(uint8_t param)
  
  /// epa.h
  void EPA_PACE_Collect_Nonce(UsbCommand * c);
 +void EPA_PACE_Replay(UsbCommand *c);
  
  // mifarecmd.h
  void ReaderMifare(bool first_try);
@@@ -171,8 -117,8 +118,8 @@@ void MifareUC_Auth(uint8_t arg0, uint8_
  void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain);
  void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
  void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
 -void MifareUWriteBlock(uint8_t arg0,uint8_t *datain);
 -void MifareUWriteBlock_Special(uint8_t arg0,uint8_t *datain);
 +//void MifareUWriteBlockCompat(uint8_t arg0,uint8_t *datain);
 +void MifareUWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
  void MifareNested(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
  void MifareChkKeys(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
  void Mifare1ksim(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
diff --combined client/Makefile
index d7126da60efd9e3670a310b30816f5515bcf3d48,f9645194829c888a825da7dc545fee5f0af9710a..c454533d7822ca63febae2f6152a28f4480cb0bf
@@@ -9,12 -9,13 +9,13 @@@ include ../common/Makefile.commo
  CC=gcc
  CXX=g++
  #COMMON_FLAGS = -m32
- VPATH = ../common
+ VPATH = ../common ../zlib
  OBJDIR = obj
  
- LDLIBS = -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lreadline -lpthread -lm
+ LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm
+ LUALIB = ../liblua/liblua.a
  LDFLAGS = $(COMMON_FLAGS)
- CFLAGS = -std=c99 -I. -I../include -I../common -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4
+ CFLAGS = -std=c99 -I. -I../include -I../common -I../zlib -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4
  LUAPLATFORM = generic
  
  ifneq (,$(findstring MINGW,$(platform)))
@@@ -35,14 -36,13 +36,13 @@@ else ifeq ($(platform),Darwin
  else
      CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
      QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
+     LUALIB +=  -ldl
      MOC = $(shell pkg-config --variable=moc_location QtCore)
-     LDLIBS +=  -ldl
      # Below is a variant you can use if you have problems compiling with QT5 on ubuntu. see http://www.proxmark.org/forum/viewtopic.php?id=1661 for more info. 
      #MOC = /usr/lib/x86_64-linux-gnu/qt4/bin/moc
      LUAPLATFORM = linux
  endif
  
  ifneq ($(QTLDLIBS),)
      QTGUI = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
      CFLAGS += -DHAVE_GUI
@@@ -102,22 -102,26 +102,27 @@@ CMDSRCS =       nonce2key/crapto1.c
                        pm3_bitlib.c\
                        aes.c\
                        protocols.c\
 +                      sha1.c\
  
+ ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
+ ZLIB_FLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED 
+ #-DDEBUG -Dverbose=1
  
  COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
  CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
+ ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
  
  RM = rm -f
- BINS = proxmark3 flasher #snooper cli
- CLEAN = cli cli.exe flasher flasher.exe proxmark3 proxmark3.exe snooper snooper.exe $(CMDOBJS) $(OBJDIR)/*.o *.o *.moc.cpp
+ BINS = proxmark3 flasher fpga_compress #snooper cli
+ CLEAN = cli cli.exe flasher flasher.exe proxmark3 proxmark3.exe fpga_compress fpga_compress.exe snooper snooper.exe $(CMDOBJS) $(OBJDIR)/*.o *.o *.moc.cpp
  
  all: lua_build $(BINS) 
  
  all-static: LDLIBS:=-static $(LDLIBS)
- all-static: snooper cli flasher
-       
- proxmark3: LDLIBS+=$(QTLDLIBS)
+ all-static: snooper cli flasher fpga_compress
+ proxmark3: LDLIBS+=$(LUALIB) $(QTLDLIBS)
  proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUI)
        $(CXX) $(CXXFLAGS) $^ $(LDLIBS) -o $@
  
@@@ -130,8 -134,11 +135,11 @@@ cli: $(OBJDIR)/cli.o $(COREOBJS) $(CMDO
  flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
        $(CXX) $(CXXFLAGS) $^ $(LDLIBS) -o $@
  
+ fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
+       $(CXX) $(CXXFLAGS) $(ZLIB_FLAGS) $^ $(LDLIBS) -o $@
  $(OBJDIR)/%.o: %.c
-       $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CFLAGS) $(ZLIB_FLAGS) -c -o $@ $<
  
  $(OBJDIR)/%.o: %.cpp
        $(CXX) $(CXXFLAGS) -c -o $@ $<
Impressum, Datenschutz