Android Kernel Analysis Reading Notes Chapter 2 Linux Basics
Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
The underlying task management and driver of Android are based on the Linux system;
The file system used in Linux is very different from that used in Windows (storage file system). It uses the root file system (rootfs) and has the following features:
All resources in Linux are files, such as disks, USB flash drives, memory, networks, and other hardware devices. Of course, there are data files on disks;
Sys/proc/dev these three directories correspond not to buckets, but to device files, maintained by the kernel and the corresponding driver;
The storage file system cannot coexist with rootfs and can only be mounted to sub-directories. The corresponding command is Mount/umount;
Storage file systems corresponding to Windows include ext2/ext3/ext4/yaffs;
Linux Startup Process
Boot and run the bootloader program:
Power the system, and the hardware circuit generates a definite reset sequence to ensure that the CPU is reset at last. Otherwise, the registers of other hardware (such as memory and hard disk) are not ready when the CPU is working;
After the reset, the CPU executes the first command. The memory address corresponding to the command should be fixed, which is generally specified by the CPU maker. The program stored with this fixed address is the so-called "Boot Program" bootloader;
Operating system kernel initialization, including Initializing Various hardware, including memory, network interfaces, and input devices. Then, various internal data structures are established for multi-thread scheduling and memory management;
Run the first application. Traditional Linux is a terminal. In fact, it provides an entry to start other applications;
Android Startup Process
Most Android systems run on arm processors. After the reset, the First Command executed by the CPU is generally uboot/fastboot in ROM (generally nand flash, it corresponds to the bootloader in the Linux system. It initializes some hardware interfaces (such as the NAND Flash interface and USB port) and provides some debugging functions, such as writing new data in NAND Flash, it can be used for Kernel burning and upgrading during development;
After the uboot is loaded, it usually checks whether the user has pressed some special Buttons (uboot is pre-defined during compilation) to enter the debugging mode. If there are no special buttons, then uboot directly loads the Linux kernel from NAND Flash and initializes it;
Run the first Android app home, or laucher;
Understand make commands and makefile files. For C/C ++ programs, the necessary tools for automatic compilation and packaging are similar to ant functions in Java. The basic syntax is: Target: condition (prerequest) (Tab key) command
The target can be any string or a file name;
The condition prerequest can be a specific file name or a target;
When the make script is executed, the make interpreter checks whether the timestamp of the file contained in the target and condition is the same. If the timestamp of the file is different, the command following the tab key is executed, the command can be any executable program;
Some common make syntaxes are described as follows:
$ Is a function call character. A function can be divided into three types (multiple parameters are used and separated ):
$ (Fname Param ...) The called function is a function defined in the make interpreter. It can be called directly anywhere in the script.
$ (Call frame, Param ...) In this case, the user uses the define keyword to create a custom function with parameters.
$ (Fname) calls a macro, that is, a user-defined non-parameter function.
The. Phony keyword is used to declare a target. The declared target always executes the command after the tab key, regardless of whether the condition and the timestamp of the object are the same;
You can add the @ symbol before the command, indicating that the command is not displayed on the console. By default, the command is automatically printed;
You can use $ (n) to obtain the input parameter in define declaration of a user-defined function. $ (0) indicates the function name, $ (1) indicates the first input parameter, and so on;
The Make interpreter has many built-in symbols, all starting with $. For example, $ @ indicates the target name;
-- Directory (-C) can specify the path of makefile/makefile. mk to be executed;
-- File (-f) can specify the name of the makefile to be executed, and the specified name can be customized, as long as it meets the make syntax rules;
-- Just-print (-N) only prints the command to be executed, rather than the actual command to execute the target. This option is useful for later analysis of Android compilation systems;
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.