diff options
24 files changed, 74 insertions, 141 deletions
@@ -73,6 +73,7 @@ ifeq ($(LIBMAPLE_MODULES),) else LIBMAPLE_MODULES += $(SRCROOT)/libmaple endif +LIBMAPLE_MODULES += $(LIBMAPLE_MODULE_FAMILY) # family submodule in libmaple LIBMAPLE_MODULES += $(SRCROOT)/wirish # Official libraries: LIBMAPLE_MODULES += $(SRCROOT)/libraries/Servo diff --git a/support/ld/libcs3_stm32_src/stm32_isrs.S b/libmaple/stm32f1/isrs_performance.S index be102e7..be102e7 100644 --- a/support/ld/libcs3_stm32_src/stm32_isrs.S +++ b/libmaple/stm32f1/isrs_performance.S diff --git a/libmaple/stm32f1/rules.mk b/libmaple/stm32f1/rules.mk new file mode 100644 index 0000000..5cadefd --- /dev/null +++ b/libmaple/stm32f1/rules.mk @@ -0,0 +1,23 @@ +# Standard things +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(dir) +BUILDDIRS += $(BUILD_PATH)/$(d) + +# Local rules and targets +sSRCS_$(d) := isrs_performance.S \ + vector_table_performance.S + +sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) + +OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) +DEPS_$(d) := $(OBJS_$(d):%.o=%.d) + +$(OBJS_$(d)): TGT_ASFLAGS := + +TGT_BIN += $(OBJS_$(d)) + +# Standard things +-include $(DEPS_$(d)) +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/support/ld/libcs3_stm32_src/stm32_vector_table.S b/libmaple/stm32f1/vector_table_performance.S index 7067d95..7067d95 100644 --- a/support/ld/libcs3_stm32_src/stm32_vector_table.S +++ b/libmaple/stm32f1/vector_table_performance.S diff --git a/support/ld/common.inc b/support/ld/common.inc index c6fa13a..0d1f4ed 100644 --- a/support/ld/common.inc +++ b/support/ld/common.inc @@ -6,7 +6,6 @@ OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") ENTRY(_start) -SEARCH_DIR(.) /* * Link against libgcc, libc, and libm @@ -22,10 +21,10 @@ GROUP(libgcc.a libc.a libm.a) */ INCLUDE vector_symbols.inc -/* STM32 vector table. See stm32_vector_table.S */ +/* STM32 vector table. */ EXTERN(__cs3_stm32_vector_table) -/* libcs3 C start function. See cs3.h */ +/* libcs3 C start function. */ EXTERN(__cs3_start_c) /* main entry point */ @@ -33,9 +32,9 @@ EXTERN(main) /* Initial stack pointer value. */ EXTERN(__cs3_stack) -PROVIDE(__cs3_stack = __cs3_region_start_ram + LENGTH(ram)); +PROVIDE(__cs3_stack = ORIGIN(ram) + LENGTH(ram)); -/* Reset vector and chip reset entry point. See start.S */ +/* Reset vector and chip reset entry point */ EXTERN(_start) PROVIDE(__cs3_reset = _start); @@ -48,7 +47,7 @@ SECTIONS /* TODO pull out rodata and stick into separate sections */ .text : { - __text_start = .; + _text = .; /* * STM32 vector table. Leave this here. Yes, really. */ @@ -100,17 +99,6 @@ SECTIONS KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*crtend.o(.dtors)) - - /* - * struct __cs3_region used during __cs3_start_c - */ - . = ALIGN(4); - __cs3_regions = .; - LONG (0) /* flags */ - LONG (__cs3_region_init_ram) /* initial contents */ - LONG (__cs3_region_start_ram) /* start address */ - LONG (__cs3_region_init_size_ram) /* size of initial data */ - LONG (__cs3_region_zero_size_ram) /* additional size to be zeroed */ } > REGION_TEXT /* @@ -119,6 +107,11 @@ SECTIONS .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) + + /* ROM image configuration; for C startup */ + . = ALIGN(4); + _lm_rom_img_cfgp = .; + LONG(LOADADDR(.data)); } > REGION_RODATA /* @@ -153,7 +146,8 @@ SECTIONS */ .data : { - __cs3_region_start_ram = DEFINED(_FLASH_BUILD) ? . : __text_start; + . = ALIGN(8); + _data = .; *(.got.plt) *(.got) *(.data .data.* .gnu.linkonce.d.*) @@ -178,26 +172,16 @@ SECTIONS */ .bss : { + . = ALIGN(8); + _bss = .; *(.bss .bss.* .gnu.linkonce.b.*) *(COMMON) . = ALIGN (8); - _end = .; + _ebss = .; + _end = _ebss; } > REGION_BSS AT> REGION_TEXT /* - * Constants needed for the pieces of CS3 we use during - * board startup; see libcs3_stm32_src/. - */ - __cs3_region_init_ram = (DEFINED(_FLASH_BUILD) ? - LOADADDR(.data) : - LOADADDR(.text)); - __cs3_region_init_size_ram = (DEFINED(_FLASH_BUILD) ? - _edata - ADDR(.data) : - _edata - ADDR(.text)); - __cs3_region_zero_size_ram = _end - _edata; - __cs3_region_num = 1; - - /* * Debugging sections */ .stab 0 (NOLOAD) : { *(.stab) } diff --git a/support/ld/libcs3_stm32_high_density.a b/support/ld/libcs3_stm32_high_density.a Binary files differdeleted file mode 100644 index b6650ca..0000000 --- a/support/ld/libcs3_stm32_high_density.a +++ /dev/null diff --git a/support/ld/libcs3_stm32_med_density.a b/support/ld/libcs3_stm32_med_density.a Binary files differdeleted file mode 100644 index e4660e3..0000000 --- a/support/ld/libcs3_stm32_med_density.a +++ /dev/null diff --git a/support/ld/libcs3_stm32_src/Makefile b/support/ld/libcs3_stm32_src/Makefile deleted file mode 100644 index 834cdad..0000000 --- a/support/ld/libcs3_stm32_src/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# setup environment - -TARGET_ARCH = -mcpu=cortex-m3 -mthumb - -CC = arm-none-eabi-gcc -CFLAGS = - -AS = $(CC) -x assembler-with-cpp -c $(TARGET_ARCH) -ASFLAGS = - -AR = arm-none-eabi-ar -ARFLAGS = cr - -LIB_OBJS = stm32_vector_table.o stm32_isrs.o start.o start_c.o - -help: - @echo "Targets:" - @echo "\t medium-density: Target medium density chips (e.g. Maple)" - @echo "\t high-density: Target high density chips (e.g. Maple-native)" - -.PHONY: help medium high - -medium-density: $(LIB_OBJS) - $(AR) $(ARFLAGS) libcs3_stm32_med_density.a $(LIB_OBJS) - rm -f $(LIB_OBJS) - -high-density: CFLAGS := -DSTM32_HIGH_DENSITY -high-density: $(LIB_OBJS) - $(AR) $(ARFLAGS) libcs3_stm32_high_density.a $(LIB_OBJS) - rm -f $(LIB_OBJS) - -# clean -.PHONY: clean -clean: - -rm -f $(LIB_OBJS) *.a diff --git a/support/ld/maple/flash.ld b/support/ld/maple/flash.ld index 8a179f7..190c187 100644 --- a/support/ld/maple/flash.ld +++ b/support/ld/maple/flash.ld @@ -11,11 +11,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K } -/* - * Use medium density device vector table - */ -GROUP(libcs3_stm32_med_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple/jtag.ld b/support/ld/maple/jtag.ld index 365068f..c090988 100644 --- a/support/ld/maple/jtag.ld +++ b/support/ld/maple/jtag.ld @@ -12,11 +12,6 @@ MEMORY rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K } -/* - * Use medium density device vector table - */ -GROUP(libcs3_stm32_med_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple/ram.ld b/support/ld/maple/ram.ld index 6f237c3..a5ef621 100644 --- a/support/ld/maple/ram.ld +++ b/support/ld/maple/ram.ld @@ -11,11 +11,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K } -/* - * Use medium density device vector table - */ -GROUP(libcs3_stm32_med_density.a) - REGION_ALIAS("REGION_TEXT", ram); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_RET6/flash.ld b/support/ld/maple_RET6/flash.ld index 4cf9c4b..8b529f8 100644 --- a/support/ld/maple_RET6/flash.ld +++ b/support/ld/maple_RET6/flash.ld @@ -9,8 +9,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K } -GROUP(libcs3_stm32_high_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_RET6/jtag.ld b/support/ld/maple_RET6/jtag.ld index 6055dfb..4ac9d76 100644 --- a/support/ld/maple_RET6/jtag.ld +++ b/support/ld/maple_RET6/jtag.ld @@ -9,8 +9,6 @@ MEMORY rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K } -GROUP(libcs3_stm32_high_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_RET6/ram.ld b/support/ld/maple_RET6/ram.ld index a4c273b..65c3a2c 100644 --- a/support/ld/maple_RET6/ram.ld +++ b/support/ld/maple_RET6/ram.ld @@ -9,8 +9,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K } -GROUP(libcs3_stm32_high_density.a) - REGION_ALIAS("REGION_TEXT", ram); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_mini/flash.ld b/support/ld/maple_mini/flash.ld index ab03207..52d01dc 100644 --- a/support/ld/maple_mini/flash.ld +++ b/support/ld/maple_mini/flash.ld @@ -11,11 +11,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 108K } -/* - * Use medium density device vector table - */ -GROUP(libcs3_stm32_med_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_mini/jtag.ld b/support/ld/maple_mini/jtag.ld index 2f9cf31..28e204f 100644 --- a/support/ld/maple_mini/jtag.ld +++ b/support/ld/maple_mini/jtag.ld @@ -12,11 +12,6 @@ MEMORY rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K } -/* - * Use medium density device vector table - */ -GROUP(libcs3_stm32_med_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_mini/ram.ld b/support/ld/maple_mini/ram.ld index 0ba0252..5b0111b 100644 --- a/support/ld/maple_mini/ram.ld +++ b/support/ld/maple_mini/ram.ld @@ -11,11 +11,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K } -/* - * Use medium density device vector table - */ -GROUP(libcs3_stm32_med_density.a) - REGION_ALIAS("REGION_TEXT", ram); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_native/flash.ld b/support/ld/maple_native/flash.ld index b6e10f8..aac5325 100644 --- a/support/ld/maple_native/flash.ld +++ b/support/ld/maple_native/flash.ld @@ -8,11 +8,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 492K } -/* - * Use high density device vector table - */ -GROUP(libcs3_stm32_high_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_native/jtag.ld b/support/ld/maple_native/jtag.ld index 9af2a11..412348e 100644 --- a/support/ld/maple_native/jtag.ld +++ b/support/ld/maple_native/jtag.ld @@ -9,11 +9,6 @@ MEMORY rom (rx) : ORIGIN = 0x08000000, LENGTH = 512K } -/* - * Use high density device vector table - */ -GROUP(libcs3_stm32_high_density.a) - REGION_ALIAS("REGION_TEXT", rom); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/ld/maple_native/ram.ld b/support/ld/maple_native/ram.ld index 7264316..eeec761 100644 --- a/support/ld/maple_native/ram.ld +++ b/support/ld/maple_native/ram.ld @@ -8,11 +8,6 @@ MEMORY rom (rx) : ORIGIN = 0x08005000, LENGTH = 0K } -/* - * Use high density device vector table - */ -GROUP(libcs3_stm32_high_density.a) - REGION_ALIAS("REGION_TEXT", ram); REGION_ALIAS("REGION_DATA", ram); REGION_ALIAS("REGION_BSS", ram); diff --git a/support/make/target-config.mk b/support/make/target-config.mk index f935cad..592e808 100644 --- a/support/make/target-config.mk +++ b/support/make/target-config.mk @@ -52,11 +52,12 @@ endif # STM32 family-specific configuration values. -# NB: this only works for STM32F1 performance line chips, but those +# NB: these only work for STM32F1 performance line chips, but those # are the only ones we support at this time. If you add support for # STM32F1 connectivity line MCUs or other STM32 families, this section # will need to change. LD_FAMILY_PATH := $(LDDIR)/stm32/f1/performance +LIBMAPLE_MODULE_FAMILY := $(LIBMAPLE_PATH)/stm32f1 # Memory target-specific configuration values diff --git a/wirish/rules.mk b/wirish/rules.mk index 6aa0904..1bf6245 100644 --- a/wirish/rules.mk +++ b/wirish/rules.mk @@ -12,8 +12,9 @@ WIRISH_INCLUDES := -I$(d) -I$(d)/comm -I$(d)/boards CFLAGS_$(d) := $(WIRISH_INCLUDES) $(LIBMAPLE_INCLUDES) # Local rules and targets -cSRCS_$(d) := +sSRCS_$(d) := start.S +cSRCS_$(d) := start_c.c cppSRCS_$(d) := wirish_math.cpp \ Print.cpp \ boards.cpp \ @@ -34,10 +35,12 @@ cppSRCS_$(d) := wirish_math.cpp \ ext_interrupts.cpp \ wirish_digital.cpp +sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%) cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%) cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%) -OBJS_$(d) := $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ +OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \ + $(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \ $(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o) DEPS_$(d) := $(OBJS_$(d):%.o=%.d) diff --git a/support/ld/libcs3_stm32_src/start.S b/wirish/start.S index 4d1d405..4d1d405 100644 --- a/support/ld/libcs3_stm32_src/start.S +++ b/wirish/start.S diff --git a/support/ld/libcs3_stm32_src/start_c.c b/wirish/start_c.c index 2ab0212..cb96fc5 100644 --- a/support/ld/libcs3_stm32_src/start_c.c +++ b/wirish/start_c.c @@ -13,7 +13,7 @@ * they apply. */ -#include "cs3.h" +#include <stddef.h> extern void __libc_init_array (void); @@ -21,30 +21,37 @@ extern int main (int, char **, char **); extern void exit (int) __attribute__ ((noreturn, weak)); -void __attribute ((noreturn)) +extern char _data, _edata; +extern char _bss, _ebss; + +struct rom_img_cfg { + long long *img_start; +}; + +extern char _lm_rom_img_cfgp; + +void __attribute__ ((noreturn)) __cs3_start_c (void) { - unsigned regions = __cs3_region_num; - const struct __cs3_region *rptr = __cs3_regions; + struct rom_img_cfg *img_cfg = (struct rom_img_cfg*)&_lm_rom_img_cfgp; + long long *src; + long long *dst; int exit_code; - /* Initialize memory */ - for (regions = __cs3_region_num, rptr = __cs3_regions; regions--; rptr++) - { - long long *src = (long long *)rptr->init; - long long *dst = (long long *)rptr->data; - unsigned limit = rptr->init_size; - unsigned count; - - if (src != dst) - for (count = 0; count != limit; count += sizeof (long long)) - *dst++ = *src++; - else - dst = (long long *)((char *)dst + limit); - limit = rptr->zero_size; - for (count = 0; count != limit; count += sizeof (long long)) - *dst++ = 0; + /* Initialize .data, if necessary. */ + src = img_cfg->img_start; + dst = (long long*)&_data; + if (src != dst) { + while (dst < (long long*)&_edata) { + *dst++ = *src++; } + } + + /* Zero .bss. */ + dst = (long long*)&_bss; + while (dst < (long long*)&_ebss) { + *dst++ = 0; + } /* Run initializers. */ __libc_init_array (); |