cancel
Showing results for 
Search instead for 
Did you mean: 

Hou to move the interruption vector table and make STM32F407VE work 32KB ahead.

Alexandre Meyer
Associate II

I need 32KB of flash memory space to store data. As the smaller memory blocks are in the beginning, it sounded logical to use the first two blocks and move everything else 32KB forward.

To achieve that I first edited the file STM32F407VE_FLASH.ld to change the memory areas.

/* Specify the memory areas */
MEMORY
{
RAM (xrw)   : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw)   : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx)   : ORIGIN = 0x8008000, LENGTH = 480K
DATA (rwx)   : ORIGIN = 0x8000000, LENGTH = 32K
}
 
 .user_data :
 {
  . = ALIGN(4);
    *(.user_data)
  . = ALIGN(4);
 } > DATA  

Then I edited system_stm32f4xx.c file to change the IRQ vector offset

#define VECT_TAB_OFFSET 0x8000 /*!< Vector Table base offset field. 
                                                                          This value must be a multiple of 0x200. */

When I fire the aplication for the first time, it apparently starts at the correct point (at least when I run the debugger), but no interruption request works, not even SysTick.

With the IRQs out, the application does not perform the intended tasks and the IWDG kicks in, but the IWDG reset tries to run the application from 0x08000000.

Is there anything else I should change in order to make it work normally starting on 0x8008000 ?

2 REPLIES 2

You can't achieve that in 'F407, the program always runs from 0x0000'0000 which is the same as 0x0800'0000 when FLASH is mapped to 0x0000'0000, which is, after reset. So you can't use the first block for data.

JW

Be sure not to transfer control to the app code while in a callback or interrupt, the system won't unwind it's internal state properly.

Do not disable interrupts unless you have equivalent code reenabling them.

The SCB->VTOR is frequently set by code in SystemInit()

My preference is to use the symbol for the vector table to set SCB->VTOR, as it removes multiple stupid options for failure.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..