cancel
Showing results for 
Search instead for 
Did you mean: 

Getting HAL_Delay() working in external loader

sk-st
Associate III

Hello,

 

i created a custom external loader for a STM32F429 board.

The problem is now, my code needs HAL_Delay() for generating short delays between flash device accesses. And the code freezes when executing HAL_Delay().

 

So i have read that interrupts are no longer allowed at newer versions of CubeMXProgrammer.

But HAL_Delay() seems to need a working SysTick interrupt.

I used this tutorial for my custom EL:

https://community.st.com/t5/stm32-mcus/how-to-add-your-spi-flash-into-the-stm32cubeprogrammer-s/ta-p/49392

 

Is

SCB->VTOR = 0x20000000 | 0x200;

the right value for my F429?

 

Further i tried uncommenting

#define USER_VECT_TAB_ADDRESS

and

#define VECT_TAB_SRAM

 

But still no success. Does someone know what else has to be fixed?

 

Thank you.

2 REPLIES 2
AScha.3
Super User

Hi,

> Is  SCB->VTOR = 0x20000000 | 0x200;   the right value for my F429?

 

1. Relocating the Vector Table to SRAM on STM32F429

Setting SCB->VTOR = 0x20000000 | 0x200; places the vector table at address 0x20000200 in SRAM. This is a valid operation for the STM32F429, provided the vector table is actually located at that address in RAM. The VTOR register's TBLOFF field (bits 29:9) contains the offset of the table base from memory address 0x00000000, and the minimum alignment is 128 words (512 bytes), so bits [8:0] of the address must be zero. The value 0x20000200 is aligned to 512 bytes, satisfying this requirement.


2. Alignment and Address Range Requirements

When relocating the vector table to SRAM, the address assigned to SCB->VTOR must:

  • Be in the SRAM region (typically starting at 0x20000000)
  • Be aligned to at least 128 words (512 bytes), meaning bits [8:0] must be zero
  • Bit 29 of VTOR determines the memory region: 0 for code, 1 for SRAM

3. Consequences of Incorrect Alignment

If SCB->VTOR is not aligned to 128 words (512 bytes), the operation will fail, and subsequent program operations may also fail, especially when using the bootloader interface or secure firmware update features. For STM32F4 Series, including STM32F429, the vector table must be aligned on 512 bytes for secure boot and firmware update purposes.


Summary

Yes, SCB->VTOR = 0x20000000 | 0x200; is a correct value for relocating the vector table to SRAM at address 0x20000200 on STM32F429, provided your vector table is actually placed at that address and the alignment requirement (512 bytes) is met.

 

If you feel a post has answered your question, please click "Accept as Solution".
sk-st
Associate III

Thank you for your quick response.

My linker map file reveals:

 

.isr_vector 0x0000000020000004 0x1fc
0x0000000020000200 . = (. + 0x1fc)
*fill* 0x0000000020000004 0x1fc
0x0000000020000200 . = ALIGN (0x4)
*(.isr_vector)
0x0000000020000200 . = ALIGN (0x4)

.ARM.extab
*(.ARM.extab* .gnu.linkonce.armextab.*)

.ARM 0x0000000020000200 0x8
0x0000000020000200 __exidx_start = .
*(.ARM.exidx*)
.ARM.exidx 0x0000000020000200 0x8 /usr/lib/gcc/arm-none-eabi/8.3.1/thumb/v7e-m+fp/hard/libgcc.a(_udivmoddi4.o)
0x0000000020000208 __exidx_end = .

.preinit_array 0x0000000020000208 0x0
0x0000000020000208 PROVIDE (__preinit_array_start = .)
*(.preinit_array*)
0x0000000020000208 PROVIDE (__preinit_array_end = .)

.init_array 0x0000000020000208 0x4
0x0000000020000208 PROVIDE (__init_array_start = .)
*(SORT_BY_NAME(.init_array.*))
*(.init_array*)
.init_array 0x0000000020000208 0x4 /usr/lib/gcc/arm-none-eabi/8.3.1/thumb/v7e-m+fp/hard/crtbegin.o
0x000000002000020c PROVIDE (__init_array_end = .)

 

So is my vector table at the right address for my VTOR value?