STM32F411RE-0010-结合map文件分析连接脚本

  • 下面是定义好对于STM32F411RE这个芯片的flash和ram的地址和大小设定。

/* Specify the memory areas */
MEMORY
{
FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 512K
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K
}

  • 下面可以看到有将.isr_vector放在了flash的一开始。

/* The startup code goes first into FLASH */
  .isr_vector :
  {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
  } >FLASH
下面是编译的map文件中看到.isr_vector确实放在了0x08000000这个位置,并且大小是0x198.

 .isr_vector    0x0000000008000000      0x198 Example/SW4STM32/startup_stm32f411xe.o
                0x0000000008000000                g_pfnVectors
                0x0000000008000198                . = ALIGN (0x4)

从汇编文件startup_stm32f411xe.s中确实可以看到这块大小,数一数,就是0x198.

  • 下面是将代码段向后放置。

  /* The program code and other data goes into 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

  • 接着是放置只读数据变量

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

这里可以结合map文件看到如下

 .rodata        0x0000000008000e84       0x18 Drivers/CMSIS/system_stm32f4xx.o
                0x0000000008000e84                AHBPrescTable
                0x0000000008000e94                APBPrescTable
 *(.rodata*)
                0x0000000008000e9c                . = ALIGN (0x4)

通过查找system_stem32f4xx.c文件,知道const定义的变量是符合的。

  • 初始化好的变量接着放置,数据也是在ram中的开始放置,即0x20000000开始处放置。

  /* Initialized data sections goes into RAM, load LMA copy after code */
  .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

从map文件距离如下:

 .data          0x0000000020000000        0x4 Drivers/CMSIS/system_stm32f4xx.o
                0x0000000020000000                SystemCoreClock

这里就是赋值的变量。

  • 接着放置的未初始化的变量

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

  • heap和堆的size配置

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

如下是对应到了MAP文件

                0x0000000020000240                . = (. + _Min_Heap_Size)
 *fill*         0x0000000020000040      0x200 
                0x0000000020000640                . = (. + _Min_Stack_Size)
 *fill*         0x0000000020000240      0x400 
                0x0000000020000640                . = ALIGN (0x4)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值