Boot Sequence Of ARM Based MCU

 

Table of Contents

  1. Introduction
  2. POR
  3. Memory Aliasing
  4. Firmware Booting
  5. Reset Handler

Introduction

Boot Sequence is a process that brings life into a Microcontroller unit (MCU), It also plays a vital role in bringing the software and hardware up and running.

The boot process can have different firmware stages and hardware configurations depending on the hardware and firmware architecture. As the hardware configurations are limited, we can define a standard template to get the depth of the boot process.

• The boot sequence can be divided into four parts:

    1. Power on Reset (Hardware Process)
    2. Memory Aliasing (Remapping) and Architecture (Hardware Process)
    3. Firmware Booting (Hardware and Firmware Process)
    4. Reset_Handler() execution, for bringing up firmware (Firmware Process)

1. POR

The Boot Process begins with the Power On Reset (POR). When an MCU is first powered up, it has to run predefined checks in the hardware to bring the MCU up, only when all the voltage and clock conditions are proper for operation. Until then this hardware circuitry holds the processor in the reset. This process is called the Power On Reset (POR).

CPU

2. Memory Aliasing (Remapping) and Architecture

After the POR Stage MCU comes out of the reset state. The processor starts pointing from the 0x0000_0000 address. This zero address can also be remapped to any other address in the address space with the help of Remapper hardware. With the remapping hardware, The processor still looks for 0x0000_0000 but now the Remapper hardware window changes the address to a new remap address. This results in booting/execution from different address spaces or different applications. This is also called Memory Aliasing.

Memory Aliasing

Target application or the firmware needs the address-specific settings in the linker file configuration e.g. FLASH start address. Flash address configuration of the linker binds the functions (of an application) binary with the linker file configured address. Each function in a C Language has an address and when the function is called/executed the Program Count jumps to that specific address to execute the function. So it is required for compiled application code (.obj) to be linked with a specific target address, or memory aliased (Remapped) address.
This boot setting for Remapper hardware is typically configured from the Boot Mode selection pin of the MCU. Processor internal circuitry reads this boot mode pin configuration to set the Remapper address as per the selected configuration. Only after this stage processor starts fetching instructions and data from the correct targeted memory address.

3. Firmware Booting

After the Memory Alias stage, where the processor takes the boot mode selection pin configuration and is ready to fetch the instruction from the target address, firmware booting starts.

Firmware boot starts with the fetch of a WORD (32 Bit Memory Addr) to the Program counter (PC). The program counter (PC) is loaded with the address 0x0000_0000 value. As PC points to the next address for the execution, the 0x0000_0000 address is loaded to the Main Stack Pointer (MSP). This is done in the hardware circuitry. PC after 0x0000_0000 points to the next instruction which is 0x0000_0004. The memory map of the ARM based MCU has 0x0000_0000 as the address to the top of the stack and 0x0000_0004 as the Reset Handler. This initial memory map, is part of the Memory segment that is called Vector Table.
Also in the ARM based MCU, the Initial top of the stack is loaded before the first function (Reset Handler) of the application, allowing the Reset Handler to be written completely in C. As C code needs stack to run.

Firmware Booting

4. Reset Handler

Reset Handler in ARM based MCU is considered as an entry point of the firmware. This value of the reset handler in the vector table is basically a pointer to the actual function.

  •  Reset Handler Does Below Things :
    •  Initializes the stacks and CPU Registers
    •  Copies the Memory Data segments from the FLASH to the RAM and fills the BSS Segment variables with 0's
    •  Initializes the Peripherals with the default states
    •  Initializes the MMU (If Available)
    •  Jump to the main function