예제


원본 출처

http://www.mikrocontroller.net/attachment/143228/stm32_flash.ld




/*

*****************************************************************************

**

**  File        : stm32_flash.ld

**

**  Abstract    : Linker script for STM32F207 Device with

**                1MByte FLASH, 128KByte SRAM

**

**                Set heap size, stack size and stack location according

**                to application requirements.

**

**                Set memory bank area and size if external memory is used.

**

**  Target      : STMicroelectronics STM32

**

**  Environment : Eclipse with CDT plugin and GCC compiler from CodeSourcery

**

** Author           Date        Comment

**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

**    T.Kamenicky      24/06/11    Upravil kod stazen z netu

** T.Kamenicky 13/10/11 Predelal na STM32F2

** T.Kamenicky 29/11/11    Pridal podporu externi SRAM

**

*****************************************************************************

*/


/* Entry Point */

/* This define entry point for linker, this address is used for CPU too as absolute first function */

ENTRY(Reset_Handler)


/* Highest address of the user mode stack, _estack is end of stack */

_estack = 0x20020000;    /* end of 128K RAM */


/* Generate a link error if heap and stack don't fit into RAM */

/* Heap is zero because we use own malloc implementation. The amount of heap is calculated 

 * from free space after compilation, see last section for RAM area */

_Min_Heap_Size = 0x0;      /* required amount of heap  */


/* This stack is used for main function. If FreeRTOS is used this stack is used by OS itself. */

/* The size of stack for tasks is defined in freertos config file and when creating the task. */

_Min_Stack_Size = 0x600; /* required amount of stack */


/* Specify the memory areas */

MEMORY

{

  FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 1022K  /* This is main program area */

  FACTORY_VAR(rx) : ORIGIN = 0x080FF800, LENGTH = 2K  /* This area is used for factory values, such as MAC address, ID...etc */

  RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 128K        /* This is RAM area */

  FSMC_SRAM (rx)  : ORIGIN = 0x64000000, LENGTH = 2048K       /* This is useful for external memory, like thru FSMC peripheral */

}


/* Define output sections */

SECTIONS

