Skip to main content
CLiao.1
Associate
April 9, 2020
Question

How to move interrupt vector from FLASH to RAM when using STM32F427?

  • April 9, 2020
  • 5 replies
  • 4445 views

Hi, I developed boot loader on STM32F427. When I try to erase FLASH, that will trigger HW watch dog(tick by interrupt timer) to reset our develop board. I search solution by google, many people say should move interrupt vector and IRQ handler program from FLASH to RAM. Do there have document describe how to implement it? I already followed "Use STM32F3/STM32G4 CCM SRAM with IAR™ EWARM, Keil® MDK-ARM and GNU-based toolchains"(AN4296), but it don't work.

BR,

Cloud

This topic has been closed for replies.

5 replies

berendi
Principal
April 9, 2020

Check the following

  • The function erasing the flash itself is relocated to RAM
  • All enabled interrupt handlers are relocated to flash
  • No relocated function calls anything in flash.
  • They don't use any const variables, or otherwise reference flash contents.

Check every possible program line, function call, macro, variable.

CLiao.1
CLiao.1Author
Associate
April 9, 2020

Hi Berendi,

boot loader flash region: 0x08000000 ~ 0x0803FFFF

AP flash region: 0x08040000~0x0807FFFF

Boot loader only erase/write AP FLASH address. When boot loader erase AP section, there will stop around 3 seconds .

Tesla DeLorean
Guru
April 9, 2020

Use memcpy(), make sure the RAM address is 512-byte aligned, and set the SCB->VTOR to the new base address.

Watch that addresses in the vector table don't point to erased areas of Flash or will call tree dependencies on same.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
CLiao.1
CLiao.1Author
Associate
April 9, 2020

Hi Clive1,

Do you mean copy IVT from FLASH to RAM at main function and set SCB->VTOR to IVT address in RAM?

BR,

Cloud

CLiao.1
CLiao.1Author
Associate
April 10, 2020

After adding below code in system_stm32f4xx.c, the IVT put in RAM.

memcpy((void*)0x20000000,(void const*)0x08000000,0x1FF); // Move Vector Table from FLASH to RAM

SCB->VTOR = 0x20000000; // Point at RAM copy