U-boot source code Configuration Principle Analysis

Source: Internet
Author: User

Author: Yang Shuo,Hua Qing vision embedded college lecturer.

The source code of U-boot is not targeted at any target platform by default. When we want to port U-boot to a specific target platform, we need to generate a configuration file for the target platform. The chips currently supported by U-boot can be found under include/configs. For example, we want to compile the u-boot.bin for the S3C2410 chip, then we need to execute in the U-boot source code root path:

Make smdk2410_config

In this way, our U-boot source code is for the smdk2410 platform. (Note: smdk2410 is a reference board specially developed by Samsung for its S3C2410 chip, that is, the reference board. Most Domestic Development Boards Based on S3C2410 are developed based on smdk2410)

So what exactly is the work behind make smdk2410_config? How does U-boot generate configurations for the smdk2410 platform? Next we will analyze this process. Since the make command calls makefile, we need to analyze the relevant parts in this makefile.

Smdk2410_config is a target of makefile in the root path of the U-boot source code. The related code is as follows:

Smdk2410_config: unconfig
@ $ (Mkconfig) $ (@: _ Config =) arm ARM920T smdk2410 null s3c24x0
Unconfig:
@ RM-F $ (OBJ) include/config. h $ (OBJ) include/config. mk/
$ (OBJ) Board/*/config. tmp $ (OBJ) Board/*/config. tmp

When you execute make smdk2410_config, The unconfig target is first executed to clear the previous configuration information. Then run @ $ (mkconfig) $ (@: _ Config =) arm ARM920T smdk2410 null s3c24x0. mkconfig is a variable of makefile and is defined as follows:

Mkconfig: = $ (srctree)/mkconfig

It can be seen that mkconfig is the mkconfig file in the top-level directory of the source code. This file is a shell script program. Therefore, when you execute make smdk2410_config, the system will execute the mkconfig script, arm ARM920T smdk2410 null s3c24x0 is to pass the five parameters of this script.

The mkconfig script generates two files for us: Include/config. h and include/config. mk. Before making smdk2410_config, let's take a look at the two files that are not included in include. Config. h contains only one sentence:

/* Automatically generated-do not edit */
# Include <config/smdk2410.h>

In fact, we include the configuration header file of the target platform. Another file, config. mk, contains the following content:

Arch = arm
CPU = ARM920T
Board = smdk2410
SOC = s3c24x0

In fact, four variables are defined here, including the architecture (ARM), the processor core (ARM920T), the target board (smdk2410), and the on-chip system (s3c24x0 ).

The above include/config. mk file will be contained in makefile. The corresponding code is as follows:

Ifeq ($ (objtree)/include/config. mk, $ (wildcard $ (objtree)/include/config. mk ))

# Load arch, board, and CPU Configuration
Include $ (objtree)/include/config. mk
Export arch CPU board vendor SOC

That is to say, makefile will determine whether there is a config. mk file under the include file. If there is a file that contains this file, this is equivalent to defining the arch, CPU, board, and SOC variables in the makefile. In this way, U-boot will know which target platform it is targeting.

There is also a config. mk file under the U-boot top-level Directory, which mainly defines cross-compiler options and compilation rules:

# Load other configuration
Include $ (topdir)/config. mk

The config. mk and config. mk under config. mk and include contain all the information during U-boot compilation. In fact, the key is to include the config. mk file. makefile will know the information of the target platform after it contains this file.

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.