From 4a70ed2ff7d32b676f9afe0cd3d4ea749e8ebe0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 9 Mar 2020 10:07:57 +0100 Subject: [PATCH] Rakefile: add dongle definition and specific linker script --- Rakefile | 12 +++++++++--- application.dongle.ld | 30 ++++++++++++++++++++++++++++++ bootloader.dongle.ld | 30 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 application.dongle.ld create mode 100644 bootloader.dongle.ld diff --git a/Rakefile b/Rakefile index 59c1205..dc25aaf 100644 --- a/Rakefile +++ b/Rakefile @@ -38,7 +38,7 @@ OBJCOPY = PREFIX+"-objcopy" OBJDUMP = PREFIX+"-objdump" GDB = PREFIX+"-gdb" -# BusVoodoo hardware version (0=0, 1=A, ...) +# BusVoodoo hardware version (0=0, 1=A, 2=DONGLE) # mainly because version 0 uses different pins) BUSVOODOO_HARDWARE_VERSION = ENV["BUSVOODOO_HARDWARE_VERSION"] || 1 @@ -157,8 +157,14 @@ rule '.d' => ['.c', "#{LIBOPENCM3_LIB}/lib#{STM32F1_LIB}.a"] do |t| end desc "link binary" -rule '.elf' => ['.o', proc{|f| dependencies(f)}, '.ld', "#{LIBOPENCM3_LIB}/lib#{STM32F1_LIB}.a"] do |t| - sh "#{LD} #{archflags} #{ldflags.join(' ')} #{t.prerequisites[0..-3].join(' ')} -T#{t.name.ext('ld')} #{ldflags_linker.collect{|flag| "-Wl,"+flag}.join(' ')} #{library_paths.collect{|path| "-L"+path}.join(' ')} #{ldlibs.collect{|lib| "-l"+lib}.join(' ')} -Wl,--start-group #{ldlibs_linker.collect{|lib| "-l"+lib}.join(' ')} -Wl,--end-group --output #{t.name}" +if "2" != BUSVOODOO_HARDWARE_VERSION then + rule '.elf' => ['.o', proc{|f| dependencies(f)}, '.ld', "#{LIBOPENCM3_LIB}/lib#{STM32F1_LIB}.a"] do |t| + sh "#{LD} #{archflags} #{ldflags.join(' ')} #{t.prerequisites[0..-3].join(' ')} -T#{t.name.ext('ld')} #{ldflags_linker.collect{|flag| "-Wl,"+flag}.join(' ')} #{library_paths.collect{|path| "-L"+path}.join(' ')} #{ldlibs.collect{|lib| "-l"+lib}.join(' ')} -Wl,--start-group #{ldlibs_linker.collect{|lib| "-l"+lib}.join(' ')} -Wl,--end-group --output #{t.name}" + end +else + rule '.elf' => ['.o', proc{|f| dependencies(f)}, '.dongle.ld', "#{LIBOPENCM3_LIB}/lib#{STM32F1_LIB}.a"] do |t| + sh "#{LD} #{archflags} #{ldflags.join(' ')} #{t.prerequisites[0..-3].join(' ')} -T#{t.name.ext('dongle.ld')} #{ldflags_linker.collect{|flag| "-Wl,"+flag}.join(' ')} #{library_paths.collect{|path| "-L"+path}.join(' ')} #{ldlibs.collect{|lib| "-l"+lib}.join(' ')} -Wl,--start-group #{ldlibs_linker.collect{|lib| "-l"+lib}.join(' ')} -Wl,--end-group --output #{t.name}" + end end desc "export binary" diff --git a/application.dongle.ld b/application.dongle.ld new file mode 100644 index 0000000..faf834c --- /dev/null +++ b/application.dongle.ld @@ -0,0 +1,30 @@ +/* linker script for application running on STM32F103x8 micro-controller + * the STM32F103x8 has 64 KB of flash starting at 0x0800 0000, and 20 KB of RAM starting at 0x2000 0000 + * the STM32F103xB has 128 KB of flash starting at 0x0800 0000, and 20 KB of RAM starting at 0x2000 0000 + * STM32F103x8 most often have in fact 128 KB, instead of the specified and advertised 64 KB, like the STM32F103xB + * CS32F103x8 has really only 64 KB of flash, which is not enough for he BusVoodoo firmware + * the USB DFU bootloader will take the first 8 KB of flash, followed by the application + * the first 4 bytes of the RAM is reserved for the DFU magic word (DFU! to start DFU bootloader) + */ + +/* define memory regions. */ +MEMORY +{ + rom (rx) : ORIGIN = 0x08000000 + 8K, LENGTH = 128K - 8K + ram (rwx) : ORIGIN = 0x20000000 + 4, LENGTH = 20K - 4 +} +PROVIDE(__application_beginning = ORIGIN(rom)); +/* if you want the firmware to use the flash size advertised by the micro-controller itself, use the following: +PROVIDE(__application_end = 0); +PROVIDE(__flash_end = 0); + if you want to enforce a flash size, because there is more flash than advertized by the micro-controller, use to following: +PROVIDE(__application_end = ORIGIN(rom) + LENGTH(rom)); +PROVIDE(__flash_end = ORIGIN(rom) + LENGTH(rom)); +*/ +PROVIDE(__application_end = ORIGIN(rom) + LENGTH(rom)); +PROVIDE(__flash_end = ORIGIN(rom) + LENGTH(rom)); +/* RAM location reserved so application can talk to bootloader and tell to start DFU */ +PROVIDE(__dfu_magic = ORIGIN(ram) - 4); + +/* include rest of the definitions for the ARM Cortex-M, including STM32F1 family */ +INCLUDE cortex-m-generic.ld diff --git a/bootloader.dongle.ld b/bootloader.dongle.ld new file mode 100644 index 0000000..2d5fc6e --- /dev/null +++ b/bootloader.dongle.ld @@ -0,0 +1,30 @@ +/* linker script for application running on STM32F103x8 micro-controller + * the STM32F103x8 has 64 KB of flash starting at 0x0800 0000, and 20 KB of RAM starting at 0x2000 0000 + * the STM32F103xB has 128 KB of flash starting at 0x0800 0000, and 20 KB of RAM starting at 0x2000 0000 + * STM32F103x8 most often have in fact 128 KB, instead of the specified and advertised 64 KB, like the STM32F103xB + * CS32F103x8 has really only 64 KB of flash, which is not enough for he BusVoodoo firmware + * the USB DFU bootloader will take the first 8 KB of flash, followed by the application + * the first 4 bytes of the RAM is reserved for the DFU magic word (DFU! to start DFU bootloader) + */ + +/* define memory regions. */ +MEMORY +{ + rom (rx) : ORIGIN = 0x08000000, LENGTH = 8K + ram (rwx) : ORIGIN = 0x20000000 + 4, LENGTH = 20K - 4 +} +PROVIDE(__application_beginning = ORIGIN(rom) + LENGTH(rom)); +/* if you want the firmware to use the flash size advertised by the micro-controller itself, use the following: +PROVIDE(__application_end = 0); +PROVIDE(__flash_end = 0); + if you want to enforce a flash size, because there is more flash than advertised by the micro-controller, use to following: +PROVIDE(__application_end = ORIGIN(rom) + 128K); +PROVIDE(__flash_end = ORIGIN(rom) + 128K); +*/ +PROVIDE(__application_end = ORIGIN(rom) + 128K); +PROVIDE(__flash_end = ORIGIN(rom) + 128K); +/* RAM location reserved so application can talk to bootloader and tell to start DFU */ +PROVIDE(__dfu_magic = ORIGIN(ram) - 4); + +/* include rest of the definitions for the ARM Cortex-M, including STM32F1 family */ +INCLUDE cortex-m-generic.ld