From e10cabc05478cdd432c6f1fab933a7b8a7915a34 Mon Sep 17 00:00:00 2001 From: Thibaut VIARD Date: Thu, 5 Apr 2012 18:23:19 +0200 Subject: [PATCH] [sam] fixing linker files and adding a compiler option --- hardware/arduino/sam/platform.txt | 4 +- .../arduino_due_x/linker_scripts/gcc/flash.ld | 54 +++++++++---------- .../arduino_due_x/linker_scripts/gcc/sram.ld | 54 +++++++++---------- 3 files changed, 50 insertions(+), 62 deletions(-) diff --git a/hardware/arduino/sam/platform.txt b/hardware/arduino/sam/platform.txt index 63b9979da..12e67027d 100644 --- a/hardware/arduino/sam/platform.txt +++ b/hardware/arduino/sam/platform.txt @@ -5,12 +5,12 @@ name=Atmel SAM3 compiler.path={runtime.ide.path}/hardware/tools/g++_arm_none_eabi/bin/ compiler.c.cmd=arm-none-eabi-gcc -compiler.c.flags=-c -g -Os -w -mlong-calls -ffunction-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf +compiler.c.flags=-c -g -Os -w -mlong-calls -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf compiler.c.elf.cmd=arm-none-eabi-gcc compiler.c.elf.flags=-Os -Wl,--gc-sections compiler.S.flags=-c -g -assembler-with-cpp compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-c -g -Os -w -mlong-calls -ffunction-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf +compiler.cpp.flags=-c -g -Os -w -mlong-calls -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf compiler.ar.cmd=arm-none-eabi-ar compiler.ar.flags=rcs compiler.objcopy.cmd=arm-none-eabi-objcopy diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld index c79e630a5..8d652b606 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld @@ -1,12 +1,12 @@ /* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support + * SAM Software Package License * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation + * Copyright (c) 2012, Atmel Corporation * * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * modification, are permitted provided that the following condition is met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the disclaimer below. @@ -27,10 +27,6 @@ * ---------------------------------------------------------------------------- */ -/*------------------------------------------------------------------------------ - * Linker script for running in internal FLASH on the SAM3U4 - *----------------------------------------------------------------------------*/ - OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) SEARCH_DIR(.) @@ -38,22 +34,20 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ - flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ - sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ - sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ - rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ - ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ + rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */ + sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */ + sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */ + ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */ } /* The stack size used by the application. NOTE: you need to adjust */ -STACK_SIZE = 0x2000; +STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x2000 ; -/* Section Definitions */ -SECTIONS -{ - .text : - { +/* Section Definitions */ +SECTIONS +{ + .text : + { . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) @@ -99,17 +93,17 @@ SECTIONS . = ALIGN(4); _efixed = .; /* End of text section */ - } > flash0 + } > rom /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > flash0 + } > rom PROVIDE_HIDDEN (__exidx_end = .); - . = ALIGN(4); + . = ALIGN(4); _etext = .; .relocate : AT (_etext) @@ -120,11 +114,11 @@ SECTIONS *(.data .data.*); . = ALIGN(4); _erelocate = .; - } > sram0 + } > ram - /* .bss section which is used for uninitialized data */ + /* .bss section which is used for uninitialized data */ .bss (NOLOAD) : - { + { . = ALIGN(4); _sbss = . ; _szero = .; @@ -133,18 +127,18 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; - } > sram0 + } > ram /* stack section */ .stack (NOLOAD): { . = ALIGN(8); - _sstack = .; + _sstack = .; . = . + STACK_SIZE; . = ALIGN(8); _estack = .; - } > sram1 + } > ram - . = ALIGN(4); - _end = . ; + . = ALIGN(4); + _end = . ; } diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld index c8e21ad30..947b2f81e 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld @@ -1,12 +1,12 @@ /* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support + * SAM Software Package License * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation + * Copyright (c) 2012, Atmel Corporation * * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * modification, are permitted provided that the following condition is met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the disclaimer below. @@ -27,10 +27,6 @@ * ---------------------------------------------------------------------------- */ -/*------------------------------------------------------------------------------ - * Linker script for running in internal SRAM on the SAM3U4 - *----------------------------------------------------------------------------*/ - OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) SEARCH_DIR(.) @@ -38,22 +34,20 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ - flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ - sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ - sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ - rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ - ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ + rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */ + sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */ + sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */ + ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */ } /* The stack size used by the application. NOTE: you need to adjust */ -STACK_SIZE = 0x800; +STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x2000 ; -/* Section Definitions */ -SECTIONS -{ - .text : - { +/* Section Definitions */ +SECTIONS +{ + .text : + { . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) @@ -99,9 +93,9 @@ SECTIONS . = ALIGN(4); _efixed = .; /* End of text section */ - } > sram0 + } > ram - . = ALIGN(4); + . = ALIGN(4); _etext = .; .relocate : AT (_etext) @@ -112,11 +106,11 @@ SECTIONS *(.data .data.*); . = ALIGN(4); _erelocate = .; - } > sram1 + } > ram - /* .bss section which is used for uninitialized data */ + /* .bss section which is used for uninitialized data */ .bss (NOLOAD) : - { + { . = ALIGN(4); _sbss = . ; _szero = .; @@ -125,26 +119,26 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; - } > sram1 + } > ram /* stack section */ .stack (NOLOAD): { . = ALIGN(8); - _sstack = .; + _sstack = .; . = . + STACK_SIZE; . = ALIGN(8); _estack = .; - } > sram1 + } > ram /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > sram1 + } > ram PROVIDE_HIDDEN (__exidx_end = .); - . = ALIGN(4); - _end = . ; + . = ALIGN(4); + _end = . ; }