Misalignment of Reset_Handler Address in Vector Table After Moving Flash Bank
I’m encountering an issue with my STM32H755 application after moving the flash memory to accommodate SBSFU. The Reset_Handler address in the vector table is misaligned by one flash bank. Here are the details:
Background:
- Microcontroller: STM32H755
- Bootloader: SBSFU
- Development Environment: STM32CubeIDE1.12
Problem: After moving my application to start at 0x08020400 to make room for SBSFU, the Reset_Handler address in the vector table is incorrect. The address is off by 0x203FF.
Linker Script: Here is the relevant part of my linker script:
MEMORY
{
FLASH (rx) : ORIGIN = 0x08020400, LENGTH = 896K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 128K
// Other memory regions
}
SECTIONS
{
.isr_vector :
{
. = ALIGN(8);
KEEP(*(.isr_vector))
FILL(0);
. = ORIGIN(FLASH) + LENGTH(FLASH) - 1;
BYTE(0)
. = ALIGN(8);
} > FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text*)
*(.glue_7)
*(.glue_7t)
*(.eh_frame)
KEEP(*(.init))
KEEP(*(.fini))
. = ALIGN(4);
_etext = .;
} > FLASH
// Other sections
}Startup Code: Here is the relevant part of my startup assembly file:
.section .isr_vector, "a", %progbits .type g_pfnVectors, %object .size g_pfnVectors, .-g_pfnVectors g_pfnVectors: .word _estack .word Reset_Handler .word NMI_Handler .word HardFault_Handler // Other exception vectors .thumb_func .type Reset_Handler, %function Reset_Handler: // Reset handler code b .
Vector Table Output: Here are the first 10 entries of the vector table:
0x08020400: 0x24020000 0x08020404: 0x080656E5 0x08020408: 0x08064549 0x0802040C: 0x0806454F 0x08020410: 0x08064555 0x08020414: 0x0806455B 0x08020418: 0x08064561 0x0802041C: 0x00000000 0x08020420: 0x00000000 0x08020424: 0x00000000
What I’ve Tried:
- Verified the linker script and startup code.
- Ensured the vector table is correctly placed at 0x08020400.
- Checked the alignment and memory regions.
Question: Why is the Reset_Handler address in the vector table misaligned by one flash bank, and how can I fix this issue?
