Conflicts:
	armsrc/Makefile
	armsrc/lfops.c
	client/cmdlft55xx.c
	common/ldscript.common
	common/lfdemod.c
This commit is contained in:
iceman1001 2015-04-01 18:02:10 +02:00
commit 49dc1d0a9e
8 changed files with 78 additions and 79 deletions

View file

@ -23,8 +23,8 @@ help:
@echo + all - Make bootrom, armsrc and the OS-specific host directory @echo + all - Make bootrom, armsrc and the OS-specific host directory
@echo + client - Make only the OS-specific host directory @echo + client - Make only the OS-specific host directory
@echo + flash-bootrom - Make bootrom and flash it @echo + flash-bootrom - Make bootrom and flash it
@echo + flash-os - Make armsrc and flash os @echo + flash-os - Make armsrc and flash os (includes fpga)
@echo + flash-fpga - Make armsrc and flash fpga @echo + flash-fpga - (Deprecated:) Make armsrc and flash fpga
@echo + flash-both - Make armsrc and flash os and fpga image @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 + 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 @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-os: armsrc/obj/osimage.elf $(FLASH_TOOL)
$(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<) $(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<)
flash-fpga: armsrc/obj/fpgaimage.elf $(FLASH_TOOL) #flash-fpga: armsrc/obj/fpgaimage.elf $(FLASH_TOOL)
$(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<) # $(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_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),$^)) $(FLASH_TOOL) $(FLASH_PORT) -b $(subst /,$(PATHSEP),$(filter-out $(FLASH_TOOL),$^))
newtarbin: newtarbin:

View file

