diff --git a/firmware/Makefile b/firmware/Makefile index 6b0cef3..4b7a6d4 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -20,12 +20,12 @@ endif # Enable this if you want the linker to remove unused code and data. ifeq ($(USE_LINK_GC),) - USE_LINK_GC = yes + USE_LINK_GC = no endif # Linker extra options here. ifeq ($(USE_LDOPT),) - USE_LDOPT = + USE_LDOPT = endif # Enable this if you want link time optimizations (LTO). @@ -111,7 +111,7 @@ include $(CHIBIOS)/tools/mk/autobuild.mk include $(CHIBIOS)/os/hal/lib/streams/streams.mk # Define linker script file here -LDSCRIPT= $(CONFDIR)/STM32F042x6.ld +LDSCRIPT= $(CONFDIR)/app.ld # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. @@ -169,7 +169,7 @@ UINCDIR = ULIBDIR = # List all user libraries here -ULIBS = +ULIBS = bootloader/build/wideband_bootloader.o # # End of user section diff --git a/firmware/cfg/STM32F042x6.ld b/firmware/cfg/app.ld similarity index 79% rename from firmware/cfg/STM32F042x6.ld rename to firmware/cfg/app.ld index b49d750..7b06038 100644 --- a/firmware/cfg/STM32F042x6.ld +++ b/firmware/cfg/app.ld @@ -14,13 +14,15 @@ limitations under the License. */ -/* - * STM32F042x6 memory setup. - */ +/*INCLUDE wideband_layout.ld*/ + + +blsize = 8k; + MEMORY { - /* bootloader (rx) : org = 0x08000000, len = 8k */ - flash0 (rx) : org = 0x08000000, len = 24k + blflash (rx) : org = 0x08000000, len = blsize + appflash (rx) : org = 0x08000000 + blsize, len = 32k - blsize flash1 (rx) : org = 0x00000000, len = 0 flash2 (rx) : org = 0x00000000, len = 0 flash3 (rx) : org = 0x00000000, len = 0 @@ -28,7 +30,8 @@ MEMORY flash5 (rx) : org = 0x00000000, len = 0 flash6 (rx) : org = 0x00000000, len = 0 flash7 (rx) : org = 0x00000000, len = 0 - ram0 (wx) : org = 0x20000000, len = 6k + ram_vectors (wx) : org = 0x20000000, len = 256 + ram0 (wx) : org = 0x20000200, len = 6k - 256 ram1 (wx) : org = 0x00000000, len = 0 ram2 (wx) : org = 0x00000000, len = 0 ram3 (wx) : org = 0x00000000, len = 0 @@ -38,6 +41,13 @@ MEMORY ram7 (wx) : org = 0x00000000, len = 0 } +__appflash_start__ = ORIGIN(appflash); +__ram_vectors_start__ = ORIGIN(ram_vectors); +__ram_vectors_size__ = LENGTH(ram_vectors); + + +REGION_ALIAS("flash0", appflash); + /* For each data/text section two region are defined, a virtual region and a load region (_LMA suffix).*/ @@ -82,5 +92,17 @@ REGION_ALIAS("BSS_RAM", ram0); /* RAM region to be used for the default heap.*/ REGION_ALIAS("HEAP_RAM", ram0); +/* Bootloader section */ +SECTIONS +{ +.bl : ALIGN(4) + { + . = ALIGN(4); + *(.bl) + *(.bl.*) + . = ALIGN(4); + } > blflash AT > blflash +} + /* Generic rules inclusion.*/ INCLUDE rules.ld diff --git a/firmware/wideband_layout.ld b/firmware/wideband_layout.ld new file mode 100644 index 0000000..20e929a --- /dev/null +++ b/firmware/wideband_layout.ld @@ -0,0 +1,31 @@ +/* + * STM32F042x6 memory setup. + */ + +blsize = 8k; + +MEMORY +{ + blflash (rx) : org = 0x08000000, len = blsize + appflash (rx) : org = 0x08000000 + blsize, len = 32k - blsize + flash1 (rx) : org = 0x00000000, len = 0 + flash2 (rx) : org = 0x00000000, len = 0 + flash3 (rx) : org = 0x00000000, len = 0 + flash4 (rx) : org = 0x00000000, len = 0 + flash5 (rx) : org = 0x00000000, len = 0 + flash6 (rx) : org = 0x00000000, len = 0 + flash7 (rx) : org = 0x00000000, len = 0 + ram_vectors (wx) : org = 0x20000000, len = 256 + ram0 (wx) : org = 0x20000200, len = 6k - 256 + ram1 (wx) : org = 0x00000000, len = 0 + ram2 (wx) : org = 0x00000000, len = 0 + ram3 (wx) : org = 0x00000000, len = 0 + ram4 (wx) : org = 0x00000000, len = 0 + ram5 (wx) : org = 0x00000000, len = 0 + ram6 (wx) : org = 0x00000000, len = 0 + ram7 (wx) : org = 0x00000000, len = 0 +} + +__appflash_start__ = ORIGIN(appflash); +__ram_vectors_start__ = ORIGIN(ram_vectors); +__ram_vectors_size__ = LENGTH(ram_vectors);