arm-none-eabi-gcc 9.2.1,STM32F429:如何在Flash中以0x4000对齐方式放置一节?

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

我正在为STM32F429创建引导加载程序。引导加载程序的最大大小为256K,这在闪存中为384K大小的两个应用程序“页面”留出了空间。为了确定哪个页面是“活动的”并启动,我想保留前四个16K闪存扇区中的第二个用于用户数据。我将ST的linker script修改为如下形式:

/* Specify the memory areas */
MEMORY
{
    FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 256K /* max. bootloader binary size */
    CCMRAM (rw)     : ORIGIN = 0x10000000, LENGTH = 64K
    RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 191K /* deduct 1K for NOINIT data */
    NOINIT (rwx)    : ORIGIN = 0x2002FC00, LENGTH = 1K /* NOINIT data will survive reset */
}

/* Define output sections */
SECTIONS
{
    /* The startup code goes first into FLASH */
    .isr_vector :
    {
    . = ALIGN(4);
    KEEP(*(.isr_vector)) /* Startup code */
    . = ALIGN(4);
    } >FLASH

    /* Then comes user flash sector, make sure to get one of the first 4 that are 16K in size
    .user_flash :
    {
      . = ALIGN(0x4000)
      KEEP(*(.user_flash))
      . = ALIGN(0x4000)
    } >FLASH

    /* ... more sections below not shown here */
}

在我的bootloader.cpp中,我声明用户闪存如下:

__attribute__((__section__(".user_flash"))) const uint32_t user_flash[0x4000 / sizeof(uint32_t)] = {0};

但是,在调试器中,user_flash的地址不是预期的0x08004000,而是0x0801b4e8

从声明中删除__attribute__((__section__(".user_flash")))会产生不同的地址,证明该属性至少具有some效果。

。elf文件上的arm-non-eabi-objdump -h运行确认user_flash节的(不正确)地址。我也尝试用. = 0x08004000声明该部分,但无效。

[我尝试的另一种方法是将.isr_vector放在其自己的16K部分中,然后是用于用户闪存的16K部分,最后是(256-16-16)= 224K FLASH部分。这产生了伪造的二进制文件,该二进制文件将进行硬故障。

我在这里做错了什么?

编辑:

我已经tried.padding之后插入.isr_vector部分以尝试以这种方式对齐.user_flash,但是无论我做什么,.text.rodata部分似乎总是在[ C0],即使它们在.padding部分之后声明。

arm embedded bootloader stm32f4 linker-scripts
1个回答
0
投票
.user_flash
© www.soinside.com 2019 - 2024. All rights reserved.