We explore the startup of a microcontroller using STM32 as an example. First, we look at the manufacturer's assembly code, then we write it from scratch in C.
00:00 Overview
01:25 Create a basic project in STM32CubeIDE
02:14 Review STM32 startup code (assembly)
08:58 Write startup code from scratch (C)
10:22 Discard libc, startfiles and default linker script
14:27 Startup file
16:05 Linker script
18:22 Debug
18:55 C runtime init (CRT0)
23:56 Link with libc (Newlib)
24:42 __libc_init_array (constructors)
26:49 system_init and _start
27:35 Final thoughts
Code: https://github.com/artfulbytes/how_a_microcontroller_starts_video
🌍 Related links
https://embeddedartistry.com/blog/2019/04/08/a-general-overview-of-what-happens-before-main/
https://interrupt.memfault.com/blog/zero-to-main-1
https://github.com/ataradov/mcu-starter-projects