In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "what are the stages of the startup of embedded linux", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the stages of the startup of embedded linux?"
Examples are as follows:
Linux version 2.4.20-uc0 (root@Local) (gcc version 2.95.3)
20010315 (release) (ColdFire patches-20010318 from
Http://f
(uClinux XIP and shared lib patches from
Http://www.snapgear.com/
)) # 20 March June 1
8 00:58:31 CST 2003
Processor: Samsung S3C4510B revision 6
Architecture: SNDS100
On node 0 totalpages: 4096
Zone (0): 0 pages.
Zone (1): 4096 pages.
Zone (2): 0 pages.
Kernel command line: root=/dev/rom0
Calibrating delay loop... 49.76 BogoMIPS
Memory: 16MB = 16MB total
Memory: 14348KB available (1615K code, 156K data, 40K init)
Dentry cache hash table entries: 2048 (order: 2, 16384 bytes)
Inode cache hash table entries: 1024 (order: 1)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 4096 (order: 2, 16384 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Samsung S3C4510 Serial driver version 0.9 (2001-12-27) with no serial options en
Abled
TtyS00 at 0x3ffd000 (irq = 5) is a S3C4510B
TtyS01 at 0x3ffe000 (irq = 7) is a S3C451
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: BE558-1A5D57 [VIRTUAL BE558-1A5D57] (RO)
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
Samsung S3C4510 Ethernet driver version 0.1 (2002-02-20)
Eth0: 00:40:95:36:35:34
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 1024 bind 1024)
VFS: Mounted root (romfs
Freeing init memory: 40K
The above output may also include the output of the embedded linux development board you are working on, and have you studied the meaning of each line, or most of the meaning, exactly? I would like to combine some of my experience in practice here to read these information with the vast number of embedded linux developers.
Here we will take the startup process of a real embedded linux system as an example to analyze these output information. The original content of the startup information is marked with a tag to distinguish it from the comment.
# P#
The startup of embedded linux is mainly divided into two stages:
① part I bootloader startup phase
② part II linux kernel initialization and startup phase
Section 1: start_kernel
Section 2: user mode (user_mode) starts and start_kernel ends
Section 3: after loading the linux kernel, transfer to the cpu_idle process
Part one: bootloader startup
Boot loader v0.12
NOTE: this boot loader is designed to boot kernels made with the
2.4.xx releases
Bootloader for XV
Built at Nov 20 2005 10:12:35
Bootloader header information, version, compilation time, etc., this varies according to the design of different bootloader, from which you can see that the version information of bootloader, there are a lot of general bootloader, such as bootloader boot, etc.
Loaded to 0x90060000
Load the bootloader to the 0x90060000 in the memory ram, that is, the bootloader to the high-end address of the memory.
The Linux kernel will be loaded into 0x90090000 by bootloader.
Found boot configuration
Found the configuration information to start boot
Booted from parallel flash
Start the code from flash, where flash is parallel flash memory. The categories of Flash are as follows:
There are three types of flash memory: parallel, serial, and non-erasable.
① parallel Parallel flash
NOR Flash,Intel was invented in 1988. The speed of random reading is relatively fast. It is randomly written by bytes, and 8Bit can be transmitted every time. Generally suitable for data / program storage applications. Nor can also be on-chip execution (execute-in-place) XIP. Write and erase speed is very low.
NAND Flash, invented by Toshiba in 1989, reads and writes in blocks and pages, and cannot access a specified point at random. Therefore, the speed of reading is relatively slow, while the speed of erasing and writing is relatively fast. 16Bit can be transmitted every time, which is generally suitable for large-capacity multimedia applications. For example, CF,SM.
② serial Serial Flash is transmitted in bytes and can transmit 1-2Bit at a time. Such as: MMC,SD, MS card. Serial flash memory devices have small size, few pins and relatively low cost.
③ non-erasable Mask Rom Flash is characterized by one-time data entry, which can not be modified, and is often used in games and documents requiring copyright protection. Its remarkable feature is low cost.
Note: the write operation of any flash device can only be performed in an empty or erased unit, so in most cases, erasure must be performed before a write operation can be performed. It is very simple for NAND devices to erase, while NOR requires that all bits in the target block be written as 0 before erasing.
From the above information, we can have a clear understanding of the characteristics of flash types.
CPU clock rate: 200 MHz
The main frequency of CPU used on the development board is 200MHZ.
DRAM size is 128MB (128MB/0MB)
The dynamic memory ram size is 128m. Here we list the types of memory and how they work.
According to the working principle of memory, there are two kinds of memory: DRAM and SRAM.
① DRAM stands for dynamic random access memory. This is a semiconductor memory stored in the form of an electric charge. Each memory cell in the DRAM consists of a transistor and a capacitor. The data is stored in the capacitor. The capacitor will lose charge due to leakage, so the DRAM device is unstable. In order to store the data in memory, DRAM devices must be refreshed regularly.
② SRAM is static, so it maintains a value as long as it is powered. Generally speaking, SRAM is faster than DRAM because SRAM does not have a refresh cycle. Each SRAM memory cell consists of six transistors, while the DRAM memory cell consists of a transistor and a capacitor. In contrast, DRAM costs more per storage unit than SRAM. According to this reasoning, it can be concluded that the density of DRAM is higher than that of SRAM in a given fixed area.
SRAM is often used in cache because of its higher speed, while DRAM is often used in main memory in PC because of its higher density.
DRAM memory is widely used in embedded systems.
Address assist description:
First explain the memory address numbers, mainly in order to facilitate memory.
The memory that can be accessed is 4G.
0x40000000 is at 1GB; 0x00040000 is at 256K, 0x00020000 is at 128K, and 0x90000000 is the place with more 2GB.
1m-> 0x00100000
2m-> 0x00200000
8m-> 0x00800000
16m-> 0x01000000
32m-> 0x02000000
256m-> 0x10000000
64K-> 0x00010000
4K-> 0x00001000
This is a quick way to remember. You can quickly know how many megabytes the converted address is based on the location of 1s in the address and the number of zeros followed by it. For example, the last five zeros of 1 represent the size of 1m, six zeros represent 16m, and so on.
ROMFS found at 0x46040000, Volume name = rom 43f291aa
Romfs, the address of the read-only file system is: 0x46040000 (partition 3 after flash mapping).
The volume is called rom.
There are conceptual differences between romfs and rootfs.
The starting address of flash in memory is 0x46000000, while the starting position of ROMFS on the flash partition is 0x00040000, so the location of ROMFS in the memory address is 0x46040000. The details can be found in Creating 3 MTD partitions, where flash was partitioned.
Romfs includes kernel and app applications, but does not include bootloader and firmware headers. There are many ways to classify the content in the romfs read-only file system. We can put kernel and app in it at the same time as a file under the root file system, or we can separate areas on the flash.
VFS virtual file system switch
In the linux system, many kinds of file systems have been developed, so how to make these file systems co-exist in one system? starting from linux 2.0, the concept of virtual file system manager VFS is introduced.
The file system under Linux can be divided into three main blocks:
① 1 is the system call of the upper file system.
② 2 is the virtual file system switch VFS (Virtual Filesystem Switch)
③ 3 is the actual file systems mounted to the VFS, such as ext2,jffs, etc.
The exact name of VFS is Virtual Filesystem Switch virtual file system exchange, where the "S" in VFS refers to switch, which needs to be emphasized, it is easy to be confused with "system", if understood as "system" will be incorrect, please pay more attention.
VFS is a manager for a specific file system filesystem.
VFS is a software layer and a software mechanism in the Linux kernel. It also provides an abstract function in the kernel that allows different file systems to coexist. It can be called the file system manager of Linux, and its related data structures only exist in physical memory. So during each system initialization, Linux first constructs a VFS directory tree in memory. The main purpose of the directories in VFS is to provide the mount point of the actual file system. The rootfs will be the root of the root node of the directory tree, that is, the "/" directory, and the structure of the VFS begins with this rootfs. With VFS, the operation of files will use a unified interface, and in the future, instructions such as file operations initiated by VFS through file system calls will be taken over by the corresponding function interfaces in the rootfs file system.
Note: rootfs is not a specific file system type, such as jffs. It's just a theoretical concept. In a specific embedded system example, we can set a specific file system as the root file system rootfs, for example, we can set romfs as the root file system, or we can set jffs as the root file system.
The ROMFS read-only file system here is only a specific file system type, which is often used in embedded systems.
After reading the above, you should already know the meaning of the similar "kernel Panic:VFS:Unable to mount root fs on 0:00". Where "VFS:" is the output information when the virtual file system manager operates.
File linux.bin.gz found
The linux kernel kernel file name, which is an integral part of the read-only file system romfs.
Unzipping image from 0x4639DE60 to 0x90090000, size = 1316021
Extract the linux kernel in romfs to 0x90090000, and then boot the kernel from this memory address. Romfs is a compressed file format and uses a compressed read-only file system in order to reduce the flash space occupied by the entire system. The size of this kernel is about 1.3m, which is the method used by most embedded systems at present.
Inptr = 0x00000014 (20)
Inflating....
Release, decompression. (enlarge, inflate, expand)
Outcnt = 0x0030e7c8 (3205064)
Final Inptr = 0x001414ad (1316013)
Original CRC = 0xcbd73adb
Computed CRC = 0xcbd73adb
Do a CRC check after release
Boot kernel at 0x90090000 with ROMFS at 0x46040000
Kernel has been released from romfs to the memory address 0x90090000, where you can jump to start kernel. Here is the starting address of the specified kernel.
Press' enter' to boot
The system is waiting to boot, and you will see the startup process of linux kernel later.
# P#
Part II: linux kernel initialization and startup
Section 1: start_kernel
The source code for Linux is available from
Www.kernel.org
Get, or you can check the linux code cross-reference website:
Http://lxr.linux.no/
Online code review, this is a good tool website.
In start_kernel, a large number of init functions will be called to complete various initialization of the kernel. Such as:
Page_address_init ()
Sched_init ()
Page_alloc_init ()
Init_IRQ ()
Softirq_init ()
Console_init ()
Calibrate_delay ()
Vfs_caches_init (num_physpages)
Rest_init ()
For more information, please see [
Http://lxr.linux.no/source/init/main.c
]
Linux version 2.4.22-uc0 (root@local) (gcc version 2.95.3 20010315 (release)) # 33.? 1. 20 12:09:106
The above code output information, which is obtained after tracking the linux code analysis, enters the start_kernel startup function of main.c under the init directory.
Embedded linux uses linux kernel version 2.4.22
Linux_banner information output from start_kernel in linux source code code. This message is printed by every linux kernel, if you haven't removed this sentence.
Found bootloader memory map at 0x10000fc0.
Bootloader after memory mapping address is: 0x10000fc0, according to the above address conversion method, 1 followed by 7 zeros, then the virtual address 256m left and right.
Processor: ARM pt110 revision 0
PT110 is one of the arm cores of ARM microprocessors, and the other is pT100. Here is the type of ARM displayed.
On node 0 totalpages: 20480
Zone (0): 20480 pages.
Zone (0): Set minimum memory threshold to 12288KB
Warning: wrong zone alignment (0x90080000, 0x0000000c, 0x00001000)
Zone (1): 0 pages.
Zone (2): 0 pages.
The memory size is reserved for a total of 20 pages on node 0, with zone (0) setting the minimum memory to 12MB and zone (1) and zone (2) to 0 pages. Warning: incorrect alignment
Kernel command line: root=/dev/mtdblock3
The Kernel startup command is set to: / dev/mtdblock3 (you'll see that mtdblock3 refers to the romfs partition on flash in a later description. To specify the location of the root file system, kernel treats the block device mtdblock3 as a file system
That is, the kernel will know that the read-only file system romfs will be the root file system rootfs based on the above kernel command line.
The above message is output in start_kernel (void).
This command is output during the startup of the linux kernel.
Console: colour dummy device 80x30
The output information of console_init () in the code shows the console properties: VGA text console is generally used, and the standard is the text console with 80 X 25 rows and rows. Here, the properties are set.
Serial_xx: setup_console @ 115
The serial port setting is 115200, which is the baud rate output information. Do a print action on the serial port setting information, which will be very useful when debugging.
Calibrating delay loop... 82.94 BogoMIPS
Calibrate: calibrate, enter the delay calibration cycle. Check CPU's MIPS (millions of instructions per second). Bogo means Bogus. Here is a real-time test of CPU to get an approximate MIPS value
Bogomips, written by linus Torvalds, is a measure of the running speed of computer processors in the Linux operating system. The program that provides this measure is called BogoMips, and when the computer is started, BogoMips can show whether the system option is at its best.
There is a function calibrate_delay () in the linux kernel that calculates how many times cpu executes a very short loop in a second. The calculated value is processed to get the BogoMIPS value.
You can compare the bogomips of a computer with the bogomips of a computer processor. Torvalds calls this program BogoMips to imply that performance metrics between two computers are wrong because not all factors that play a role can be shown or recognized. Although MIPS is often used in computer benchmarks, changes in the environment can easily lead to measurement errors. Bogomips can measure how many times a program has been run in a second.
You can also get this value by looking at the last line in the / proc/cpuinfo file.
The output above will be printed in all linux system booting.
Enter memory initialization
Mem_init (void), [arch/i386/mm/init.c]
Memory: 80MB = 80MB total
Memory: 76592KB available (1724K code, 2565K data, 72k init)
The current memory usage will list the total memory size and the amount of memory allocated to the kernel: including the code part, the data part, and the initialization part, with a total of exactly 4m. Note the various values of the memory size of the kernel here.
Enter the virtual file system VFS initialization
Vfs_caches_init ()
Dentry cache hash table entries: 16384 (order: 5, 131072 bytes)
Inode cache hash table entries: 8192 (order: 4, 65536 bytes)
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer cache hash table entries: 4096 (order: 2, 16384 bytes)
Page-cache hash table entries: 32768 (order: 5, 131072 bytes)
Noun:
① Dentry: directory data structure
② Inode:i node
③ Mount cache: file system load buffer
④ buffer cache: memory buffer
⑤ Page Cache: page buffer
Dentry directory data structure (directory entry cache), which provides a fast lookup mechanism for translating pathnames into specific dentry. Dentry exists only in RAM.
The I node (inode) data structure stores the information of a file or directory on disk, and the I node exists on the disk drive; the I node that exists in RAM is the I node of VFS, and the pointer contained in dentry points to it.
Buffer cache memory buffers, similar to kupdated, are used to buffer between memory and disk
Page Cache is used to speed up access to images and data on disk.
Set up each buffered hash table in memory in preparation for kernel's access to the file system.
The VFS (virtual filesystem switch) virtual file switch directory tree is useful for structural tables like this.
The above output information can be seen in the general linux startup process.
POSIX conformance testing by UNIFIX
Conformance: adapt, consistent. That is, POSIX adaptability detection. UNIFIX is a German technology company. Linux was originally based on POSIX.1, but POSIX is not free, and POSIX.1 certificates are very expensive. This makes it difficult to develop Linux based on POSIX. Unifix Company (Braunschweig, Germany) has developed a Linux system that has obtained the FIPS 151-2 certificate. This technology is used in Unifix Linux 2. 0, the Unifix distribution, and Linux-FT in Lasermoon.
The above output is removed in the 2.6 kernel.
# P#
Section 2: user mode (user_mode) starts and start_kernel ends
PCI: bus0: Fast back to back transfers disabled
PCI: Configured XX as a PCI slave with 128MB PCI memory
PCI: Each Region size is 16384KB
PCI: Reserved memory from 0x10080000 to 0x15080000 for DMA and mapped to 0x12000000
Initialize init ()-- > do_basic_init ()-- > pci_init () of the device, initialize PCI, and detect the PCI device of the system.
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
NET3.039, TCP/IP protocol stack of Swansea University in Wales, UK
This information appears during the startup of linux.
Initializing RT netlink socket
Initialization of Socket, socket_init (), Netlink a router management protocol (linux-2.4.22\ net\ core\ Rtnetlink.c,Routing netlink socket interface: protocol independent part. Where RT means route routing. This output is a debug output when create generates rtnetlink's socket socket.)
This information appears during the startup of linux.
Starting kswapd
Start the exchange daemon kswapd, the process IO operation routine kpiod
Kswapd can be run with kpiod. A process sometimes has nothing to do, and it doesn't necessarily need to keep all its code and data in memory when it runs. This means that we can make better use of memory by switching things that are not used by running programs to swap partitions. About every second, kswapd wakes up and checks memory. If something on the hard disk needs to be read into memory, or if there is not enough free space in memory, kpiod will be called to do the move in / out operation. Kswapd is responsible for checking and kpiod is responsible for moving.
Journalled Block Device driver loaded
Load the log block device driver.
A log block device is a block device used to log a file system. The journaling file system adds the logging of file system changes on the basis of the traditional file system.
Its design idea is to track and record the changes of the file system and record the changes in the log. The log file system keeps log records in the disk partition. The write operation begins with the operation of the record file. If the whole write operation is interrupted for some reason (such as a power outage of the system), when the system restarts, the write operation before the interruption is resumed according to the log record. In the journaling file system, all changes to the file system are recorded in the log, and at regular intervals, the file system will write the updated metadata and file contents to disk. Before making any changes to the metadata, the file system driver writes an entry to the log that describes what it is going to do, and then it modifies the metadata.
Devfs: v1.12c (20020818) Richard Gooch (rgooch@atnf.csiro.au)
Devfs: boot_options: 0x1
The output of the Devfs module.
Device file system devfs, version 1.12c
Pty: 256 Unix98 ptys configured
The output information of the Pty module and the settings related to the console operation.
Unix98 PTYs will be used through the devpts file system, and (Pseudo-ttys (telnet etc) device is an abbreviation for pseudo-ttys devices.
① TTY (/ dev/tty) is an old acronym for TeleTYpe that provides different console device drivers for user input. Its name comes from a terminal called a teletypewriter (teletype) that is actually connected to the UNIX system. Under Linux, these files provide support for virtual consoles, which can be accessed by pressing the < Alt-F1 > to < Alt-F6 > key. These virtual consoles provide independent, simultaneous local login conversations
② ttys (/ dev/ttys) is the serial interface of the computer terminal. / dev/ttyS0 corresponds to the COM1 under MS-DOS.
Use the make dev script MAKEDEV to create the pty file. In this way, the system kernel supports Unix98-style pty. The / dev/pty device will be used for Telnet login. Pty is a pseudo terminal device, which must be used in applications that need to connect by terminal, such as remote login, but not a real terminal, such as telnet or xterm. Linux 2.2 has added a UNIX98-style Pty device that uses a new file system (devpts's file system for pseudo-terminals) and a cloned device cloning device to implement its functions.
Linux-2.4.22\ drivers\ char\ Pty.c, which outputs the above information when devfs_mk_dir (NULL, "pts", NULL);.
Loop: loaded (max 8 devices)
Load return block device driver, supporting up to 8 devices
8139too Fast Ethernet driver 0.9.27
Eth0: RealTek RTL8139 at 0x60112000, 00:10:0d:42:a0:03, IRQ 14
Eth0: Identified 8139 chip type 'RTL-8100B/8139D'
Nic driver, base address: 0x60112000, MAC address: 00:10:0d:42:a0:03, interrupt number: 14
The receive path of RTL8139 is designed as a ring buffer (a linear memory mapped to a ring memory). When the device receives the data, the contents of the data are stored in the ring buffer and the address of the next stored data is updated (the start address of the first packet + the length of the first packet). The device retains the data in the buffer until the entire buffer is exhausted. In this way, the device rewrites the contents of the starting position in the buffer again, just like a ring.
By the time the kernel was upgraded from version 2.2 to version 2.4, the RTL-8139 support module was no longer called rtl8139, but 8139too, and now you won't fail to understand where it comes from when you see 8139too again.
SCSI subsystem driver Revision: 1.00
USB device information, USB will be treated as SCSI.
Mumk_register_tasklet: (1) tasklet 0x905bf9c0 status @ 0x9025e974
Soft interrupt information output. Tasklet appeared in 2. 4 to make better use of multi-CPU.
Probing XX Flash Memory
Probe XX's flash memory (Flash Memory), "NOR NAND Flash Memory Technology"
Amd/Fujitsu Extended Query Table v1.3 at 0x0040
Number of CFI chips: 1
Spansion, a Flash supplier jointly established by AMD and Fujitsu. AMD has withdrawn from the Flash market due to poor profits, followed by a Spansion joint venture. It mainly produces NOR type flash, which is characterized by small capacity and high speed. Spansion trademark flash, in our development will often see. In the future, when you see the chip of Spansion, you will be able to understand its relationship with AMD and Fujitsu.
Common flash Interface (CFI) refers to a unified flash access interface, indicating that this flash is of this interface type.
Using buffer write method
Use flash write buffering
Flash provides commands to write BUFFER to speed up operations on blocks on flash. It is slow to erase and write data to Flash. It will be faster if you use the command to write BUFFER. According to the manual, it will be 20 times faster. Buffer Size: 5 bytes buffer buffer is not available for every block. There is only one 5 bytes buffer for the whole flash. Write BUFFER commands are used to write all blocks using the same buffer. Writing Buffer is mainly to check whether buffer is available. In fact, buffer acts as a buffer to improve work efficiency.
For example, a flash has 128k byte blocks. The user is allowed to program any block and write buffer byte, and the programming time per byte is 210 μ s. If the write buffer byte programming mode is adopted, the total programming time of 32 bytes is 218 μ s, and the programming time per byte is only 6.8 μ s. The block erase time of the chip is 1s, which allows suspension interrupt to read operation while programming or block erasure operation. After the read operation is completed, write suspension recovery command, and then continue programming or block erase.
Creating 3 MTD partitions on "XX mapped flash":
0x00000000-0x00020000: "BootLoader"
0x00020000-0x00040000: "Config"
0x00040000-0x01000000: "Romfs"
Here is the important information section, which requires special attention.
With the flash mapped in memory, create three MTD partitions:
The content on the flash will be mapped to the corresponding address in memory
The first 128k is BootLoader--- > 0x00000000-0x00020000
The next 128k is the location where the system configuration information Config is stored-> 0x00020000-0x00040000
The next 16m-2X128K is the storage of the romfs.-> 0x00040000-0x01000000
The above content can be obtained according to the previous conversion formula.
The general size of A > compiled bootloader is about 50K
B > you will know the configuration information here. Config is placed in the second partition.
The size of the romfs made by C > is generally about 8m or 10m, so it can fit.
Block device driver of embedded Linux kernel:
For the root file system of linux, there are currently three drivers for block devices to choose from, which are:
A) Blkmem driver
B) MTD driver
C) RAM disk driver
Blkmem driver is a kind of block device driver specially developed for embedded linux. It is the most ancient and general block device driver in embedded linux system. Its principle is relatively simple but the configuration is relatively complex, and you need to modify the code according to the partition usage of your Flash. Of course, the result of the modification is that it can read and write to some nor-type Flash. However, there are not enough Flash types currently supported. If you add new support for a Flash, you need to do a lot of work.
The MTD driver for Linux is the Flash driver for standard Linux. It supports a large number of devices, has enough functionality to define Flash partitions, address mapping, and so on. With MTD you can use different types of Flash in a system. It can combine different Flash into a linear address for you to use.
In the standard Linux 2.4 kernel, MTD has a series of options that you can choose and customize according to the needs of your personal system.
Another option is the RAM disk driver. On PC, it is often used in the boot process of Linux without a hard disk. It is not directly related to Flash. But when a compressed kernel is started on Flash. RAM disk can be used as the root file system.
The MTD driver provides powerful support for Flash, and you can even run a real file system that can read and write on Flash, such as JFFS2. The Blkmem driver is unmatched.
NET4: Linux TCP/IP 1.0 for NET4.0
The output information when calling inet_init [linux-2.4.22\ net\ ipv4\ Af_inet.c] is called by socket.c during startup.
IP Protocols: ICMP, UDP, TCP, IGMP
Lists the IP protocols that can be supported, here is the output of the kernel source code inet_add_protocol (p);.
You will see the output of this sentence during the startup of linux.
IP: routing cache hash table of 512 buckets, 4Kbytes
The output of the IP routing code.
Ip_rt_init [linux-2.4.22\ net\ ipv4\ Route.c], Set the IP module up, routing buffer hash table
TCP: Hash tables configured (established 8192 bind 8192)
The TCP protocol initializes the output information. Tcp_init [linux-2.4.22\ net\ ipv4\ Tcp.c]
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
UNIX network protocol information.
Af_unix_init [linux-2.4.22\ net\ unix\ Af_unix.c], one of multiple connections (IPv4, UNIX domain sockets, IPv6 and IrDA). SMP symmetric multiprocessor-Symmetrical Multi Processing, which mainly refers to some network protocols of UNIX.
The above output information about the network will appear in the linux startup information.
Load various file systems
Cramfs: wrong magic
There will be "cramfs: wrong magic", don't worry, this is kernel's writing bug, which has been modified in 2.6. it is a warning message to check the superblock super block of cramfs. Superblock is also the data structure to be used by VFS.
Code linux-2.4.22\ fs\ cramfs\ Inode.c:
2.4
Cramfs_read_super (. )
/ * Do sanity checks on the superblock * /
If (super.magic! = CRAMFS_MAGIC) {
/ * check at 512 byte offset * /
Memcpy (& super, cramfs_read (sb, 512, sizeof (super)), sizeof (super))
If (super.magic! = CRAMFS_MAGIC) {
Printk (KERN_ERR "cramfs: wrong magic\ n")
Goto out
}
}
2.6
If (super.magic! = CRAMFS_MAGIC) {
If (! silent)
Printk (KERN_ERR "cramfs: wrong magic\ n")
Goto out
}
The superblock is the "header" of the file system. It contains information such as the status, size, and free blocks of the file system. If a super block of a file system is corrupted (such as accidentally writing data directly to the super block partition of the file system), the file system may not be recognized at all, so it cannot be mounted and cannot be handled even with the e2fsck command.
# P#
Cramfs file system:
Cramfs is a small file system suitable for embedded systems developed by Linus Torvalds himself. Because it is read-only, although it uses zlib to do compression, it can still do efficient random reading. Cramfs does not affect the speed at which the system reads files, and it is also a highly compressed file system.
After we have made the image file, we also need to consider how to mount the image file into an available file system while the system is running. Since this image file is not a normal block device, we must use a loopback device to accomplish this task, such as:
Mount-o loop-t cramfs / usr.img / usr
In this way, you can mount the image file of usr.img cramfs to the / usr directory via the loopback device. Support for loopback is required in the kernel.
The compression efficiency of cramfs is generally close to 50%.
Cramfs achieves the purpose of saving space by optimizing the size of the index node table and removing the waste of space between files in the traditional file system. It also uses zlib compression to achieve a compression ratio better than 2:1. The system overhead of the decompression process is not great, because Cramfs supports the extraction of a specified single block, and it is not necessary to extract the entire file.
Cramfs can not only save space, but also avoid the trouble of waiting for fsck or manual fsck caused by abnormal shutdown. It does this in a read-only way.
There are three ways to implement RamDisk:
In Linux, a part of the memory mount can be used as a partition, usually called RamDisk, which is divided into:
Ramdisk, ramfs, tmpfs.
The first ① is in the traditional sense, which can be formatted and then loaded.
This is already supported in the Linux kernel 2.0 amp 2.2, but its disadvantage is that the size is fixed and cannot be changed later.
In order to be able to use Ramdisk, we have to select the Ramdisk support in block device when compiling the kernel, and there are two options below it, one is to set the size of Ramdisk, the default is 4096k, and the other is initrd support.
If support for Ramdisk has been compiled into the kernel, we can use it:
First check the available RamDisk, using ls / dev/ram*
First create a directory, such as test, and run mkdir / mnt/test
Then create a file system for / dev/ram0 and run mke2fs / dev/ram0
Finally, mount / dev/ram0, run mount / dev/ram / mnt/test, and you can manipulate it as if it were a normal hard disk.
The other two kinds of ② are supported by kernel 2.4 and are implemented through Ramfs or Tmpfs:
They do not need to be formatted, they are flexible to use, and their size increases or decreases with the space needed.
Ramfs, as its name implies, is an in-memory file system, which is at the virtual file system (VFS) layer, unlike ramdisk, which is based on other virtual file systems in memory (ex2fs).
Therefore, it does not need to be formatted, it can create multiple, as long as there is enough memory, you can specify the maximum amount of memory that can be used at the time of creation.
If your Linux has compiled Ramfs into the kernel, you can easily use Ramfs. Create a directory and load Ramfs into the directory:
# mkdir / testRam
# mount-t ramfs none / testRAM
By default, Ramfs is limited to a maximum of half the amount of memory available. It can be changed through the maxsize (in kbyte) option.
# mount-t ramfs none / testRAM-o maxsize=2000 (creates a ramdisk with a maximum memory usage of 2m)
③ Tmpfs is a virtual memory file system, which is different from the traditional Ramdisk implemented in the form of block devices, and also different from Ramfs for physical memory.
Tmpfs can use physical memory or swap partitions. In the Linux kernel, virtual memory resources are composed of physical memory (RAM) and swap partitions, which are allocated and managed by the virtual memory subsystem in the kernel.
Tmpfs requests pages from the virtual memory subsystem to store files, and like other requested pages in Linux, it doesn't know whether the pages allocated to it are in memory or in swap partitions. Like Ramfs, its size is not fixed, but increases or decreases dynamically with the space needed.
With tmpfs, you first have to select Virtual memory File system support (Virtual memory filesystem support) when compiling the kernel.
Then you can load the tmpfs file system:
# mkdir-p / mnt/tmpfs
# mount tmpfs / mnt/tmpfs-t tmpfs
You can also specify the maximum size limit for the tmpfs file system at load time:
# mount tmpfs / mnt/tmpfs-t tmpfs-o size=32m
FAT: bogus logical sector size 21072
The specific file system FAT format.
The size of the virtual logical sector is 20K Linex fs 2.4.22\ fs\ fat\ Inode.c.
When initializing the MS-DOS file system, read the superblock of the MS-DOS file system and output the above information in the function fat_read_super.
UMSDOS: msdos_read_super failed, mount aborted.
UMSDOS: a file system characterized by large capacity but relatively unstable. Is an extended DOS file system used by Linux. It adds long file names, UID/GID, POSIX permissions and special file (devices, named pipes, etc.) functions under the DOS file system without sacrificing compatibility with DOS. Allowing a normal msdos file system to be used in Linux without having to create a separate partition for it is especially suitable for early hardware conditions where hard disk space is insufficient.
VFS: Mounted root (romfs filesystem) readonly
The output of the virtual file system VFS (Virtual Filesystem Switch).
Emphasize a concept again. VFS is a software mechanism, which can also be called the file system manager of Linux. It is used to manage the mount point of the actual file system in order to support multiple file systems. Kernel first builds a VFS directory tree in memory, which is a data object in memory, and then mounts the rootfs file system under it, as well as other types of file systems to a subdirectory.
Mounted devfs on / dev
Load the devfs device management file system on the dev mount point.
/ dev is a directory that we often use.
It is only used in 2. 4 kernel. The kernel automatically mounts devfs each time it starts.
Devfs provides a namespace to access kernel devices. It's not about creating or changing device nodes, devfs is just maintaining your special file system. In general, we can manually create mknod device nodes. The / dev directory is initially empty and specific files are created when the system boots or when the driver loads the module. When the module and driver are uninstalled, the file disappears.
Freeing init memory: 72K
Frees up the memory used by user process 1, init.
Section 3: after loading the linux kernel, transfer to the cpu_idle process
The process during the system startup process:
① init process
Generally speaking, after running kernel bootstrapping kernel boot bootstrap (loaded into memory, has started running, has initialized all device drivers and data structures, etc.), the system runs init "father of all processes". With it, it can start to run other processes. Therefore, the init process, which is the first user-level process started by the kernel, has always had a process number of 1.
You can verify it with the process view command
# ps aux
PID Uid VmSize Stat Command
1 0 SW init
2 0 SW [keventd]
3 0 SWN [ksoftirqd_CPU0]
4 0 SW [kswapd]
5 0 SW [bdflush]
6 0 SW [kupdated]
7 0 SW [rbwdg]
9 0 SW [mtdblockd]
10 0 SW [khubd]
80 0 SW [loop0]
In addition, Linux has two process of kernel class, one is kflushd/bdflush, the other is kswapd.
Only this init is a process that belongs entirely to the user class, and the latter two are kernel hanging on the process under the name of the process process.
Init has many important tasks, such as starting getty (for user login), implementing the run level, and dealing with orphaned processes.
Init starts to read / etc/inittab (init initialization table). The initialization table is arranged in a certain format about the information about the runtime of the process. The init program needs to read the / etc/inittab file as its behavior pointer. This inittab has clear settings for which rc or spawn to run and what to produce for each runlevel runlevel.
In general, initialization scripts in Linux can find descriptions of different run levels in the / etc/inittab file (or initialization table). Inittab is descriptive (non-executable) text in a behavior unit, with each instruction line in a fixed format
There is a respawn entry in inittab, but if a command fails at runtime, to avoid rerunning too frequently, init will track how many times a command has been rerunned, and if the rerun frequency is too high, it will be delayed for five minutes.
② kernel process
A > Please note that init is process 1, and the other processes id are kflushd/ bdflush, kupdate, and kpiod and kswapd. Here's one thing to point out: you'll notice that both the SIZE and RSS columns are 0, so how can the process not use memory?
These processes are the kernel daemons. Most kernels do not appear in the process list. Daemons start after init, so they have process ID like other processes, but their code and data are stored in the memory occupied by the kernel. Use parentheses in the list to distinguish them from other processes.
B > input and output are done by buffering in memory, which makes things faster, and program writes are stored in memory buffers and then written to the hard disk together. The daemons kflushd and kupdate manage this work. Kupdate works intermittently (every 5 seconds) to check if there are written buffers, and if so, let kflushd write them to disk.
A C > process sometimes has nothing to do, and it doesn't necessarily need to keep all its code and data in memory when it runs. This means that we can make better use of memory by switching things that are not used by running programs to swap partitions. Move these process data into / out of memory through the process IO to manage daemon kpiod and swap daemon kswapd. About every second, kswapd wakes up and checks memory. If something on the hard disk needs to be read into memory, or if there is not enough free space in memory, kpiod will be called to do the move in / out operation.
D > bdflush-BUF_DIRTY, the core daemon that writes the dirty cache back to disk. A dynamic response is provided for systems with many dirty buffers (buffers containing data that must be written to disk at the same time). It starts as a core thread when the system starts, and it calls itself "kflushd", which is the name you will see when you use ps to display the processes in the system. That is, write the contents of the dirty buffer to disk periodically (5 seconds) to free up memory.
E > ksoftirqd_CPUx is an endless loop that handles soft interrupts. It is a process used to buffer the soft interrupt queue. When a soft interrupt occurs, the system is not in a hurry to deal with it, but only sets the corresponding bit of active in the interrupt state structure of the corresponding cpu, sets the corresponding processing function to the corresponding queue, and then waits for the scheduling time to come to deal with it.
Ksoftirqd_CPUx is a kernel thread triggered by cpu_raise_softirq (), that is, cpu, to wake up the kernel thread, which involves soft interrupts. For the code of ksoftirqd, see [kernel/softirq.c]
F > keventd, whose task is to execute tasks in the scheduler scheduler queue, and keventd provides a predictable process context for the tasks it runs.
G > khubd is used to detect USB hub devices. When the usb is dynamically plugged and unplugged, it will be handled by this kernel process. When a hub event is detected, there will be a corresponding action (usb_hub_events ())
H > mtdblockd is a daemon used to write to flash block devices.
Flash of NAND type requires the support of MTD (Memory Technology Devices memory Technology driver) driver to be used by linux.
The characteristic of NAND is that it can not be executed in the chip (XIP,eXecute In Place), and the code needs to be read into the system RAM before execution. The transmission efficiency is not the highest, with a maximum number of erasure times of one million times, but the speed of writing and erasing is very fast, and the erase unit is small, so it is the best choice for high data storage density.
NAND requires an Icano interface, so a driver is required when using it.
I > loop0 is responsible for handling loop block devices (loopback devices). Loopback device refers to the use of files to simulate block devices. In our case, loop devices are mainly used to deal with file systems that require mount to the board, similar to mount / tmp/rootfs / mnt-o loop. . Our examples are: mount-o loop-t cramfs / xxx.bin / xxx, that is, mount the file xxx.bin to the board to simulate the cramfs compressed ram file system. The loop0 process is responsible for operating the loop device.
Loopback devices are used in the same way as other block devices. In particular, you can create a file system on the device and then use the mount command to map the system to a directory for access. This whole file system based on an ordinary disk file is called virtual file system (virtual file system).
At this point, I believe that everyone on the "embedded linux startup is divided into which stages" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.