简体   繁体   English

如何让STM32F429NI中的bootloader跳转到外部Nor Flash

[英]How to make the bootloader in STM32F429NI to jump to external Nor Flash

I am working on STM32F429NI Evaluation board, I have a code to blink the led.我正在研究 STM32F429NI 评估板,我有一个使 LED 闪烁的代码。 I want the blink led code to be present in external nor flash and the bootloader residing the internal flash has to transfer control to the external nor flash of STM32F429NI.我希望闪烁 LED 代码出现在外部或闪存中,并且驻留在内部闪存中的引导加载程序必须将控制权转移到 STM32F429NI 的外部或闪存中。

Reference manual of STM32F429NI evaluation board: https://www.st.com/en/microcontrollers-microprocessors/stm32f429ni.html#documentation STM32F429NI评估板参考手册: https ://www.st.com/en/microcontrollers-microprocessors/stm32f429ni.html#documentation

Steps I have followed is:我遵循的步骤是:

void jump_to_external_flash(uint32_t address)
{
  uint32_t msp_value = *(__IO uint32_t*)address;
  void (*reset_handler)(void);

  SysTick->CTRL = 0;
  SysTick->LOAD = 0;
  SysTick->VAL = 0;

  HAL_DeInit();

  __set_MSP(msp_value);
  uint32_t rst_handler_addr = *(__IO uint32_t*)(address + 0x4);
  reset_handler = (void*) rst_handler_addr;

  reset_handler();
}

In the code for led blink linked script在 LED 闪烁链接脚本的代码中

MEMORY
{
RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 192K
CCMRAM (xrw)      : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx)      : ORIGIN = 0x60000000, LENGTH = 64MB
}

It is very simple.这很简单。 You need to initialize the Flexible memory controller (FMC) to map the external flash into uC address space.您需要初始化灵活的内存控制器 (FMC) 以将外部闪存映射到 uC 地址空间。 Then simply jump to the code there.然后只需跳转到那里的代码。

FLASH will still be at the normal address. FLASH 仍将位于正常地址。 Add a new memory segment for the external FLASH.为外部 FLASH 添加一个新的内存段。

To program it you will probably need to write your own routine.要对其进行编程,您可能需要编写自己的例程。 Example here: https://github.com/magicmicros/AT25Q641_ExternalLoader这里的例子: https : //github.com/magicmicros/AT25Q641_ExternalLoader

PS do not use HAL functions in the bootloader. PS 不要在引导加载程序中使用 HAL 函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM