What are the parts of the so-called Complete Linux system? Go

Source: Internet
Author: User

This article was reproduced from: http://www.eeskill.com/article/index/id/1358.html

Introduction: Three parts: bootloader, Linux kernel (Linux kernel), rootfile (root file System). So how do these 3 parts work together to make up the system? What's the use of each? What are the links between the three people? How to contact? What is the implementation process of the system? Figuring out the problem you're working on the whole system is clear, and another important foundation for the next step in making this Linux system.

The following is a summary of the relationship between Bootloader, Linuxkernel (Linux kernel), rootfile (root file system), including questions and answers.

What is the exact relationship between bootloader, Linuxkernel and RootFile in 1.LINUX?

Bootloader->linuxkernel->rootfile

Boot order.

The latter requires the former to provide functional support, the former is to start the latter.

2. What is the startup process of embedded Linux bootloader?

An embedded Linux system can be divided into four parts from a software perspective: the boot loader (Bootloader), the Linux kernel, the file system, the application.

When the system is first booted, or when the system is reset, the processor executes a code at a known location in Flash/rom, and Bootloader is the first piece of code. It is mainly used to initialize the processor and peripherals, and then call the Linux kernel. After initializing the system, the Linux kernel needs to mount a file system as the root file system (Rootfilesystem) and then load the necessary kernel modules to launch the application. This is the whole process of Linux booting for embedded Linux system boot process.

The root file system is a core component of a Linux system that can be used as a storage area for files and data in a Linux system, often including system configuration files and libraries needed to run application software. An application can be said to be the "soul" of an embedded system, and the functions it implements are usually the goals to be achieved in designing the embedded system. Without the support of the application, any embedded system that is well-designed on hardware has no practical significance.

From the above analysis can be seen bootloader in the process of operation, although the initialization of the system and the execution of user input commands, but its most fundamental function is to start the Linux kernel, let us further analysis of the bootloader and Linux kernel in the embedded system of the relationship and role.

Bootloader

1, bootloader Basic overview

Bootloader is the bootloader of embedded system, it is the first program running after power on the system, it acts like the BIOS on PC. Bootloader is hardware-dependent, especially in the embedded domain, it is difficult to build a common bootloader for embedded systems, but in order to achieve the purpose of starting the Linux kernel, all bootloader must have the following features:

1) Initializing RAM

Because the Linux kernel typically runs in RAM, bootloader must set and initialize RAM before calling the Linux kernel, ready to call the Linux kernel. The task of initializing RAM includes setting the CPU's control register parameters so that the RAM can be used properly and the RAM size is detected.

2) initialize the serial port

Plays a very important role in the Linux startup process, which is one of the ways the Linux kernel interacts with the user. Linux can output the information through the serial port during the boot process, so you can clearly understand the Linux startup process. Although it is not a bootloader must be done, but through the serial port output information is a powerful tool to debug bootloader and Linux kernel, so the general bootloader will be in the process of initializing a serial port as the debug port.

3) Detecting processor type

Bootloader must detect the processor type of the system before calling the Linux kernel and save it to a constant to provide to the Linux kernel. The Linux kernel invokes the appropriate initialization program during startup based on the processor type.

4) Set Linux boot parameters

Bootloader the kernel boot parameters of Linux must be set and initialized during execution.

5) Call the Linux kernel image

The last thing bootloader do is call the Linux kernel. If the Linux kernel is stored in flash, and can be run directly on it (here Flash refers to Norflash), then you can jump directly to the kernel to execute. But because there are limits to executing code in Flash, and faster than RAM, the average embedded system is copying the Linux kernel into RAM and then jumping into RAM to do it.

2. bootloader Start-up process

Embedded Linux system through bootloader boot, a power on, it is necessary to perform bootloader to initialize the system. After the initialization of the system, it copies the Linux kernel in the nonvolatile memory (usually flash or doc, etc.) to ram and then jumps to the first instruction of the kernel to continue execution to start the Linux kernel. Bootloader and the Linux kernel are inextricably linked.

Bootloader most have two phases of the boot process:

Stage1:

Basic hardware Initialization

Preparing RAM space for loading Stage2

Copy the kernel image and file system image into RAM

Set stack pointer sp

Jump to the entry point of Stage2

Stage2:

Initialize the hardware device to be used in this stage

Memory mapping of the detection system

Loading kernel images and file system images

Setting the kernel's startup parameters

The non-volatile memory widely used in embedded systems is usually flash, and the bootloader is located at the very front of the memory, so the first procedure that the system performs after power-up or reset is bootloader. The bootloader is stored in Flash as follows:

Bootloader Start flowchart

3, bootloader start-up mode

3.1 Network boot Mode

The Development Board in this way does not require large storage media, which is a bit similar to diskless workstations, but it is necessary to install the bootloader into EPROM or flash on the board before using this startup method. The bootloader remotely downloads the Linux kernel image or file system via the Ethernet interface. The bootloader download file generally uses the TFTP network protocol, and the IP address can be dynamically configured by means of DHCP.

3.2 How to start a hard drive

Traditional Linux systems run on desktops or servers, which generally use BIOS booting and use disks as storage media. Linux has traditionally been the Linuxloader boot, and then the Gun Software (grandunifiedbootloader). These two types of bootloader are widely used in X86 Linux systems.

3.3Flash Boot Mode

Flash storage media is used on most embedded systems. There are many types of flash, including Norflash, Nandflash, and other semiconductor discs. The difference between them is that Norflash supports in-chip execution (Xip,executeinplace) so that the code can be executed directly on Flash without having to copy it into RAM. Nandflash does not support XIP, so to execute the code on Nandflash, you must first copy it into RAM and then jump into RAM to execute it. Norflash is most commonly used. The bootloader is usually placed at the bottom or top of the flash, which needs to be set according to the processor's reset vector. Can be configured as a MTD device to access the Flash partition

