Android Kernel Analysis Reading Notes Chapter 2 Linux Basics

Source: Internet
Author: User
  1. The underlying task management and driver of Android are based on the Linux system;
  2. 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:
    1. 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;
    2. Sys/proc/dev these three directories correspond not to buckets, but to device files, maintained by the kernel and the corresponding driver;
    3. The storage file system cannot coexist with rootfs and can only be mounted to sub-directories. The corresponding command is Mount/umount;
    4. Storage file systems corresponding to Windows include ext2/ext3/ext4/yaffs;
  3. Linux Startup Process
    1. Boot and run the bootloader program:

      1. 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;
      2. 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;
    2. 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;
    3. Run the first application. Traditional Linux is a terminal. In fact, it provides an entry to start other applications;
  4. Android Startup Process
    1. 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;
    2. 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;
    3. Run the first Android app home, or laucher;
  5. 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

    1. The target can be any string or a file name;
    2. The condition prerequest can be a specific file name or a target;
    3. 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;
    4. Some common make syntaxes are described as follows:
      1. $ Is a function call character. A function can be divided into three types (multiple parameters are used and separated ):

        1. $ (Fname Param ...) The called function is a function defined in the make interpreter. It can be called directly anywhere in the script.
        2. $ (Call frame, Param ...) In this case, the user uses the define keyword to create a custom function with parameters.
        3. $ (Fname) calls a macro, that is, a user-defined non-parameter function.
      2. 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;
      3. 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;
      4. 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;
      5. The Make interpreter has many built-in symbols, all starting with $. For example, $ @ indicates the target name;
      6. -- Directory (-C) can specify the path of makefile/makefile. mk to be executed;
      7. -- 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;
      8. -- 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;
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: 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.