diff --git a/armsrc/Makefile b/armsrc/Makefile index 46ba4f027..074380058 100644 --- a/armsrc/Makefile +++ b/armsrc/Makefile @@ -217,8 +217,12 @@ $(OBJDIR)/fullimage.data.o: $(OBJDIR)/fullimage.data.bin.z $(Q)$(OBJCOPY) -O elf32-littlearm -I binary -B arm --rename-section .data=compressed_data $^ $@ $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.nodata.o $(OBJDIR)/fullimage.data.o +ifneq ($(SKIP_COMPRESSION),1) $(info [=] LD $@) $(Q)$(CC) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-e,_osimage_entry,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ +else + $(Q)$(CP) $(OBJDIR)/fullimage.stage1.elf $@ +endif tarbin: $(OBJS) $(info TAR $@) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index fe8566363..b4c3d6a30 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -257,6 +257,9 @@ void ReadMem(int addr) { /* osimage version information is linked in, cf commonutil.h */ /* bootrom version information is pointed to from _bootphase1_version_pointer */ extern char *_bootphase1_version_pointer, _flash_start, _flash_end, __data_src_start__; +#ifdef WITH_NO_COMPRESSION +extern char *_bootrom_end, _bootrom_start, __os_size__; +#endif static void SendVersion(void) { char temp[PM3_CMD_DATA_SIZE - 12]; /* Limited data payload in USB packets */ char VersionString[PM3_CMD_DATA_SIZE - 12] = { '\0' }; @@ -295,9 +298,11 @@ static void SendVersion(void) { strncat(VersionString, "\n ", sizeof(VersionString) - strlen(VersionString) - 1); } } +#ifndef WITH_NO_COMPRESSION // 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; +#endif struct p { uint32_t id; @@ -308,7 +313,11 @@ static void SendVersion(void) { struct p payload; payload.id = *(AT91C_DBGU_CIDR); - payload.section_size = text_and_rodata_section_size + compressed_data_section_size; +#ifdef WITH_NO_COMPRESSION + payload.section_size = (uint32_t)&_bootrom_end - (uint32_t)&_bootrom_start + (uint32_t)&__os_size__; +#else + payload.section_size = text_and_rodata_section_size + compressed_data_section_size; +#endif payload.versionstr_len = strlen(VersionString) + 1; memcpy(payload.versionstr, VersionString, payload.versionstr_len); diff --git a/armsrc/start.c b/armsrc/start.c index 70eee5063..542b9f3f4 100644 --- a/armsrc/start.c +++ b/armsrc/start.c @@ -14,14 +14,16 @@ #include "proxmark3_arm.h" #include "appmain.h" +#ifndef WITH_NO_COMPRESSION #include "lz4.h" +#endif #include "BigBuf.h" #include "string.h" extern struct common_area common_area; extern char __data_src_start__, __data_start__, __data_end__, __bss_start__, __bss_end__; - +#ifndef WITH_NO_COMPRESSION static void uncompress_data_section(void) { int avail_in; memcpy(&avail_in, &__data_src_start__, sizeof(int)); @@ -35,6 +37,7 @@ static void uncompress_data_section(void) { // save the size of the compressed data section common_area.arg1 = avail_in; } +#endif void __attribute__((section(".startos"))) Vector(void); void Vector(void) { @@ -47,12 +50,23 @@ void Vector(void) { common_area.version = 1; } common_area.flags.osimage_present = 1; - - uncompress_data_section(); + +#ifdef WITH_NO_COMPRESSION + /* Set up data segment: Copy from flash to ram */ + char *src = &__data_src_start__; + char *dst = &__data_start__; + char *end = &__data_end__; + while(dst < end) *dst++ = *src++; + dst = &__bss_start__; + end = &__bss_end__; +#else + uncompress_data_section(); /* Set up (that is: clear) BSS. */ char *dst = &__bss_start__; char *end = &__bss_end__; +#endif + while (dst < end) *dst++ = 0; AppMain(); diff --git a/common_arm/Makefile.hal b/common_arm/Makefile.hal index 24d31261e..bfbe56d34 100644 --- a/common_arm/Makefile.hal +++ b/common_arm/Makefile.hal @@ -137,6 +137,9 @@ endif ifneq ($(SKIP_HFPLOT),1) PLATFORM_DEFS += -DWITH_HFPLOT endif +ifeq ($(SKIP_COMPRESSION),1) + PLATFORM_DEFS += -DWITH_NO_COMPRESSION +endif # Standalone mode ifneq ($(strip $(filter $(PLATFORM_DEFS),$(STANDALONE_REQ_DEFS))),$(strip $(STANDALONE_REQ_DEFS)))