GNU链接程序脚本-将闪存移至新区域

问题描述 投票:0回答:2

我正在尝试使用STM32F446ZE微控制器的链接描述文件来移动存储器的各个部分。我的原始设置包括以下内容:

MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K
FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 512K - 128k
DATA (rwx)      : ORIGIN = 0x08060000, LENGTH = 5120
}

SECTIONS
{
  .user_data :
  {
    . = ALIGN(4);
    KEEP(*(.user_data))
    . = ALIGN(4);
  } >DATA
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH

  .text :
  {
    . = ALIGN(4);
    *(.text)           /* .text sections (code) */
    *(.text*)          /* .text* sections (code) */
    *(.glue_7)         /* glue arm to thumb code */
    *(.glue_7t)        /* glue thumb to arm code */
    *(.eh_frame)
    KEEP (*(.init))
    KEEP (*(.fini))
    . = ALIGN(4);
    _etext = .;        /* define a global symbols at end of code */
  } >FLASH

  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >FLASH

  .data : 
  {
    . = 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 AT> FLASH

  . = 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;
  } >RAM

  /* User_heap_stack section, used to check that there is enough RAM left */
  ._user_heap_stack :
  {
    . = ALIGN(4);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    . = . + _Min_Stack_Size;
    . = ALIGN(4);
  } >RAM

我想做的是将数据移至0x08000000(当前正在启动闪存),然后将FLASH移至0x08040000(在DATA之后)。我可以很容易地在内存部分更改它,但是我的程序无法启动。我相信可能需要更改SECTIONS块中的某些代码,但是我不确定该如何做。问题是:如何将闪存(程序代码所在的位置)移动到更高的内存地址。

memory linker stm32 gnu linker-scripts
2个回答
1
投票

这是不可能的,因为从闪存启动时,您的STM32 uC从地址0x8000000开始。

问题是:如何将闪存(程序代码所在的位置)移动到更高的内存地址。

答案:不可能。从闪存启动时,向量表必须从0x8000000开始]


0
投票

正如P__J__所述,您不能将整个数据区域移到地址0x0800 0000,因为MCU希望中断向量从此处开始。从闪存启动MCU时,地址0x0800 0000映射到地址0x0000 0000。您可以做的是为矢量表的长度创建另一个区域,并根据需要移动部分的其他部分。

© www.soinside.com 2019 - 2024. All rights reserved.