diff --git a/ci/build.yml b/ci/build.yml index 27aaa1ffe..c89127c59 100644 --- a/ci/build.yml +++ b/ci/build.yml @@ -108,6 +108,8 @@ build crypto: # TODO: add clang https://github.com/trezor/trezor-firmware/issues/44 build legacy firmware: stage: build + variables: + MEMORY_PROTECT: "0" script: - cd legacy - pipenv run script/cibuild @@ -123,6 +125,7 @@ build legacy firmware debug: stage: build variables: DEBUG_LINK: "1" + MEMORY_PROTECT: "0" script: - cd legacy - pipenv run script/cibuild @@ -131,6 +134,7 @@ build legacy firmware bitcoinonly: stage: build variables: BITCOIN_ONLY: "1" + MEMORY_PROTECT: "0" script: - cd legacy - pipenv run script/cibuild diff --git a/legacy/Makefile.include b/legacy/Makefile.include index 1ddc13f47..65500c4b3 100644 --- a/legacy/Makefile.include +++ b/legacy/Makefile.include @@ -135,10 +135,12 @@ CFLAGS += -DU2F_ENABLED=1 endif ifeq ($(MEMORY_PROTECT), 0) -CFLAGS += -DMEMORY_PROTECT=0 +CFLAGS += -DMEMORY_PROTECT=0 +CPUFLAGS += -DMEMORY_PROTECT=0 $(info MEMORY_PROTECT=0) else -CFLAGS += -DMEMORY_PROTECT=1 +CFLAGS += -DMEMORY_PROTECT=1 +CPUFLAGS += -DMEMORY_PROTECT=1 $(info MEMORY_PROTECT=1) endif @@ -194,9 +196,9 @@ $(NAME).elf: $(OBJS) $(LDSCRIPT) $(LIBDEPS) @printf " LD $@\n" $(Q)$(LD) -o $(NAME).elf $(OBJS) $(LDLIBS) $(LDFLAGS) -%.o: %.s Makefile +%.o: %.S Makefile @printf " AS $@\n" - $(Q)$(AS) $(CPUFLAGS) -o $@ $< + $(Q)$(CC) $(CPUFLAGS) -o $@ -c $< %.o: %.c Makefile @printf " CC $@\n" diff --git a/legacy/firmware/bl_check.c b/legacy/firmware/bl_check.c index 218c3d0c0..b548fc603 100644 --- a/legacy/firmware/bl_check.c +++ b/legacy/firmware/bl_check.c @@ -26,6 +26,8 @@ #include "memory.h" #include "util.h" +#if MEMORY_PROTECT + static int known_bootloader(int r, const uint8_t *hash) { if (r != 32) return 0; if (0 == @@ -126,6 +128,7 @@ static int known_bootloader(int r, const uint8_t *hash) { return 1; // 1.8.0 shipped with fw 1.8.0 and 1.8.1 return 0; } +#endif void check_bootloader(void) { #if MEMORY_PROTECT diff --git a/legacy/startup.s b/legacy/startup.S similarity index 98% rename from legacy/startup.s rename to legacy/startup.S index ce75ba1a7..f79646cad 100644 --- a/legacy/startup.s +++ b/legacy/startup.S @@ -19,6 +19,8 @@ memset_reg: .global reset_handler .type reset_handler, STT_FUNC reset_handler: + +#if MEMORY_PROTECT // we need to perform this in case an old bootloader // is starting the new firmware, these will be set incorrectly ldr r0, =0xE000ED08 // r0 = VTOR address @@ -28,6 +30,7 @@ reset_handler: msr msp, r0 // set stack pointer dsb isb +#endif ldr r0, =_ram_start // r0 - point to beginning of SRAM ldr r1, =_ram_end // r1 - point to byte after the end of SRAM