如何调整STM32F4链接描述文件以实现闪存的分区预留?

2019-07-14 18:08发布


我需要为STM32F405VGT6上的虚拟EEPROM仿真保留FLASH:
我需要的页面位于闪存的扇区2和扇区3中,因此不在闪存区域的末尾。所以我需要这样的东西:MEMORY{RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128KCCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 64KFLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 32kEMULATED_EEPROM (rwx) : ORIGIN = 0x8008000 LENGTH=2*16kFLASH (rx)      : ORIGIN = 0x8008000+2*16k, LENGTH = 1024k-(32k+2*16k)}但是这个。不起作用。如何调整链接描述文件以实现闪存的分区预留?
  1. <p> File        : stm32_flash.ld
  2. **
  3. **  Abstract    : Linker script for STM32F405VG Device with
  4. **                1024KByte FLASH, 128KByte RAM
  5. **
  6. </p><p>**                Set heap size, stack size and stack location according
  7. **                to application requirements.
  8. **
  9. **                Set memory bank area and size if external memory is used.
  10. **
  11. **  Target      : STMicroelectronics STM32
  12. **
  13. **  Environment : Atollic TrueSTUDIO(R)
  14. **
  15. **  Distribution: The file is distributed as is, without any warranty
  16. **                of any kind.
  17. **
  18. **  (c)Copyright Atollic AB.
  19. **  You may use this file as-is or modify it according to the needs of your
  20. **  project. This file may only be built (assembled or compiled and linked)
  21. **  using the Atollic TrueSTUDIO(R) product. The use of this file together
  22. **  with other tools than Atollic TrueSTUDIO(R) is not permitted.
  23. **
  24. *****************************************************************************
  25. */

  26. /* Entry Point */
  27. ENTRY(Reset_Handler)

  28. /* Highest address of the user mode stack */
  29. _estack = 0x20020000;    /* end of RAM */
  30. /* Generate a link error if heap and stack don't fit into RAM */
  31. _Min_Heap_Size = 0x200;      /* required amount of heap  */
  32. _Min_Stack_Size = 0x400; /* required amount of stack */

  33. /* Specify the memory areas */
  34. MEMORY
  35. {
  36. RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K
  37. CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 64K
  38. FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 1024K
  39. }

  40. /* Define output sections */
  41. SECTIONS
  42. {
  43.   /* The startup code goes first into FLASH */
  44.   .isr_vector :
  45.   {
  46.     . = ALIGN(4);
  47.     KEEP(*(.isr_vector)) /* Startup code */
  48.     . = ALIGN(4);
  49.   } >FLASH

  50.   /* The program code and other data goes into FLASH */
  51.   .text :
  52.   {
  53.     . = ALIGN(4);
  54.     *(.text)           /* .text sections (code) */
  55.     *(.text*)          /* .text* sections (code) */
  56.     *(.glue_7)         /* glue ARM to thumb code */
  57.     *(.glue_7t)        /* glue thumb to arm code */
  58.     *(.eh_frame)

  59.     KEEP (*(.init))
  60.     KEEP (*(.fini))

  61.     . = ALIGN(4);
  62.     _etext = .;        /* define a global symbols at end of code */
  63.   } >FLASH

  64.   /* Constant data goes into FLASH */
  65.   .rodata :
  66.   {
  67.     . = ALIGN(4);
  68.     *(.rodata)         /* .rodata sections (constants, strings, etc.) */
  69.     *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
  70.     . = ALIGN(4);
  71.   } >FLASH

  72.   .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
  73.   .ARM : {
  74.     __exidx_start = .;
  75.     *(.ARM.exidx*)
  76.     __exidx_end = .;
  77.   } >FLASH

  78.   .preinit_array     :
  79.   {
  80.     PROVIDE_HIDDEN (__preinit_array_start = .);
  81.     KEEP (*(.preinit_array*))
  82.     PROVIDE_HIDDEN (__preinit_array_end = .);
  83.   } >FLASH
  84.   .init_array :
  85.   {
  86.     PROVIDE_HIDDEN (__init_array_start = .);
  87.     KEEP (*(SORT(.init_array.*)))
  88.     KEEP (*(.init_array*))
  89.     PROVIDE_HIDDEN (__init_array_end = .);
  90.   } >FLASH
  91.   .fini_array :
  92.   {
  93.     PROVIDE_HIDDEN (__fini_array_start = .);
  94.     KEEP (*(SORT(.fini_array.*)))
  95.     KEEP (*(.fini_array*))
  96.     PROVIDE_HIDDEN (__fini_array_end = .);
  97.   } >FLASH

  98.   /* used by the startup to initialize data */
  99.   _sidata = LOADADDR(.data);

  100.   /* Initialized data sections goes into RAM, load LMA copy after code */
  101.   .data :
  102.   {
  103.     . = ALIGN(4);
  104.     _sdata = .;        /* create a global symbol at data start */
  105.     *(.data)           /* .data sections */
  106.     *(.data*)          /* .data* sections */

  107.     . = ALIGN(4);
  108.     _edata = .;        /* define a global symbol at data end */
  109.   } >RAM AT> FLASH

  110.   _siccmram = LOADADDR(.ccmram);

  111.   /* CCM-RAM section
  112.   *
  113.   * IMPORTANT NOTE!
  114.   * If initialized variables will be placed in this section,
  115.   * the startup code needs to be modified to copy the init-values.  
  116.   */
  117.   .ccmram :
  118.   {
  119.     . = ALIGN(4);
  120.     _sccmram = .;       /* create a global symbol at ccmram start */
  121.     *(.ccmram)
  122.     *(.ccmram*)

  123.     . = ALIGN(4);
  124.     _eccmram = .;       /* create a global symbol at ccmram end */
  125.   } >CCMRAM AT> FLASH


  126.   /* Uninitialized data section */
  127.   . = ALIGN(4);
  128.   .bss :
  129.   {
  130.     /* This is used by the startup in order to initialize the .bss secion */
  131.     _sbss = .;         /* define a global symbol at bss start */
  132.     __bss_start__ = _sbss;
  133.     *(.bss)
  134.     *(.bss*)
  135.     *(COMMON)

  136.     . = ALIGN(4);
  137.     _ebss = .;         /* define a global symbol at bss end */
  138.     __bss_end__ = _ebss;
  139.   } >RAM

  140.   /* User_heap_stack section, used to check that there is enough RAM left */
  141.   ._user_heap_stack :
  142.   {
  143.     . = ALIGN(4);
  144.     PROVIDE ( end = . );
  145.     PROVIDE ( _end = . );
  146.     . = . + _Min_Heap_Size;
  147.     . = . + _Min_Stack_Size;
  148.     . = ALIGN(4);
  149.   } >RAM



  150.   /* Remove information from the standard libraries */
  151.   /DISCARD/ :
  152.   {
  153.     libc.a ( * )
  154.     libm.a ( * )
  155.     libgcc.a ( * )
  156.   }

  157.   .ARM.attributes 0 : { *(.ARM.attributes) }
  158. }</p>
复制代码


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
1条回答
胡扯123
2019-07-14 22:30
你可以尝试(从未测试过自己)

MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 64K
FLASH_1 (rx)      : ORIGIN = 0x8000000, LENGTH = 32k
EMULATED_EEPROM (rwx) : ORIGIN = 0x8008000 LENGTH=2*16k
FLASH (rx)      : ORIGIN = 0x8008000+2*16k, LENGTH = 1024k-(32k+2*16k)
}

  .text2 :  
  {  
    ...  
  } >> FLASH_1

  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH_1
但是要在text2部分中放置任何内容(例如某些函数),您必须使用它们进行声明  __attribute__ ((section ("text2")))

一周热门 更多>