Kernel boot process analysis

Kernel boot process analysis

The ultimate goal is to start the kernel to mount the root file system, run the application;

Core operating basis

  • Unzip and patch;

  • Disposed (there are three methods):

    1. Direct implementation of the make menuconfig , from start to finish each of which own configuration;

    2. Using the default configuration, modify up on this basis;

      You can use the following command to find out what are the current default configuration:

      find -name "*defconfig*" *

      Find found in ./arch/arm/configs/ have a lot of default configuration file directory, you can find a close comparison with its own board configuration file in which to use and modify;

      Execution profile operation command is:

      make xxxxx_defconfig    

      For example: make s3c2410_defconfig, the execution result is written to all the configuration items .config file;

      make muneconfig   

      Based on the configuration will xxxxx_defconfig (read .config file) after performing a configuration menu appears, and then can be further modified configuration item;

    3. Using a configuration file provided by the manufacturer;

      Files provided by the manufacturer typically config_ manufacturers , therefore run the following command to convert the file to .config file

      cp config_厂家 .config

      Then directly execute: the make menuconfig configuration;

  • Compile

    Direct execution the make , or to perform make uImage generate the corresponding file;

Compile the kernel configuration process analysis

Result of the configuration is generated .config file, which is a function of the contents of configuration options macros have different values, indicating that these functions at compile time, not incorporated into the kernel or the kernel or in the form of compiled modules (module after dynamically into the kernel);

When performing make uImage command:

  • .config file will generate /include/linux/autoconf.h file kernel source to be used;
  • .config file will generate /include/config/auto.conf file top Makefile is contained in the Makefile subdirectory will be used that will determine if a .o file is compiled into the kernel or compiled .ko module;

Kernel boot process analysis

Analysis can be found in the Makefile first file to be linked (entry program can be found in order to start the analysis process) as well as linker script (you can know where the kernel should be placed (connection address), how the internal arrangement);

The first file is: arch / arm / kernel / head.o arch / arm / kernel / init_task.o

Connection script is: arch / arm / kernel / vmlinux.lds (generated according to the file compiled vmlinux.lds.S);

Process flow:

  • Judge whether to support the CPU;

  • Determining whether to support the veneer (u-boot parameter passed by the machine ID);

  • Build page table (virtual addresses to actual physical address);

  • Enable MMU;

  • Jump to the start_kernel (first function implemented inside the kernel C), u-boot in which the parameters passed in setup_arch () and setup_commond_line () Processing two functions, after calling relationships are:

    start_kernel
      setup_arch  /* 解析u-boot传入的启动参数 */
      setup_commond_line
      rest_init
          kernel_init
              prepare_namespace
                  mount_root   /* 挂载根文件系统 */
              init_post  /* 执行应用程序 */

The definition of the kernel partition

The so-called core district is planning to write a good value fixed in accordance with the actual needs of the code, as written in which file, you can use the grep command to find the "bootloader" words, and then find the corresponding file;

Guess you like

Origin www.cnblogs.com/jasontian996/p/11403703.html