Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 453 of 9366. Embedded Software Construction and ToolchainsFree lesson

Identifying the Reset Vector and Boot Sequence

Locate the processor's entry point in the vector table to understand how the CPU begins execution immediately after power-on or reset.

In this lesson, you will learn how the processor hardware maps its first execution instructions to a specific memory location, known as the Reset Vector, to initiate the system boot sequence.

The Architecture's Starting Line

When you power on an embedded system, the CPU’s Program Counter (PC) does not just point to a random address. Instead, the hardware is hardwired to look at a fixed memory location—the Reset Vector—immediately upon reset. This location holds the address of the first instruction the processor will execute.

In many architectures, such as ARM Cortex-M, this isn't just a single address; it is the first entry in the Vector Table. The Vector Table is an array of memory addresses that the processor consults to jump to specific routines. The very first entry (at offset 0x00000000) is the initial value for the Main Stack Pointer, and the second entry (at offset 0x00000004) is the Reset Handler address.

The Boot Sequence in Practice

The boot sequence follows a predictable path:

  1. Power-on/Reset: The CPU samples the hardware state and points the PC to the Reset Vector.
  2. Fetch: The CPU reads the 32-bit address stored at that vector location.
  3. Branch: The CPU jumps to that address, which marks the start of your startup code (typically an assembly file like startup.s).
  4. Initialization: Your startup code initializes the hardware, copies initialized data from Flash to RAM (using the Load/Virtual Address concepts you learned previously), and clears the BSS section.
  5. Main: Once the environment is ready, the startup code branches to your main() function.

If you inspect a linker map file, you will often see the startup object file placed at the very beginning of your code section to ensure it aligns with the expected Reset Vector:

/* Simplified Vector Table Example */
.section .isr_vector, "a"
.word _stack_top         /* Initial Stack Pointer */
.word Reset_Handler      /* Reset Vector: Address of startup code */
.word NMI_Handler        /* Non-maskable interrupt */

Understanding this sequence is vital because if your linker script places your Reset_Handler in the wrong memory region, the CPU will fetch an invalid instruction, resulting in an immediate system hang or "hard fault" before your code ever runs.

Key Takeaway: The Reset Vector is the hardwired memory address the CPU fetches immediately after a reset, serving as the critical bridge between hardware power-up and the execution of your C/C++ software.