Boot Sequence – On the Ti OMAP4 devices



Boot Sequence – On the Ti OMAP4 devices

1 1


boot-sequence-slides


On Github changyuheng / boot-sequence-slides

Boot Sequence

On the Ti OMAP4 devices

Created by Chang Yu-heng

A Quick View of The Generic Boot Sequence

Power up ROM Boot loader Operating system

Think About It

We need an operating system since it has the full power of machine controlling.

But why should we need “ROM” and “boot loader”?

One Line Answer

It's all about the preparation.

Let's take a look at what they do before the operating system starting up.

ROM

Think this step as a basic hardware initialization.

Which components have been intialized?

The core mudules, such as:

  • CPU (at least one)
  • RAM (maybe only built-in)
  • I/Os (optional)

Satisfy Von Neumann architecture so that we can execute the instructinos (of the boot loader).

Boot Loader

What things have been done with the “boot loader”?

  • CPU
  • RAM
  • I/Os (optional)
  • File system (optional)

We are now able to launch operating system.

Operating System

“Operating systems are designed as if they never start or stop, ...”

So we temporarily omit it here.

It's so-called chain loading

The general introduction ends up.

Let's check out what OMAP4-design does.

Boot Sequence of Ti OMAP4 Devices

Power Up ROM code X-Loader U-Boot (Das U-Boot) Linux Kernel Android
“This figure shows the booting sequence of the ROM code, x-loader, u-boot, and kernel, with each stage performing enough configuration in order to load and execute the next.”

Think About It

“Why are there two bootloaders?”

Answer

“The x-loader is a small first stage bootloader derived from the u-boot base code. It is loaded into the internal static RAM by the OMAP ROM code. Due to the small size of the internal static RAM, the x-loader is stripped down to the essentials.” “Boot loaders may face peculiar constraints, especially in size; for instance, on the IBM PC and compatibles, a boot sector should typically work in only 32 KB (later relaxed to 64 KB) of system memory...”

ROM Code

And the SYSBOOT pins

ROM Code

“The internal ROM Code can attempt to boot from several different peripheral and memory devices, including, but not limited to: Serial (UART3), SD Card, eMMC, NAND, and USB. The order in which these devices are searched for a valid first-stage booting image (x-loader) is determine by a set of GPIO configuration pins referred to as SYSBOOT.”

SD Card Boot

“If a card is found, the ROM then looks for the first FAT32 partition within the partition table. Once the partition is found, the root directory is scanned for a special signed file called "MLO" (which is the x-loader binary with a header containing the memory location to load the file to and the size of the file).”

NAND/eMMC Boot

“If NAND is included in the booting device list, the ROM attempts to load the first sector of NAND. If the sector is bad, corrupt, or blank, the ROM will try the next sector (up to 4) before exiting.”

ROM Code Boot Order

X-Loader

First Stage Boot

X-Loader

“The first bootloader, x-loader, is a stripped-down version of the u-boot, designed to run in OMAP's small on-chip SRAM. It initializes the main off-chip memory of the system and other necessary device drivers, and then loads the larger bootloader for Linux, u-boot.” “The x-loader configures the pin muxing, clocks, DDR, and serial console, so that it can access and load the second stage bootloader (u-boot) into the DDR.”

X-Loader

U-Boot

Second Stage Boot

U-Boot

“The u-boot is a second stage bootloader that is loaded by the x-loader into DDR.” “The u-boot can perform CPU dependent and board dependent initialization and configuration not done in the x-loader.” “The u-boot runs on the Master CPU (CPU ID 0), which is responsible for the initialization and booting; at the same time, the Slave CPU (CPU ID 1) is held in the “wait for event” state.”

U-Boot

do_bootm()

Loads kernel image header into RAM Loads kernel image into RAM Uncompresses kernel image from RAM to RAM Starts kernel

Starting the Linux Kernel

The entry point:
init/main.c: start_kernel()
The first process (init):
init/main.c: init_post()

Init

The source code:
android/system/core/init/init.c: main()
The init script:
android/system/core/rootdir/init.rc

init.rc

Android Init Language

“The Android Init Language consists of four broad classes of statements, which are Actions, Commands, Services, and Options.”

E.g.

  • Sets environment variables
  • Makes directories
  • Mounts file system
  • Starts services
  • Defines property hooks

Starting Android

Zygote Dalvik Virtual Machine System Server
android/frameworks/base/services/java/com/android/server/SystemServer.java
SystemUI
android/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUI.java
Launcher
android/packages/apps/Launcher2/src/com/android/launcher2/Launcher.java

Review

Review

Discussion Time

The End

Thank you!

0