Linux kernel booting

In this Article we will be discussing about linux kernel booting process. We will go step by step to have a deep knowledge of Linux kernel booting. Linux kernel booting process which we are discussing is basically related to linux kernel booting in embedded devices but linux booting is almost similar in PC also.

 

Linux kernel booting is divided mainly into three stages.

 

1) System Startup

2) Bootloader

3) Linux kernel execution

 

We will going in each stage of linux booting and understand it deeply.

diagram-1

1) System startup

diagram-2

1)User press the power button or reset the device.

2)CPU fetches first instruction from Reset vector .

3)Reset vector is the address which contains the first instruction to be executed after press the power or reset button.

4)Value of Reset vector is provided by OEM vendor of device.

5)Generally this address exist in NOR flash memory where the execution of boot monitor code starts.

6)Boot monitor is the small program which exist in Nor memory and shipped with Board similar to BIOS in PC.

7)Boot monitor code initialize main memory controller.

8)Setup stack in memory for the execution of bootloader.

9)Flash u-boot or other bootloader to NOR flash Memory.

10)Launch U-boot or other boot loader from boot monitor command line or can be done manually by entering command on boot monitor prompt.

11) If internal static RAM of Device or board is so small and cant store full bootloader then boot loader is devided into two parts first stage boot loader and second stage boot loader.

12) Then instead of loading full boot loader Boot monitor code loads only first stage boot loader.

 

2) Bootloader

If boot loader is divided into two stage then first stage boot loader initialise the core, Cache memory and then load second stage boot loader.

diagram-3

Second stage boot loader setup C environment for the execution of linux kernel.

Configure the system main memory.

Loads the Linux kernel image from a pre specified location.

3)Initialise Serial or video console for kernel.

4)Passes Physical memory layout to kernel by using booting ATAGS command ATAGS_MEM.

Generally linux kernel loaded at address 0x7cf0 in main memory.

Initialise boot parameters to passing to kernel in form of tags to describe the task it has done till now.

Pass control to kernel.

 

3) Linux kernel execution

Jump to head.s file which exist in /arch/arm/boot/compressed/head.S for ARM Processor.

diagram-4

Kernel follow the decompression algorithm and decompress itself as we had compressed image in memory.

After decompressing of kernel , it is responsible to perform some further initialisation activities.

This initialisation activity is divided into two stage.

In first stage kernel perform processor dependent initialisation e.g

lookup for processor type,machine type

Create page tables

Initialise TLB, Cache, MMU

finally it jumps to start_kernel() routine init/main.c where actually linux kernel starts.

After that kernel does second stage initialisation which perform processor independent tasks.

Initialise kernel tick control

set-up per cpu stack

Initialise memory zones such as DMA , High memory, low memory etc.

Initialise the interrupt tables

Initialise and run the system timer.

initialisation slab allocation

initialise the proc file system.

calls rest_init() function which creates first process which has PID 1.

After all this initialization it does basic setup like driver_init(), network socket interface setup, sysctl interface and calls do_initcalls() which initialise built-in device drivers.

after all kernel level initialisation it calls init_post() in which we actually switch to user mode by calling following processes

run_init_process(“/sbin/init”);

run_init_process(“/etc/init”);

run_init_process(“/bin/init”);

run_init_process(“/bin/sh”);

After userspace process creation and initialisation of services we can see the Operating System logo on our screen which confirms that device booting happened successfully.

 

 

 

 

 

adana elektrikci

', 'auto'); ga('send', 'pageview');