is the 3.linux kernel loaded into memory by bootloader?

Questions:

The content of the reference book bootloader the role of loading the kernel and transferring control to the kernel program, but the kernel file itself is stored in the hard disk file system, bootloader only 512B, at this time does not have the ability to identify the file system and INITRD, So how do you locate the kernel file on your hard disk?

For the file system of a doubt, to the Linux ext file system, for example, the file is composed of Super block, Inode, data block, to read the data must find the Inode, from which to take out the file is what bloc blocks, but who records the location of the inode? Is it a principle of MBR with hard disk? The first few fixed locations of the hard disk partition are present, and then the system interrupts are called to fetch?

Reply:

The kernel of Linux is actually loaded into memory by bootloader. The Linux bootloader consists of 2 parts: Bootstrap and Uboot. So the more accurate point is that the Linux kernel is loaded into memory by Uboot. The kernel file itself is stored in the file system of the hard disk, which is a wrong sentence. The kernel and file systems are stored separately. Uboot read kernel to memory is read from the address that the kernel begins to store, and the read start and read size are determined by the environment variables. So you don't need a file system at this time.

Give you a picture, easy to understand. This picture is the storage distribution of bootstrap, uboot, environment variables, kernel, and file system in Nandflash.

One of the ROOTFS.JFSS2 is the file system.

4. What are the differences and relationships between bootloader, U-boot and Linux kernels? Trouble who the hero to the younger brother guidance .

Bootloader is to replace the MBR function, can be seen as the strengthening of the MBR. U-boot is the USB disk into the boot disk, the Linux kernel is the core of the Linux system, you use Linux is the kernel based on the expansion of the shell and applications.

Mbr=masterbootrecord, master boot record, location on disk 0 track 0 cylinder 1 sector. The BIOS boot will first visit him and turn the boot over to the MBR,MBR record from where it started.

Brief introduction

MBR, all called Masterbootrecord, is the master boot record of the hard disk.

To facilitate understanding, the MBR is generally divided into generalized and narrow two: The generalized MBR contains the entire sector (boot program, partition table and delimited identity), which is referred to as the main boot record, and the narrow-sense MBR refers only to the boot program.

The hard disk's 0 cylinders, 0 heads, and 1 sectors are referred to as the primary boot sector (also called the Master Boot Record MBR). It consists of three parts, the master boot program, the hard disk partition table DPT (diskpartitiontable), and the hard disk effective flag (55AA). The Master Boot Program (bootloader) occupies 446 bytes in a total of 512 bytes of the main boot sector, and the second part is the Partitiontable area (partition table), which is the DPT, which accounts for 64 bytes, how many partitions are in the hard disk, and the size of each partition. The third part is MagicNumber, which accounts for 2 bytes and is fixed at 55AA.

5. Why bootloader to go to Flash to read into the Linux kernel

Your question should be divided into several parts.

1bootloader is mainly responsible for system initialization and system load embedded system will generally put bootloader and system kernel separately, so that if the system kernel is damaged can also be restored through bootloader

2linux cores are generally much larger than bootloader. An embedded system that, depending on the CPU, is running from a fixed memory address when the system has just been powered on. In general, this fixed address will be a ROM, its storage space is generally small, generally used to store bootloader. Depending on the design of the board, the system kernel is kept on flash or other storage media.

3bootloader after hardware initialization, the system kernel is read from the storage media into the specified memory area, and then jump to the system kernel with a jump instruction to start execution. Note that this storage medium is not necessarily flash

6. Why do I need bootloader?linux

The bootloader is the first piece of software code that runs after the system is power-up. The bootloader in the PC is made up of the BIOS (which is essentially a firmware program) and the Osbootloader (such as Lilo and Grub) in the hard disk MBR. After completing hardware detection and resource allocation, the BIOS reads the bootloader in the hard disk MBR into the system's RAM, and then gives control to Osbootloader. The main operational task of bootloader is to read the kernel image from the hard disk into RAM and then jump to the kernel entry point to run, starting the operating system.

In the embedded system, there is usually no firmware program like BIOS (note, some embedded CPU will also embed a short startup program), so the whole system load start task is completely done by bootloader. For example, in an embedded system based on Arm7tdmicore, the system usually executes from address 0x00000000 when power-up or reset, and the bootloader program of the system is usually arranged at this address.

To put it simply, Bootloader is a small program that runs before the operating system kernel runs. With this applet, we can initialize the hardware device and establish a mapping of the memory space to bring the system's hardware and software environment to a suitable state to prepare the correct environment for the final call to the operating system kernel.

Typically, Bootloader is implemented heavily on hardware, especially in the embedded world. Therefore, it is almost impossible to build a universal bootloader in the embedded world. Nonetheless, we can still generalize some common concepts to bootloader to guide user-specific bootloader design and implementation.

Running Gnu/linux systems on dedicated embedded boards has become increasingly popular. An embedded Linux system can usually be divided into four levels from a software perspective:

1, boot loader program. Includes the boot code (optional) that is cured in the firmware (firmware), and the bootloader two parts.

2, the Linux kernel. Custom kernel and kernel startup parameters specific to the embedded board.

3, File system. Includes the root file system and the file system built on the flash memory device. RAMDisk is usually used as a rootfs.

4, the user application program. User-specific applications. Sometimes an embedded graphical user interface may also be included between the user application and the kernel layer. Commonly used embedded GUI are: Microwindows and Minigui and so on.

What are the parts of the so-called Complete Linux system? Go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.