MCU boot-up sequence question
So I’ve been reading up on how to make my own bootloader, because I want to understand how they work on the low level and apply that understanding for my own one. I don’t want to use the ST’s own bootloader in the system memory (addr. 0x1FFF 0000 - 0x1FFF 7A0F). I’m using my own little bare metal board with a STM32F415RGT (Pic below). I’m using the STM32 AC6 workbench IDE.
At the moment I’m using a very light debug test build, which enables GPIO clocks and then configures the LED GPIOs as outputs and in the while loop toggles their state according to the pushbutton state on the board (SW not-actuated -> LEDS on, SW actuated -> LEDS off). The startup file “startup_stm32f415xx.s” (is this file defined somewhere in the project settings, because I couldn’t find it’s declaration?) inits the RAM and configures the basic clock with the “systemInit” from “system_stm32f4xx.c”.
So far I have never needed to change the default linker scripts, because I haven’t used a bootloader before or have needed to change where the application was written in FLASH, so I had never actually touched the linker script even.But I have figured that out now through my own experimenting and googling how to change where the application is being written in FLASH.
following snippet from the “STM32F415RGTx_FLASH.ld” linker script.
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20020000; /* end of RAM */
/* Generate a link error if heap and stack don’t fit into RAM */
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x200; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 992K //been experimenting with changing this address and length and confirmed through debug that the application has moved according to it.
}
Now the part I’m really interested is the “ENTRY(Reset_Handler)”, because it seems to define the address where the MCU will jump to when it resets. Where is it located in the memory? And also, does it jump to the “reset vector” on the vector table and from there to the “reset_handler” or directly to the actual “reset_handler” address?
This question rose after debugging and having flashed the same app to FLASH at addresses 0x0800 0000, 0x0800 4000 and 0x0800 8000 (debugging doesn’t erase FLASH, so it left the old apps in place. I then later chip erased the FLASH with ST-LINK UTILITY to clean it up) and wondered where the jump vector is defined so it knows which apps reset_handler address to jump to.