@ -10,7 +10,7 @@ APP_INCLUDES = apps.h
#remove one of the following defines and comment out the relevant line #remove one of the following defines and comment out the relevant line
#in the next section to remove that particular feature from compilation #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 #-DWITH_LCD
#SRC_LCD = fonts.c LCD.c #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 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
include ../common/Makefile.common include ../common/Makefile.common
OBJS = $(OBJDIR)/osimage.s19 $(OBJDIR)/fpgaimage.s19 OBJS = $(OBJDIR)/osimage.s19
#$(OBJDIR)/fpgaimage.s19
all: $(OBJS) 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) $(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) $(CC) $(LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
$(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fullimage.elf #$(OBJDIR)/fpgaimage.elf: $(OBJDIR)/fullimage.elf
$(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@ # $(OBJCOPY) -F elf32-littlearm --only-section .fpgaimage $^ $@
$(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf $(OBJDIR)/osimage.elf: $(OBJDIR)/fullimage.elf
$(OBJCOPY) -F elf32-littlearm --remove-section .fpgaimage $^ $@ $(OBJCOPY) -F elf32-littlearm $^ $@
tarbin: $(OBJS) tarbin: $(OBJS)
$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf) $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf)

View file

@ -11,8 +11,7 @@ INCLUDE ../common/ldscript.common
PHDRS PHDRS
{ {
fpgaimage PT_LOAD FLAGS(4); text PT_LOAD FLAGS(5);
text PT_LOAD;
data PT_LOAD; data PT_LOAD;
bss PT_LOAD; bss PT_LOAD;
} }
@ -20,11 +19,6 @@ PHDRS
ENTRY(Vector) ENTRY(Vector)
SECTIONS SECTIONS
{ {
.fpgaimage : {
*(fpga_lf_bit.data)
*(fpga_hf_bit.data)
} >fpgaimage :fpgaimage
.start : { .start : {
*(.startos) *(.startos)
} >osimage :text } >osimage :text
@ -40,6 +34,8 @@ SECTIONS
.rodata : { .rodata : {
*(.rodata) *(.rodata)
*(.rodata.*) *(.rodata.*)
*(fpga_lf_bit.data)
*(fpga_hf_bit.data)
KEEP(*(.version_information)) KEEP(*(.version_information))
} >osimage :text } >osimage :text

View file

@ -414,7 +414,10 @@ int ASKmanDemod(const char *Cmd, bool verbose, bool emSearch)
int invert=0; int invert=0;
int clk=0; int clk=0;
int maxErr=100; 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}; uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr); sscanf(Cmd, "%i %i %i", &clk, &invert, &maxErr);
if (invert != 0 && invert != 1) { 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); ans = sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr);
if (ans>0) if (ans>0)
ans = ASKrawDemod(Cmd+2, FALSE); ans = ASKrawDemod(Cmd+1, FALSE);
else else
ans = ASKrawDemod(Cmd, FALSE); ans = ASKrawDemod(Cmd, FALSE);
if (!ans) { if (!ans) {

View file

@ -761,7 +761,7 @@ int CmdT55xxReadTrace(const char *Cmd)
PrintAndLog(" CID : 0x%02X (%d) - %s", cid, cid, GetModelStrFromCID(cid)); PrintAndLog(" CID : 0x%02X (%d) - %s", cid, cid, GetModelStrFromCID(cid));
PrintAndLog(" ICR IC Revision : %d",icr ); PrintAndLog(" ICR IC Revision : %d",icr );
PrintAndLog(" Manufactured"); PrintAndLog(" Manufactured");
PrintAndLog(" Year/Quarter : %d/%d",year, quarter ); PrintAndLog(" Year/Quarter : 20?%d/%d",year, quarter);
PrintAndLog(" Lot ID : %d", lotid ); PrintAndLog(" Lot ID : %d", lotid );
PrintAndLog(" Wafer number : %d", wafer); PrintAndLog(" Wafer number : %d", wafer);
PrintAndLog(" Die Number : %d", dw); PrintAndLog(" Die Number : %d", dw);
@ -923,94 +923,96 @@ char * GetBitRateStr(uint32_t id){
char *retStr = buf; char *retStr = buf;
switch (id){ switch (id){
case 0: case 0:
sprintf(retStr,"%d - RF/8",id); snprintf(retStr,sizeof(buf),"%d - RF/8",id);
break; break;
case 1: case 1:
sprintf(retStr,"%d - RF/16",id); snprintf(retStr,sizeof(buf),"%d - RF/16",id);
break; break;
case 2: case 2:
sprintf(retStr,"%d - RF/32",id); snprintf(retStr,sizeof(buf),"%d - RF/32",id);
break; break;
case 3: case 3:
sprintf(retStr,"%d - RF/40",id); snprintf(retStr,sizeof(buf),"%d - RF/40",id);
break; break;
case 4: case 4:
sprintf(retStr,"%d - RF/50",id); snprintf(retStr,sizeof(buf),"%d - RF/50",id);
break; break;
case 5: case 5:
sprintf(retStr,"%d - RF/64",id); snprintf(retStr,sizeof(buf),"%d - RF/64",id);
break; break;
case 6: case 6:
sprintf(retStr,"%d - RF/100",id); snprintf(retStr,sizeof(buf),"%d - RF/100",id);
break; break;
case 7: case 7:
sprintf(retStr,"%d - RF/128",id); snprintf(retStr,sizeof(buf),"%d - RF/128",id);
break; break;
default: default:
sprintf(retStr,"%d - (Unknown)",id); snprintf(retStr,sizeof(buf),"%d - (Unknown)",id);
break; break;
} }
return buf; return buf;
} }
char * GetSaferStr(uint32_t id){ char * GetSaferStr(uint32_t id){
static char buf[20]; static char buf[20];
char *retStr = buf; char *retStr = buf;
sprintf(retStr,"%d",id); snprintf(retStr,sizeof(buf),"%d",id);
if (id == 6) { if (id == 6) {
sprintf(retStr,"%d - passwd",id); snprintf(retStr,sizeof(buf),"%d - passwd",id);
} }
if (id == 9 ){ if (id == 9 ){
sprintf(retStr,"%d - testmode",id); snprintf(retStr,sizeof(buf),"%d - testmode",id);
} }
return buf; return buf;
} }
char * GetModulationStr( uint32_t id){ char * GetModulationStr( uint32_t id){
static char buf[60]; static char buf[60];
char *retStr = buf; char *retStr = buf;
switch (id){ switch (id){
case 0: case 0:
sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id); snprintf(retStr,sizeof(buf),"%d - DIRECT (ASK/NRZ)",id);
break; break;
case 1: 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; break;
case 2: 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; break;
case 3: 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; break;
case 4: 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; break;
case 5: 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; break;
case 6: 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; break;
case 7: 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; break;
case 8: case 8:
sprintf(retStr,"%d - Manschester",id); snprintf(retStr,sizeof(buf),"%d - Manschester",id);
break; break;
case 16: case 16:
sprintf(retStr,"%d - Biphase",id); snprintf(retStr,sizeof(buf),"%d - Biphase",id);
break; break;
case 0x18: 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; break;
case 17: case 17:
sprintf(retStr,"%d - Reserved",id); snprintf(retStr,sizeof(buf),"%d - Reserved",id);
break; break;
default: default:
sprintf(retStr,"0x%02X (Unknown)",id); snprintf(retStr,sizeof(buf),"0x%02X (Unknown)",id);
break; break;
} }
return buf; return buf;
@ -1028,48 +1030,48 @@ char * GetModelStrFromCID(uint32_t cid){
char * GetSelectedModulationStr( uint8_t id){ char * GetSelectedModulationStr( uint8_t id){
static char buf[16]; static char buf[20];
char *retStr = buf; char *retStr = buf;
switch (id){ switch (id){
case DEMOD_FSK: case DEMOD_FSK:
sprintf(retStr,"FSK"); snprintf(retStr,sizeof(buf),"FSK");
break; break;
case DEMOD_FSK1: case DEMOD_FSK1:
sprintf(retStr,"FSK1"); snprintf(retStr,sizeof(buf),"FSK1");
break; break;
case DEMOD_FSK1a: case DEMOD_FSK1a:
sprintf(retStr,"FSK1a"); snprintf(retStr,sizeof(buf),"FSK1a");
break; break;
case DEMOD_FSK2: case DEMOD_FSK2:
sprintf(retStr,"FSK2"); snprintf(retStr,sizeof(buf),"FSK2");
break; break;
case DEMOD_FSK2a: case DEMOD_FSK2a:
sprintf(retStr,"FSK2a"); snprintf(retStr,sizeof(buf),"FSK2a");
break; break;
case DEMOD_ASK: case DEMOD_ASK:
sprintf(retStr,"ASK"); snprintf(retStr,sizeof(buf),"ASK");
break; break;
case DEMOD_NRZ: case DEMOD_NRZ:
sprintf(retStr,"DIRECT/NRZ"); snprintf(retStr,sizeof(buf),"DIRECT/NRZ");
break; break;
case DEMOD_PSK1: case DEMOD_PSK1:
sprintf(retStr,"PSK1"); snprintf(retStr,sizeof(buf),"PSK1");
break; break;
case DEMOD_PSK2: case DEMOD_PSK2:
sprintf(retStr,"PSK2"); snprintf(retStr,sizeof(buf),"PSK2");
break; break;
case DEMOD_PSK3: case DEMOD_PSK3:
sprintf(retStr,"PSK3"); snprintf(retStr,sizeof(buf),"PSK3");
break; break;
case DEMOD_BI: case DEMOD_BI:
sprintf(retStr,"BIPHASE"); snprintf(retStr,sizeof(buf),"BIPHASE");
break; break;
case DEMOD_BIa: case DEMOD_BIa:
sprintf(retStr,"BIPHASEa - (CDP)"); snprintf(retStr,sizeof(buf),"BIPHASEa - (CDP)");
break; break;
default: default:
sprintf(retStr,"(Unknown)"); snprintf(retStr,sizeof(buf),"(Unknown)");
break; break;
} }
return buf; return buf;

View file

@ -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 at your option, any later version. See the LICENSE.txt file for the text of
the license. the license.
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -13,9 +14,7 @@ MEMORY
{ {
bootphase1 : ORIGIN = 0x00100000, LENGTH = 0x200 /* Phase 1 bootloader: Copies real bootloader to RAM */ 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 */ 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 = 0x00102000, LENGTH = 256K - 0x2000 /* Place where the main OS 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 */
ram : ORIGIN = 0x00200000, LENGTH = 64K - 0x20 /* RAM, minus small common area */ ram : ORIGIN = 0x00200000, LENGTH = 64K - 0x20 /* RAM, minus small common area */
commonarea : ORIGIN = 0x00200000 + 64K - 0x20, LENGTH = 0x20 /* Communication between bootloader and main OS */ commonarea : ORIGIN = 0x00200000 + 64K - 0x20, LENGTH = 0x20 /* Communication between bootloader and main OS */
} }

View file

@ -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 (BitStream[i] < *low) *low = BitStream[i];
} }
if (*high < 123) return -1; // just noise if (*high < 123) return -1; // just noise
*high = (int)(((*high-128)*(((float)fuzzHi)/100))+128); *high = ((*high-128)*fuzzHi + 12800)/100;
*low = (int)(((*low-128)*(((float)fuzzLo)/100))+128); *low = ((*low-128)*fuzzLo + 12800)/100;
return 1; 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 idx=0;
size_t numBits=0; size_t numBits=0;
uint32_t n=1; 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++) { for( idx=1; idx < size; idx++) {
n++; n++;
if (dest[idx]==lastval) continue; if (dest[idx]==lastval) continue;
//if lastval was 1, we have a 1->0 crossing //if lastval was 1, we have a 1->0 crossing
if (dest[idx-1]==1) { if (dest[idx-1]==1) {
if (!numBits && n < lowWaves/100) { if (!numBits && n < rfLen/fclow) {
n=0; n=0;
lastval = dest[idx]; lastval = dest[idx];
continue; continue;
} }
n = (size_t)((((n*1000)/lowWaves)+5)/10); n = (n * fclow + rfLen/2) / rfLen;
} else {// 0->1 crossing } else {// 0->1 crossing
//test first bitsample too small //test first bitsample too small
if (!numBits && n < highWaves/100) { if (!numBits && n < rfLen/fchigh) {
n=0; n=0;
lastval = dest[idx]; lastval = dest[idx];
continue; continue;
} }
n = (((n*1000)/highWaves)+5)/10; n = (n * fchigh + rfLen/2) / rfLen;
} }
if (n == 0) n = 1; 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]; lastval=dest[idx];
}//end for }//end for
// if valid extra bits at the end were all the same frequency - add them in // 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) { if (dest[idx-2]==1) {
n=(((n*1000)/lowWaves)+5)/10; n = (n * fclow + rfLen/2) / rfLen;
} else { } else {
n=(((n*1000)/highWaves)+5)/10; n = (n * fchigh + rfLen/2) / rfLen;
} }
memset(dest+numBits, dest[idx-1]^invert , n); memset(dest+numBits, dest[idx-1]^invert , n);
numBits += n; numBits += n;