Home | Projects | Notes > Bootloader > Reset Sequence
When you reset the processor (e.g., press the reset button on the boad), the PC is loaded with the value 0x0000_0000. (Memory location 0x0000_0000 belongs to a Flash memory, or ROM memory, or Program memory.)
Then the processor reads the value at the memory location 0x0000_0000 into the MSP.
MSP = value at 0x0000_0000
MSP is the Main Stack Pointer register. This means that the processor, upon reset, first initializes the Stack Pointer.
Then the processor reads the value at the memory location 0x000_0004 into PC. That value is actually the address of the reset handler. (In other words, the address of the reset handler gets stored into PC.)
PC jumps to the reset handler.
A reset handler is just a C or assembly function written by you to carry out any initialization required.
From the reset handler, main() function of the application gets called.
This is how the control reaches your program's main() function after reset.
All ARM Cortex-M based MCUs, upon reset, does
Load the value stored at 0x0000_0000 into MSP
Load the value stored at 0x000_0004 into PC (Value: the address of the reset handler)
In STM32 microcontroller,
MSP value is stored at 0x0800_0000
Vector table starts from 0x0800_0004
Address of the reset handler found at 0x0800_0004
So, there must be something that links 0x0800_0000 to 0x0000_0000?
[Answer] Both addresses can be linked with the technique called "memory aliasing" and it depends on the MCU.
The base address of the user Flash (i.e., 0x0800_0000; depends on the MCU) is mapped to 0x0000_0000 via memory aliasing. So, when the processor references the memory location 0x0000_0000, the address is converted into 0x0800_0000 and the processor ends up reading 0x0800_0000.
This can be verified by comparing the contents of the both of the memory regions using the memory browser on your IDE. They will show the same contents.

Reset handler does the early initialization after which the call to the user program (main()) is made:
Processor reset
__libc_init_array();)
main())
Remember! The main() function cannot be called without these important early initializations.
xxxxxxxxxx431/* a section of startup file (startup_stm32f407vgtx.s) */2
3Reset_Handler:4 ldr r0, =_estack5 mov sp, r0 /* set stack pointer */6/* Call the clock system initialization function.*/7 bl SystemInit8
9/* Copy the data segment initializers from flash to SRAM */10 ldr r0, =_sdata11 ldr r1, =_edata12 ldr r2, =_sidata13 movs r3, #014 b LoopCopyDataInit15
16CopyDataInit:17 ldr r4, [r2, r3]18 str r4, [r0, r3]19 adds r3, r3, #420
21LoopCopyDataInit:22 adds r4, r0, r323 cmp r4, r124 bcc CopyDataInit25
26/* Zero fill the bss segment. */27 ldr r2, =_sbss28 ldr r4, =_ebss29 movs r3, #030 b LoopFillZerobss31
32FillZerobss:33 str r3, [r2]34 adds r2, r2, #435
36LoopFillZerobss:37 cmp r2, r438 bcc FillZerobss39
40/* Call static constructors */41 bl __libc_init_array42/* Call the application's entry point.*/43 bl main