Use CPP to generate linker scripts

This commit is contained in:
iabdalkader 2014-07-31 06:26:19 +02:00
parent 52da153c0c
commit a93cd7fd7a
3 changed files with 45 additions and 120 deletions

View File

@ -3,6 +3,7 @@ AS = arm-none-eabi-as
LD = arm-none-eabi-ld
AR = arm-none-eabi-ar
RM = rm
CCP = arm-none-eabi-cpp
SIZE = arm-none-eabi-size
STRIP = arm-none-eabi-strip -s
OBJCOPY = arm-none-eabi-objcopy
@ -63,14 +64,8 @@ CFLAGS += -I$(TOP_DIR)/$(OMV_DIR)/img/
# Linker Flags
LDFLAGS = -mcpu=cortex-m4 -mabi=aapcs-linux -mthumb -mlittle-endian \
-mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostdlib -Wl,--gc-sections
ifeq ($(TARGET), OPENMV1)
LDFLAGS += -Wl,-T$(OMV_DIR)/stm32f407.ld
else
LDFLAGS += -Wl,-T$(OMV_DIR)/stm32f429.ld
endif
LDFLAGS = -mcpu=cortex-m4 -mabi=aapcs-linux -mthumb -mlittle-endian -mfloat-abi=hard\
-mfpu=fpv4-sp-d16 -nostdlib -Wl,--gc-sections -Wl,-T$(BUILD)/stm32f4xx.lds
#OBJ += $(wildcard $(BUILD)/$(CMSIS_DIR)/src/st/*.o)
OBJ += $(wildcard $(BUILD)/$(CMSIS_DIR)/src/dsp/CommonTables/*.o)
@ -227,6 +222,7 @@ all: | $(BUILD)
$(MAKE) -C $(CC3K_DIR) BUILD=$(BUILD)/$(CC3K_DIR)
$(MAKE) -C $(MICROPY_DIR)/stmhal BUILD=$(BUILD)/$(MICROPY_DIR) BOARD=$(TARGET) V=1
$(MAKE) -C $(OMV_DIR) BUILD=$(BUILD)/$(OMV_DIR)
$(CCP) -P -E $(OMV_DIR)/stm32f4xx.ld.S > $(BUILD)/stm32f4xx.lds
$(CC) $(LDFLAGS) $(OBJ) $(LIB) -o $(BUILD)/$(BIN).elf
$(OBJCOPY) -Obinary $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).bin
$(SIZE) $(BUILD)/$(BIN).elf

View File

@ -1,107 +0,0 @@
/**
* Linker script for STM32F429
* 2 MB FLASH, 192KB RAM 64KB CCM
*/
/* Entry Point */
ENTRY(Reset_Handler)
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K
FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 1984K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K
CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
SDRAM (xrw) : ORIGIN = 0xC0000000, LENGTH = 16M
}
/* Highest address of the user mode stack */
_estack = 0x10010000; /* Stack is allocated on CCM block */
_ram_end = 0x10010000; /* 64KB CCM */
/* Generate a link error if heap and stack don't fit into RAM */
_stack_size = 0x1300; /* required amount of stack */
_heap_size = 0x7800; /* required amount of heap */
_cache_size = 0x4000; /* required amount of cache */
_main_ram_start = 0x20000000;
/* Define output sections */
SECTIONS
{
/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH_ISR
/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
_exit = .;
} >FLASH_TEXT
/* used by the startup to initialize data */
_sidata = .;
/* Initialized data sections goes into RAM, load LMA copy after code */
.data : AT ( _sidata )
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
_ram_start = .;
*(.data) /* .data sections */
*(.data*) /* .data* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >CCM
/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
_bss_end = _ebss; /* for gccollect */
} >CCM
._heap :
{
. = ALIGN(4);
_heap_start = .;
. = . + _heap_size;
. = ALIGN(4);
_heap_end = .;
} >CCM
/* Make sure there is enough RAM left for the stack */
._user_heap_stack :
{
. = ALIGN(4);
. = . + _cache_size;
. = . + _stack_size;
. = ALIGN(4);
} >CCM
.ARM.attributes 0 : { *(.ARM.attributes) }
}

View File

@ -4,15 +4,51 @@
/* Entry Point */
ENTRY(Reset_Handler)
#ifdef OPENMV1
#define FLASH_ORIGIN 0x08000000
#define FLASH_LENGTH 512K
#define ISR_ORIGIN 0x08000000
#define ISR_LENGTH 16K
#define TEXT_ORIGIN 0x08010000
#define TEXT_LENGTH 448K
#define RAM_ORIGIN 0x20000000
#define RAM_LENGTH 128K
#define CCM_ORIGIN 0x10000000
#define CCM_LENGTH 64K
#else
#define FLASH_ORIGIN 0x08000000
#define FLASH_LENGTH 2048K
#define ISR_ORIGIN 0x08000000
#define ISR_LENGTH 16K
#define TEXT_ORIGIN 0x08010000
#define TEXT_LENGTH 1984K
#define RAM_ORIGIN 0x20000000
#define RAM_LENGTH 192K
#define CCM_ORIGIN 0x10000000
#define CCM_LENGTH 64K
#define SDRAM_ORIGIN 0xC0000000
#define SDRAM_LENGTH 16M
#endif //OPENMV1
/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 16K
FLASH_TEXT (rx) : ORIGIN = 0x08010000, LENGTH = 448K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCM (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx) : ORIGIN = FLASH_ORIGIN, LENGTH = FLASH_LENGTH
FLASH_ISR (rx) : ORIGIN = ISR_ORIGIN, LENGTH = ISR_LENGTH
FLASH_TEXT (rx) : ORIGIN = TEXT_ORIGIN, LENGTH = TEXT_LENGTH
RAM (xrw) : ORIGIN = RAM_ORIGIN, LENGTH = RAM_LENGTH
CCM (xrw) : ORIGIN = CCM_ORIGIN, LENGTH = CCM_LENGTH
}
/* Highest address of the user mode stack */