diff --git a/Makefile b/Makefile index 46f9b920a..81ba3dbe1 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,15 @@ GDB=arm-none-eabi-gdb OBJCOPY=arm-none-eabi-objcopy CFLAGS = -Iarch/stm32f429 -Iexternal/freertos/include -Iexternal -Iexternal/freertos/portable/GCC/ARM_CM4F -Iexternal/newlib/libc/include #-I/Users/romain/local/arm-none-eabi/include -CFLAGS += -std=c99 -g -Wall # -Os +CFLAGS += -std=c99 -g -Wall #CFLAGS += -march=armv7e-m -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 CC=clang CFLAGS += -target thumbv7em-unknown-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -ffreestanding +# Production +CFLAGS += -Os -fdata-sections -ffunction-sections +LDFLAGS += --gc-sections + objs := boot/crt0.o arch/stm32f429/isr.o arch/stm32f429/registers/rcc.o arch/stm32f429/registers/gpio.o external/freertos/tasks.o external/freertos/list.o external/freertos/queue.o external/freertos/portable/GCC/ARM_CM4F/port.o external/freertos/portable/MemMang/heap_1.o external/newlib/libc/string/memset.o external/newlib/libc/string/memcpy.o default: clean boot.elf @@ -21,7 +25,7 @@ test: test.elf $(GDB) -x test/gdb_script.gdb test.elf test.elf: $(objs) test/runner.o - @$(LD) -T boot/stm32f429.ld $(objs) test/runner.o -o $@ + @$(LD) $(LDFLAGS) $(objs) test/runner.o -o $@ boot.hex: boot.elf @echo "OBJCOPY $@" diff --git a/boot/stm32f429.ld b/boot/stm32f429.ld index 768f89f0f..fe90bee01 100644 --- a/boot/stm32f429.ld +++ b/boot/stm32f429.ld @@ -90,11 +90,13 @@ SECTIONS { PROVIDE(_HardFaultServiceRoutine = _halt); *(.text) + *(.text.*) } >FLASH .rodata : { . = ALIGN(4); *(.rodata) + *(.rodata.*) } >FLASH .data : { @@ -114,6 +116,7 @@ SECTIONS { _data_section_start_flash = LOADADDR(.data); _data_section_start_ram = .; *(.data) + *(.data.*) _data_section_end_ram = .; } >RAM AT> FLASH @@ -127,6 +130,7 @@ SECTIONS { . = ALIGN(4); _bss_section_start_ram = .; *(.bss) + *(.bss.*) _bss_section_end_ram = .; } >RAM diff --git a/gdb_script.gdb b/gdb_script.gdb index 56ba33c47..3d553d77e 100644 --- a/gdb_script.gdb +++ b/gdb_script.gdb @@ -9,4 +9,4 @@ monitor reset halt break main -#continue +continue