diff --git a/targets/stm32l442/Makefile b/targets/stm32l442/Makefile index 4be0573..217013c 100644 --- a/targets/stm32l442/Makefile +++ b/targets/stm32l442/Makefile @@ -1,20 +1,26 @@ +ifndef DEBUG +DEBUG=0 +endif all: - $(MAKE) -f application.mk -j8 solo.hex + $(MAKE) -f application.mk -j8 solo.hex DEBUG=$(DEBUG) -debug: - $(MAKE) -f application.mk -j8 solo.hex DEBUG=1 +all-hacker: + $(MAKE) -f application.mk -j8 solo.hex EXTRA_DEFINES='-DSOLO_HACKER' debugboot-app: $(MAKE) -f application.mk -j8 solo.hex DEBUG=1 \ - LDSCRIPT=linker/stm32l4xx_extra.ld EXTRA_DEFINES='-DAPPLICATION_START_PAGE=16' + LDSCRIPT=linker/stm32l4xx_extra.ld EXTRA_DEFINES='-DAPPLICATION_START_PAGE=16 -DSOLO_HACKER' debugboot-boot: $(MAKE) -f bootloader.mk -j8 bootloader.hex DEBUG=1 \ - LDSCRIPT=linker/bootloader_stm32l4xx_extra.ld EXTRA_DEFINES='-DAPPLICATION_START_PAGE=16' + LDSCRIPT=linker/bootloader_stm32l4xx_extra.ld EXTRA_DEFINES='-DAPPLICATION_START_PAGE=16 -DSOLO_HACKER' boot: - $(MAKE) -f bootloader.mk -j8 bootloader.hex + $(MAKE) -f bootloader.mk -j8 bootloader.hex DEBUG=$(DEBUG) + +boot-hacker: + $(MAKE) -f bootloader.mk -j8 bootloader.hex EXTRA_DEFINES='-DSOLO_HACKER' clean: $(MAKE) -f application.mk clean @@ -28,7 +34,7 @@ flash: solo.hex bootloader.hex flash_dfu: solo.hex bootloader.hex python merge_hex.py solo.hex bootloader.hex all.hex # STM32_Programmer_CLI -c port=usb1 -halt -e all --readunprotect - STM32_Programmer_CLI -c port=usb1 -halt -d all.hex + STM32_Programmer_CLI -c port=usb1 -halt -rdu -d all.hex flashboot: solo.hex bootloader.hex python merge_hex.py solo.hex bootloader.hex all.hex diff --git a/targets/stm32l442/bootloader/bootloader.h b/targets/stm32l442/bootloader/bootloader.h index 4d0c957..f17c56d 100644 --- a/targets/stm32l442/bootloader/bootloader.h +++ b/targets/stm32l442/bootloader/bootloader.h @@ -15,8 +15,6 @@ #define IS_BOOTLOADER 1 -#define SOLO_HACKER - #define ENABLE_U2F_EXTENSIONS // #define ENABLE_U2F @@ -53,6 +51,7 @@ void hw_init(void); void device_reboot(); int is_authorized_to_boot(); +int is_bootloader_disabled(); void bootloader_heartbeat(); #endif diff --git a/targets/stm32l442/linker/bootloader_stm32l4xx.ld b/targets/stm32l442/linker/bootloader_stm32l4xx.ld index 8b0aea5..333501a 100644 --- a/targets/stm32l442/linker/bootloader_stm32l4xx.ld +++ b/targets/stm32l442/linker/bootloader_stm32l4xx.ld @@ -41,7 +41,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */ /* Specify the memory areas */ MEMORY { -FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 14K +FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 20K RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K SRAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K } diff --git a/targets/stm32l442/linker/stm32l4xx.ld b/targets/stm32l442/linker/stm32l4xx.ld index e005e05..bc7424f 100644 --- a/targets/stm32l442/linker/stm32l4xx.ld +++ b/targets/stm32l442/linker/stm32l4xx.ld @@ -42,7 +42,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */ MEMORY { /* First 14 KB is bootloader */ -FLASH (rx) : ORIGIN = 0x08003800, LENGTH = 204K-8 /* Leave out 38 Kb at end for data */ +FLASH (rx) : ORIGIN = 0x08005000, LENGTH = 198K-8 /* Leave out 38 Kb at end for data */ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 48K SRAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K } diff --git a/targets/stm32l442/src/app.h b/targets/stm32l442/src/app.h index 5c41d44..ab69aee 100644 --- a/targets/stm32l442/src/app.h +++ b/targets/stm32l442/src/app.h @@ -13,11 +13,6 @@ #define BOOT_TO_DFU 0 -// Uncomment SOLO_HACKKER to Only use level 1 read-out-protection, -// allows booting to ST bootloader or Solo bootloader without any button press, -// Disables signature check in Solo bootloader. -#define SOLO_HACKER - //#define USING_DEV_BOARD //#define ENABLE_U2F_EXTENSIONS diff --git a/targets/stm32l442/src/memory_layout.h b/targets/stm32l442/src/memory_layout.h index 17a0ed7..63a7543 100644 --- a/targets/stm32l442/src/memory_layout.h +++ b/targets/stm32l442/src/memory_layout.h @@ -21,7 +21,7 @@ // Start of application code #ifndef APPLICATION_START_PAGE -#define APPLICATION_START_PAGE (7) +#define APPLICATION_START_PAGE (10) #endif #define APPLICATION_START_ADDR (0x08000000 + ((APPLICATION_START_PAGE)*PAGE_SIZE)) @@ -31,6 +31,6 @@ #define APPLICATION_END_ADDR ((0x08000000 + ((APPLICATION_END_PAGE)*PAGE_SIZE))-8) // Bootloader state. -#define AUTH_WORD_ADDR ((0x08000000 + ((APPLICATION_END_PAGE)*PAGE_SIZE))-8) +#define AUTH_WORD_ADDR (APPLICATION_END_ADDR) #endif