diff options
author | xengineering <me@xengineering.eu> | 2021-09-26 16:09:46 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2021-09-26 16:09:46 +0200 |
commit | 45a6fdb04f3bf605eb4280473dd22db041ece6a7 (patch) | |
tree | 95ae1f59121adf263529ced1305d312e6411411a | |
parent | 5d17a976070be9d66349da0ddd28361884f3461d (diff) | |
download | ledcontrol-45a6fdb04f3bf605eb4280473dd22db041ece6a7.tar ledcontrol-45a6fdb04f3bf605eb4280473dd22db041ece6a7.tar.zst ledcontrol-45a6fdb04f3bf605eb4280473dd22db041ece6a7.zip |
Remove startup.c and switch to libopencm3's Linker Script
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | ld/stm32f103c8t6.ld | 35 | ||||
-rw-r--r-- | src/startup.c | 50 |
4 files changed, 7 insertions, 84 deletions
@@ -1,3 +1,2 @@ docs -baremetal build @@ -1,6 +1,4 @@ -OBJS = main.o startup.o - # tools PREFIX ?= arm-none-eabi CC = $(PREFIX)-gcc @@ -10,8 +8,7 @@ OBJCOPY = $(PREFIX)-objcopy all: deps/libopencm3/lib/libopencm3_stm32f1.a mkdir build $(CC) -O0 -c -g -DSTM32F1 -Ideps/libopencm3/include -mcpu=cortex-m3 -mthumb -o build/main.o src/main.c - $(CC) -O0 -c -g -DSTM32F1 -Ideps/libopencm3/include -mcpu=cortex-m3 -mthumb -o build/startup.o src/startup.c - $(LD) --static -nostartfiles -mcpu=cortex-m3 -mthumb -msoft-float -Tld/stm32f103c8t6.ld -Ldeps/libopencm3/lib build/startup.o build/main.o -lopencm3_stm32f1 -o build/ledcontrol.elf + $(LD) --static -nostartfiles -mcpu=cortex-m3 -mthumb -msoft-float -Tld/stm32f103c8t6.ld -Ldeps/libopencm3/lib build/main.o -lopencm3_stm32f1 -o build/ledcontrol.elf $(OBJCOPY) -O binary build/ledcontrol.elf build/ledcontrol.bin deps/libopencm3/lib/libopencm3_stm32f1.a: diff --git a/ld/stm32f103c8t6.ld b/ld/stm32f103c8t6.ld index 9f74206..db01550 100644 --- a/ld/stm32f103c8t6.ld +++ b/ld/stm32f103c8t6.ld @@ -1,32 +1,9 @@ -SECTIONS -{ - . = 0x0; /* From 0x00000000 */ - - .text : - { - *(vectors) /* Vector table */ - *(.text) /* Program code */ - } - .rodata : - { - *(.rodata) /* Read only data */ - } - _DATA_ROM_START = .; - - . = 0x20000000; /* From 0x20000000 */ - _DATA_RAM_START = .; - .data : AT(_DATA_ROM_START) - { - *(.data) /* Data memory */ - } - _DATA_RAM_END = .; - - _BSS_START = .; /* Indicates where BSS section starts in RAM */ - .bss : - { - *(.bss) /* Zero-filled run time allocate data memory */ - } - _BSS_END = .; /* Indicates where BSS section ends in RAM */ +MEMORY +{ + rom (rx) : ORIGIN = 0x08000000, LENGTH = 64K + ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K } +INCLUDE cortex-m-generic.ld + diff --git a/src/startup.c b/src/startup.c deleted file mode 100644 index b71a805..0000000 --- a/src/startup.c +++ /dev/null @@ -1,50 +0,0 @@ - - -#define STACK_TOP 0x20005000 - - -extern unsigned int _BSS_START; -extern unsigned int _BSS_END; -extern unsigned int _DATA_ROM_START; -extern unsigned int _DATA_RAM_START; -extern unsigned int _DATA_RAM_END; - -void startup(); -void main(); - -// Define the vector table -unsigned int * myvectors[2] -__attribute__ ((section("vectors")))= { - (unsigned int *) STACK_TOP, // stack pointer - (unsigned int *) startup // code entry point -}; - -void startup() -{ - /* Set memory in bss segment to zeros */ - unsigned int * bss_start_p = &_BSS_START; - unsigned int * bss_end_p = &_BSS_END; - - while(bss_start_p != bss_end_p) - { - *bss_start_p = 0; - bss_start_p++; - } - - /* Copy memory in data segment from its position - * in the flash image to its position in the - * read/write memory */ - unsigned int * data_rom_start_p = &_DATA_ROM_START; - unsigned int * data_ram_start_p = &_DATA_RAM_START; - unsigned int * data_ram_end_p = &_DATA_RAM_END; - - while(data_ram_start_p != data_ram_end_p) - { - *data_ram_start_p = *data_rom_start_p; - data_ram_start_p++; - data_rom_start_p++; - } - - /* Now we are ready to start the main function */ - main(); -} |