From: iceman1001 Date: Wed, 1 Apr 2015 16:02:10 +0000 (+0200) Subject: Merge branch 'master' of https://github.com/Proxmark/proxmark3 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/49dc1d0a9eafdb1e369ead88c3c8882bc6959a17?hp=b8f705e73e60cc098c220152e856ca8ec42f6fa4 Merge branch 'master' of https://github.com/Proxmark/proxmark3 Conflicts: armsrc/Makefile armsrc/lfops.c client/cmdlft55xx.c common/ldscript.common common/lfdemod.c --- diff --git a/Makefile b/Makefile index 101212b4..b558da2d 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,8 @@ help: @echo + all - Make bootrom, armsrc and the OS-specific host directory @echo + client - Make only the OS-specific host directory @echo + flash-bootrom - Make bootrom and flash it - @echo + flash-os - Make armsrc and flash os - @echo + flash-fpga - Make armsrc and flash fpga + @echo + flash-os - Make armsrc and flash os (includes fpga) + @echo + flash-fpga - (Deprecated:) Make armsrc and flash fpga @echo + flash-both - Make armsrc and flash os and fpga image @echo + flash-all - Make bootrom and armsrc and flash bootrom, os and fpga image @echo + clean - Clean in bootrom, armsrc and the OS-specific host directory @@ -37,13 +37,13 @@ flash-bootrom: bootrom/obj/bootrom.elf $(FLASH_TOOL) flash-os: armsrc/obj/osimage.elf $(FLASH_TOOL) $(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<) -flash-fpga: armsrc/obj/fpgaimage.elf $(FLASH_TOOL) - $(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<) +#flash-fpga: armsrc/obj/fpgaimage.elf $(FLASH_TOOL) +# $(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<) -flash-both: armsrc/obj/osimage.elf armsrc/obj/fpgaimage.elf $(FLASH_TOOL) +flash-both: armsrc/obj/osimage.elf $(FLASH_TOOL) $(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$(filter-out $(FLASH_TOOL),$^)) -flash-all: bootrom/obj/bootrom.elf armsrc/obj/osimage.elf armsrc/obj/fpgaimage.elf $(FLASH_TOOL) +flash-all: bootrom/obj/bootrom.elf armsrc/obj/osimage.elf $(FLASH_TOOL) $(FLASH_TOOL) $(FLASH_PORT) -b $(subst /,$(PATHSEP),$(filter-out $(FLASH_TOOL),$^)) newtarbin: diff --git a/armsrc/Makefile b/armsrc/Makefile index d85244c7..3140a0e7 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -10,7 +10,7 @@ APP_INCLUDES = apps.h #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 -Os +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 @@ -52,7 +52,8 @@ 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)/osimage.s19 +#$(OBJDIR)/fpgaimage.s19 all: $(OBJS) @@ -65,11 +66,11 @@ $(OBJDIR)/fpga_hf.o: fpga_hf.bit $(OBJDIR)/fullimage.elf: $(VERSIONOBJ) $(OBJDIR)/fpga_lf.o $(OBJDIR)/fpga_hf.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)/fpgaimage.elf: $(OBJDIR)/fullimage.elf +# $(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@ $(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf - $(OBJCOPY) -F elf32-littlearm --remove-section .fpgaimage $^ $@ + $(OBJCOPY) -F elf32-littlearm $^ $@ tarbin: $(OBJS) $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf) diff --git a/armsrc/ldscript b/armsrc/ldscript index d0be3b6a..840b8196 100644 --- a/armsrc/ldscript +++ b/armsrc/ldscript @@ -11,8 +11,7 @@ INCLUDE ../common/ldscript.common PHDRS { - fpgaimage PT_LOAD FLAGS(4); - text PT_LOAD; + text PT_LOAD FLAGS(5); data PT_LOAD; bss PT_LOAD; } @@ -20,11 +19,6 @@ PHDRS ENTRY(Vector) SECTIONS { - .fpgaimage : { - *(fpga_lf_bit.data) - *(fpga_hf_bit.data) - } >fpgaimage :fpgaimage - .start : { *(.startos) } >osimage :text @@ -40,6 +34,8 @@ SECTIONS .rodata : { *(.rodata) *(.rodata.*) + *(fpga_lf_bit.data) + *(fpga_hf_bit.data) KEEP(*(.version_information)) } >osimage :text diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 1bd23e5a..d6d686e1 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -953,7 +953,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol) code = bytebits_to_byte(dest+idx,32); code2 = bytebits_to_byte(dest+idx+32,32); version = bytebits_to_byte(dest+idx+27,8); //14,4 - facilitycode = bytebits_to_byte(dest+idx+18,8) ; + facilitycode = bytebits_to_byte(dest+idx+18,8); number = (bytebits_to_byte(dest+idx+36,8)<<8)|(bytebits_to_byte(dest+idx+45,8)); //36,9 crc = bytebits_to_byte(dest+idx+54,8); diff --git a/client/cmddata.c b/client/cmddata.c index 2563cb18..f2f1cfd7 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -414,7 +414,10 @@ int ASKmanDemod(const char *Cmd, bool verbose, bool emSearch) int invert=0; int clk=0; int maxErr=100; - + //param_getdec(Cmd, 0, &clk); + //param_getdec(Cmd, 1, &invert); + //maxErr = param_get32ex(Cmd, 2, 0xFFFFFFFF, 10); + //if (maxErr == 0xFFFFFFFF) maxErr=100; uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0}; sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); if (invert != 0 && invert != 1) { @@ -677,7 +680,7 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose) ans = sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr); if (ans>0) - ans = ASKrawDemod(Cmd+2, FALSE); + ans = ASKrawDemod(Cmd+1, FALSE); else ans = ASKrawDemod(Cmd, FALSE); if (!ans) { @@ -1148,7 +1151,7 @@ int FSKrawDemod(const char *Cmd, bool verbose) if (strlen(Cmd)>0 && strlen(Cmd)<=2) { if (rfLen==1){ - invert=1; //if invert option only is used + invert = 1; //if invert option only is used rfLen = 0; } } @@ -1958,7 +1961,7 @@ int NRZrawDemod(const char *Cmd, bool verbose) if (g_debugMode) PrintAndLog("Too many errors found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt); return 0; } - if (errCnt<0|| BitLen<16){ //throw away static - allow 1 and -1 (in case of threshold command first) + if (errCnt<0 || BitLen<16){ //throw away static - allow 1 and -1 (in case of threshold command first) if (g_debugMode) PrintAndLog("no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt); return 0; } diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 7d967d5d..ed7e2c80 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -737,7 +737,7 @@ int CmdT55xxReadTrace(const char *Cmd) uint32_t icr = PackBits(si, 3, DemodBuffer); si += 3; uint32_t year = PackBits(si, 4, DemodBuffer); si += 4; uint32_t quarter = PackBits(si, 2, DemodBuffer); si += 2; - uint32_t lotid = PackBits(si, 14, DemodBuffer); si += 14; + uint32_t lotid = PackBits(si, 14, DemodBuffer); si += 14; uint32_t wafer = PackBits(si, 5, DemodBuffer); si += 5; uint32_t dw = PackBits(si, 15, DemodBuffer); @@ -761,7 +761,7 @@ int CmdT55xxReadTrace(const char *Cmd) PrintAndLog(" CID : 0x%02X (%d) - %s", cid, cid, GetModelStrFromCID(cid)); PrintAndLog(" ICR IC Revision : %d",icr ); PrintAndLog(" Manufactured"); - PrintAndLog(" Year/Quarter : %d/%d",year, quarter ); + PrintAndLog(" Year/Quarter : 20?%d/%d",year, quarter); PrintAndLog(" Lot ID : %d", lotid ); PrintAndLog(" Wafer number : %d", wafer); PrintAndLog(" Die Number : %d", dw); @@ -923,94 +923,96 @@ char * GetBitRateStr(uint32_t id){ char *retStr = buf; switch (id){ case 0: - sprintf(retStr,"%d - RF/8",id); + snprintf(retStr,sizeof(buf),"%d - RF/8",id); break; case 1: - sprintf(retStr,"%d - RF/16",id); + snprintf(retStr,sizeof(buf),"%d - RF/16",id); break; case 2: - sprintf(retStr,"%d - RF/32",id); + snprintf(retStr,sizeof(buf),"%d - RF/32",id); break; case 3: - sprintf(retStr,"%d - RF/40",id); + snprintf(retStr,sizeof(buf),"%d - RF/40",id); break; case 4: - sprintf(retStr,"%d - RF/50",id); + snprintf(retStr,sizeof(buf),"%d - RF/50",id); break; case 5: - sprintf(retStr,"%d - RF/64",id); + snprintf(retStr,sizeof(buf),"%d - RF/64",id); break; case 6: - sprintf(retStr,"%d - RF/100",id); + snprintf(retStr,sizeof(buf),"%d - RF/100",id); break; case 7: - sprintf(retStr,"%d - RF/128",id); + snprintf(retStr,sizeof(buf),"%d - RF/128",id); break; default: - sprintf(retStr,"%d - (Unknown)",id); + snprintf(retStr,sizeof(buf),"%d - (Unknown)",id); break; } return buf; } + char * GetSaferStr(uint32_t id){ static char buf[20]; char *retStr = buf; - sprintf(retStr,"%d",id); + snprintf(retStr,sizeof(buf),"%d",id); if (id == 6) { - sprintf(retStr,"%d - passwd",id); + snprintf(retStr,sizeof(buf),"%d - passwd",id); } if (id == 9 ){ - sprintf(retStr,"%d - testmode",id); + snprintf(retStr,sizeof(buf),"%d - testmode",id); } return buf; } + char * GetModulationStr( uint32_t id){ static char buf[60]; char *retStr = buf; switch (id){ case 0: - sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id); + snprintf(retStr,sizeof(buf),"%d - DIRECT (ASK/NRZ)",id); break; case 1: - sprintf(retStr,"%d - PSK 1 phase change when input changes",id); + snprintf(retStr,sizeof(buf),"%d - PSK 1 phase change when input changes",id); break; case 2: - sprintf(retStr,"%d - PSK 2 phase change on bitclk if input high",id); + snprintf(retStr,sizeof(buf),"%d - PSK 2 phase change on bitclk if input high",id); break; case 3: - sprintf(retStr,"%d - PSK 3 phase change on rising edge of input",id); + snprintf(retStr,sizeof(buf),"%d - PSK 3 phase change on rising edge of input",id); break; case 4: - sprintf(retStr,"%d - FSK 1 RF/8 RF/5",id); + snprintf(retStr,sizeof(buf),"%d - FSK 1 RF/8 RF/5",id); break; case 5: - sprintf(retStr,"%d - FSK 2 RF/8 RF/10",id); + snprintf(retStr,sizeof(buf),"%d - FSK 2 RF/8 RF/10",id); break; case 6: - sprintf(retStr,"%d - FSK 1a RF/5 RF/8",id); + snprintf(retStr,sizeof(buf),"%d - FSK 1a RF/5 RF/8",id); break; case 7: - sprintf(retStr,"%d - FSK 2a RF/10 RF/8",id); + snprintf(retStr,sizeof(buf),"%d - FSK 2a RF/10 RF/8",id); break; case 8: - sprintf(retStr,"%d - Manschester",id); + snprintf(retStr,sizeof(buf),"%d - Manschester",id); break; case 16: - sprintf(retStr,"%d - Biphase",id); + snprintf(retStr,sizeof(buf),"%d - Biphase",id); break; case 0x18: - sprintf(retStr,"%d - Biphase a - AKA Conditional Dephase Encoding(CDP)",id); + snprintf(retStr,sizeof(buf),"%d - Biphase a - AKA Conditional Dephase Encoding(CDP)",id); break; case 17: - sprintf(retStr,"%d - Reserved",id); + snprintf(retStr,sizeof(buf),"%d - Reserved",id); break; default: - sprintf(retStr,"0x%02X (Unknown)",id); + snprintf(retStr,sizeof(buf),"0x%02X (Unknown)",id); break; } return buf; @@ -1028,48 +1030,48 @@ char * GetModelStrFromCID(uint32_t cid){ char * GetSelectedModulationStr( uint8_t id){ - static char buf[16]; + static char buf[20]; char *retStr = buf; switch (id){ case DEMOD_FSK: - sprintf(retStr,"FSK"); + snprintf(retStr,sizeof(buf),"FSK"); break; case DEMOD_FSK1: - sprintf(retStr,"FSK1"); + snprintf(retStr,sizeof(buf),"FSK1"); break; case DEMOD_FSK1a: - sprintf(retStr,"FSK1a"); + snprintf(retStr,sizeof(buf),"FSK1a"); break; case DEMOD_FSK2: - sprintf(retStr,"FSK2"); + snprintf(retStr,sizeof(buf),"FSK2"); break; case DEMOD_FSK2a: - sprintf(retStr,"FSK2a"); + snprintf(retStr,sizeof(buf),"FSK2a"); break; case DEMOD_ASK: - sprintf(retStr,"ASK"); + snprintf(retStr,sizeof(buf),"ASK"); break; case DEMOD_NRZ: - sprintf(retStr,"DIRECT/NRZ"); + snprintf(retStr,sizeof(buf),"DIRECT/NRZ"); break; case DEMOD_PSK1: - sprintf(retStr,"PSK1"); + snprintf(retStr,sizeof(buf),"PSK1"); break; case DEMOD_PSK2: - sprintf(retStr,"PSK2"); + snprintf(retStr,sizeof(buf),"PSK2"); break; case DEMOD_PSK3: - sprintf(retStr,"PSK3"); + snprintf(retStr,sizeof(buf),"PSK3"); break; case DEMOD_BI: - sprintf(retStr,"BIPHASE"); + snprintf(retStr,sizeof(buf),"BIPHASE"); break; case DEMOD_BIa: - sprintf(retStr,"BIPHASEa - (CDP)"); + snprintf(retStr,sizeof(buf),"BIPHASEa - (CDP)"); break; default: - sprintf(retStr,"(Unknown)"); + snprintf(retStr,sizeof(buf),"(Unknown)"); break; } return buf; diff --git a/common/ldscript.common b/common/ldscript.common index c1a48dfc..ea57ec24 100644 --- a/common/ldscript.common +++ b/common/ldscript.common @@ -1,6 +1,7 @@ /* ----------------------------------------------------------------------------- - This code is licensed to you under the terms of the GNU GPL, version 2 or, + This code is licensed to you under the ter +ms of the GNU GPL, version 2 or, at your option, any later version. See the LICENSE.txt file for the text of the license. ----------------------------------------------------------------------------- @@ -13,9 +14,7 @@ MEMORY { bootphase1 : ORIGIN = 0x00100000, LENGTH = 0x200 /* Phase 1 bootloader: Copies real bootloader to RAM */ bootphase2 : ORIGIN = 0x00100200, LENGTH = 0x2000 - 0x200 /* Main bootloader code, stored in Flash, executed from RAM */ - fpgaimage : ORIGIN = 0x00102000, LENGTH = 96k - 0x2000 /* Place where the FPGA image will end up */ - //osimage : ORIGIN = 0x00118000, LENGTH = 256K - 96k /* Place where the main OS will end up */ - osimage : ORIGIN = 0x00118000, LENGTH = 256K - 96k /* Place where the main OS will end up */ + osimage : ORIGIN = 0x00102000, LENGTH = 256K - 0x2000 /* Place where the main OS will end up */ ram : ORIGIN = 0x00200000, LENGTH = 64K - 0x20 /* RAM, minus small common area */ commonarea : ORIGIN = 0x00200000 + 64K - 0x20, LENGTH = 0x20 /* Communication between bootloader and main OS */ } diff --git a/common/lfdemod.c b/common/lfdemod.c index d3c2a01c..ffa807fe 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -34,8 +34,8 @@ int getHiLo(uint8_t *BitStream, size_t size, int *high, int *low, uint8_t fuzzHi if (BitStream[i] < *low) *low = BitStream[i]; } if (*high < 123) return -1; // just noise - *high = (int)(((*high-128)*(((float)fuzzHi)/100))+128); - *low = (int)(((*low-128)*(((float)fuzzLo)/100))+128); + *high = ((*high-128)*fuzzHi + 12800)/100; + *low = ((*low-128)*fuzzLo + 12800)/100; return 1; } @@ -559,28 +559,26 @@ size_t aggregate_bits(uint8_t *dest, size_t size, uint8_t rfLen, size_t idx=0; size_t numBits=0; uint32_t n=1; - uint16_t lowWaves = ((rfLen*100/fclow)); // (((float)(rfLen))/((float)fclow)); - uint16_t highWaves = ((rfLen*100/fchigh)); // (((float)(rfLen))/((float)fchigh)); for( idx=1; idx < size; idx++) { n++; if (dest[idx]==lastval) continue; //if lastval was 1, we have a 1->0 crossing if (dest[idx-1]==1) { - if (!numBits && n < lowWaves/100) { + if (!numBits && n < rfLen/fclow) { n=0; lastval = dest[idx]; continue; } - n = (size_t)((((n*1000)/lowWaves)+5)/10); + n = (n * fclow + rfLen/2) / rfLen; } else {// 0->1 crossing //test first bitsample too small - if (!numBits && n < highWaves/100) { + if (!numBits && n < rfLen/fchigh) { n=0; lastval = dest[idx]; continue; } - n = (((n*1000)/highWaves)+5)/10; + n = (n * fchigh + rfLen/2) / rfLen; } if (n == 0) n = 1; @@ -590,11 +588,11 @@ size_t aggregate_bits(uint8_t *dest, size_t size, uint8_t rfLen, lastval=dest[idx]; }//end for // if valid extra bits at the end were all the same frequency - add them in - if (n > highWaves/100) { + if (n > rfLen/fchigh) { if (dest[idx-2]==1) { - n=(((n*1000)/lowWaves)+5)/10; + n = (n * fclow + rfLen/2) / rfLen; } else { - n=(((n*1000)/highWaves)+5)/10; + n = (n * fchigh + rfLen/2) / rfLen; } memset(dest+numBits, dest[idx-1]^invert , n); numBits += n;