{

   /* The startup code goes first into FLASH */

  .isr_vector :

  {

    . = ALIGN(4);

    KEEP(*(.isr_vector)) /* Startup code */

    . = ALIGN(4);

  } >FLASH


  /* 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.) */

    *(.glue_7)         /* glue arm to thumb code */

    *(.glue_7t)        /* glue thumb to arm code */


    KEEP (*(.init))

    KEEP (*(.fini))


     . = ALIGN(4);

    _etext = .;        /* define a global symbols at end of code */

  } >FLASH


  /* .ARM.extab names a section that contains exception unwinding information.  See EHABI for details. */

  /* .ARM.exidx names a section that contains index entries for section unwinding.  See EHABI for details. */

   .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH

    .ARM : {

    __exidx_start = .;

      *(.ARM.exidx*)

      __exidx_end = .;

    } >FLASH


  /* Is used for compiler information, which is located only in elf file */

  .ARM.attributes 0 : { *(.ARM.attributes) }


  /* Those sections is used for initializing dynamic objects used in C++ */

 .preinit_array     :

  {

    PROVIDE_HIDDEN (__preinit_array_start = .);

    KEEP (*(.preinit_array*))

    PROVIDE_HIDDEN (__preinit_array_end = .);

  } >FLASH

  .init_array :

  {

    PROVIDE_HIDDEN (__init_array_start = .);

    KEEP (*(SORT(.init_array.*)))

    KEEP (*(.init_array*))

    PROVIDE_HIDDEN (__init_array_end = .);

  } >FLASH

  .fini_array :

  {

    PROVIDE_HIDDEN (__fini_array_start = .);

    KEEP (*(.fini_array*))

    KEEP (*(SORT(.fini_array.*)))

    PROVIDE_HIDDEN (__fini_array_end = .);

  } >FLASH


  /* used by the startup as memory location to initialize data */

  /* from this point the content of flash is copied to ram */

  _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 */

    *(.data)           /* .data sections */

    *(.data*)          /* .data* sections */


    . = ALIGN(4);

    _edata = .;       /* define a global symbol at data end */

  } >RAM


  _SRAM_data = _sidata + _edata - _sdata;


  /* Second part of inicialized section goes into SRAM conected thru FSMC */

  /* FSMC_SRAM section, code must be located here explicitly            */

  /* unsigned long int __attribute__ ((section (".sram_data"))) my_initialized_number = 0xAABBCCDD; */

  .fsmc_sram_data : AT ( _SRAM_data )

  {

  . = ALIGN(4);

    _iSRAM_data = .;        

    *(.sram_data)      

    *(.sram_data*)

    

    . = ALIGN(4);

    _iSRAM_data_end = .;   

  } >FSMC_SRAM

  

  .fsmc_sram_bss : AT ( _iSRAM_data_end )

  {

    _iSRAM_null_data = .;       

    *(.sram_bss)

    *(.sram_bss*)

    

    . = ALIGN(4);

    _iSRAM_null_data_end = .;

  } >FSMC_SRAM

  

  .fsmc_sram_perma : AT ( _iSRAM_null_data_end )

  {

    _iSRAM_perma_data = .;       

    *(.sram_perma)

    *(.sram_perma*)

    

    . = ALIGN(4);

    _iSRAM_perma_data_end = .;

  } >FSMC_SRAM

  

   /* Uninitialized data section */

  . = ALIGN(4);

  

  .bss : AT ( _edata )

  {

    /* 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;

  } >RAM

  

  /* Those numbers are used for SRAM init */

  PROVIDE ( _linker_sram_start = _iSRAM_data );

  PROVIDE ( _linker_sram_data_end = _iSRAM_data_end );

  PROVIDE ( _linker_sram_end = _iSRAM_null_data_end );

  PROVIDE ( _linker_sram_inits = _SRAM_data );

  

  /* Those numbers are used for malloc and sbrk functions */

  PROVIDE ( _linker_memory_start = _sdata );

  PROVIDE ( _linker_heap_start = _ebss );

  PROVIDE ( _linker_heap_end = (_estack - _Min_Stack_Size) );

  PROVIDE ( _linker_memory_end = _estack );

  PROVIDE ( _end = _ebss );


   /* User_heap_stack section, used to check that there is enough RAM left */

  ._user_heap_stack : AT ( _linker_heap_end )

  {

    . = ALIGN(4);

    . = . + _Min_Heap_Size;

    . = . + _Min_Stack_Size;

    . = ALIGN(4);

  } >RAM


 /* FLASH memory area for factory default values                          */

  /* Example of usage: extern int foo(void) __attribute__ ((section (".fvtext"))); */

  /* unsigned long int my_factory_number_changed_in_production = 0xAABBCCDD __attribute__ ((section (".fvrodata"))); */ 

  .factory_values :

  {

    . = ALIGN(4);

    *(.fvtext)        /* .fvtext sections (code) */

    *(.fvtext*)       /* .fvtext* sections (code)  */

    *(.fvrodata)      /* read-only data (constants) */

    *(.fvrodata*)

    . = ALIGN(4);

  } >FACTORY_VAR


  /* Remove information from the standard libraries */

  /DISCARD/ :

  {

    libc.a ( * )

    libm.a ( * )

    libgcc.a ( * )

  }

}





'devel > man & example' 카테고리의 다른 글

man page 비슷한거  (0) 2016.11.30
gcc inline assembly  (0) 2016.08.11
arm stm32f4xx software interrupt handler 만들기  (0) 2016.08.09
arm assembly byte swap 예제 분석  (0) 2016.04.13
dev file  (0) 2015.08.04
Posted by 쵸코케키

블로그 이미지
chocokeki
쵸코케키

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.4
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

최근에 올라온 글

최근에 달린 댓글

글 보관함