[STM32F4] CubeIDE 如何设置程序偏移?

[复制链接]
156|0
yunfu1117 发表于 2025-10-7 12:05 | 显示全部楼层 |阅读模式
RAM, ST, se, AB, EIDE, or
我正在为 stm32f4-discovery 板制作 DFU。

我的 DFU 使用的是由 STM32CubeMX 生成的项目。

但当我使用由 STM32CubeIDE 生成的项目时,主程序无法运行。

我采取了以下步骤:

首先,在 system_stm32f4xx.c 中
#define USER_VECT_TAB_ADDRESS

#if defined(USER_VECT_TAB_ADDRESS)
/*!< Uncomment the following line if you need to relocate your vector Table
     in Sram else user remap will be done in Flash. */
/* #define VECT_TAB_SRAM */
#if defined(VECT_TAB_SRAM)
#define VECT_TAB_BASE_ADDRESS   SRAM_BASE       /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x00000000U     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#else
#define VECT_TAB_BASE_ADDRESS   FLASH_BASE      /*!< Vector Table base address field.
                                                     This value must be a multiple of 0x200. */
#define VECT_TAB_OFFSET         0x8000     /*!< Vector Table base offset field.
                                                     This value must be a multiple of 0x200. */
#endif /* VECT_TAB_SRAM */
#endif /* USER_VECT_TAB_ADDRESS */

在STM32F407VGTX_FLASH.ld中
/* Memories definition */
MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  FLASH    (rx)    : ORIGIN = 0x8008000,   LENGTH = 992K

}


在STM32F407VGTX_RAM.ld中
/* Memories definition */
MEMORY
{
  CCMRAM    (xrw)    : ORIGIN = 0x10000000,   LENGTH = 64K
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 128K
  FLASH    (rx)    : ORIGIN = 0x8008000,   LENGTH = 992K

}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

60

主题

62

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部