Thursday 9 November 2017

Boot Sequence for an ARM based embedded system

ARM embedded system, at the time of power on, CPU is uninitialized and a basic clock setup, system specifics' setup is required before proceeding to the bigger and complex tasks.

a hardware bootloader generally called as Boot Rom is provided by vendor (pre-loaded into the processors’ internal ROM).This is hardwired at the manufacturing time. After a power on reset, that causes the processor core to jump to the reset vector, Boot Rom is the first code to execute in the processor.


Responsibilities of Bootrom
  • Bootrom performs the essential initialization including programming the clocks, stacks, interrupt set up etc.
  • Bootrom will detect the boot media using a system register. This is to determine where to find the software bootloader. A particular sequence of probing for boot media is followed as defined by the manufacturer.  If no bootloader is found in any external memory, bootrom listens for a download request on UART/USB port to start the download process.
  • Thus during the probing process, if the flash has already been programmed,  software bootloader will be detected to be available in flash , if not so –it will be downloaded to the flash by bootrom.
  • For platforms using NAND flash , the bootrom will load this boot loader to internal RAM and set the program counter at the load address of the SW bootloader in RAM.
  •  For platforms using NOR flash, control is transferred to the external flash (NOR flash is XiP- Execute in Place).
Software Bootloader 
The main task of S/W bootloader is to load the OS and pass over the execution to it after setting up necessary environment for its setup. For this, the bootloader must first initialize the DDR memory (this includes setting up the controller, refresh rate etc).

 After the system setup, bootloader’s responsibility would be to look for an OS to boot. Again, like Boot Rom, if OS is not already loaded to flash, it will load this from the boot media in flash and execute-in-place in case of NOR flash, or place it in RAM in case of NAND flash. 

After all the necessary system setup, bootloader will pass over the execution to OS


the flow the startup code for an  ARM based embedded system.

 Step 1: The reset
On startup, the processor will jump to fixed location ,(most ARM cores support two vector locations 0x0 or 0xFFFF0000).his address should contain the reset vector and the default vector table. Reset vector is always the first instruction to be executed.
Step 2: The reset code
his reset code to which the jump has been executed from the reset vector will do the following tasks:
->Set up system registers  and memory environment
->Set up MMU
->Setup stack pointers : initialize stack pointers for all ARM modes
->Set up bss section : zeroing the ZI data region,  copying initialization values for initialized variables from ROM to RAM
->Set up hw : CPU clock initialization , external bus interface configuration,low level peripheral initialization etc

Step 3: Remap Memory
At the time of start up, ROM is located at 0×0 address and then during normal execution RAM is re-mapped to this location.Memory remapping can be achieved through hardware remapping, that is changing the address map of the bus. This can also be acheived through MMU.

Step 4: Setting up the external memory, loading and executing the OS image 
External memory should be setup before loading an image to it (Refresh rate, clock etc),OS image can then be loaded from flash(assuming its NAND flash) to RAM.The OS image may be compressed in which case it needs to be decompressed before PC can be modified to point to the operating system entry point address.
  
      

No comments:

Post a Comment