u-boot make_config execution process analysis

Publisher:科技先锋Latest update time:2024-08-29 Source: cnblogsKeywords:u-boot  make Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

After downloading the uboot source code from the Internet, you need to modify the source code accordingly to support your own development board. After changing the source code, you need to configure uboot (make _config). Here, we take the development board jz2440 of Baiwen.com as an example, and the configuration command is make 100ask24x0_config. The execution process of this command is analyzed in the following steps:


1. Simple analysis of u-boot-1.1.6/Makefile


2. Detailed analysis of u-boot-1.1.6/mkconfig


3. Summarize what happens after executing the make 100ask24x0_config command


1. Simple analysis of u-boot-1.1.6/Makefile. The simplest rules of Makefile are as follows (extracted from the blog https://blog.csdn.net/haoel/article/details/2886)


target ... : prerequisites ...

command

...

...

target is a target file, which can be an object file or an executable file. It can also be a label.

(Label), the label feature will be described in the subsequent "pseudo target" chapter.

Prerequisites are the files or targets required to generate the target.

command is the command that make needs to execute. (Any Shell command)


Added rules to support jz2440 development board in u-boot-1.1.6/Makefile. This rule first executes the dependency unconfig to clear the files left by the previous configuration; then executes the mkconfig script with mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0.


a. @ before a command means that only the result will be displayed instead of the command itself.


b. $(bar) means referencing the variable bao.


c. The replacement rule is that we can replace the common part of the variable. Its format is "$(var:a=b)" or "${var:a=b}", which means,

Replace all occurrences of "a" in the variable "var" that "end with" a" with the string "b". Here "ends with"

It is "space" or "terminator".


MKCONFIG := $(SRCTREE)/mkconfig

SRCTREE := $(CURDIR) //CURDIR represents the current directory


100ask24x0_config: unconfig

@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0

//$(@:_config=) is the replacement rule that changes 100ask24x0_config to 100ask24x0, where @ represents 100ask24x0_config

//The final command is translated into /work/system/u-boot-1.1.6/mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0,

//Execute the mkconfig script with 6 parameters


100ask24x0_config depends on unconfig, which performs the following steps to delete some things that may be left over from previous configurations.


unconfig:

@rm -f $(obj)include/config.h $(obj)include/config.mk //If the command executed by Makefile is preceded by the @ symbol, the command itself will not be displayed but only the result

$(obj)board/*/config.tmp $(obj)board/*/*/config.tmp //$(obj) indicates the obj variable, and the actual obj is empty


2. Detailed analysis of the u-boot-1.1.6/mkconfig script


Some basic concepts of shell scripts: $0 represents the script file; $1 represents the first parameter; $2 represents the second parameter, and so on; $# represents the number of parameters that follow.


mkconfig 100ask24x0 arm arm920t 100ask24x0 NULL s3c24x0


$0 $1 $2 $3 $4 $5 $6


The script is annotated in detail as follows, excerpted from the blog https://www.cnblogs.com/mylinux/p/5549386.html


vi mkconfig

{

# Parameters: Target Architecture CPU Board [VENDOR] [SOC]

Determine the name of the development board:

{

23 [ "${BOARD_NAME}" ] || BOARD_NAME="$1"

}

Create links to header files related to the platform/development board. The purpose of establishing the connection is to use the same Makefile. After the connection is established, the Makefile has the same name, but in fact it can correspond to different files through configuration.

{

46 cd ./include

47 rm -f asm

48 ln -s asm-$2 asm //Create a soft link ./include/asm to ./include/asm-arm

51 rm -f asm-$2/arch

56 ln -s ${LNPREFIX}arch-$6 asm-$2/arch //Create a soft link ./include/asm-arm/arch to ./include/asm-arm/arch-arm920t

60 rm -f asm-$2/proc

61 ln -s ${LNPREFIX}proc-armv asm-$2/proc //Establish a soft link ./include/asm/arm/proc-armv to ./include/asm-arm/proc

}

Create include/config.mk for Make, and finally determine the variables ARCH=arm;CPU=arm920t;BOARD=100ask24x0;SOC=s3c2440 for the top-level Makefile to call

{

67 echo "ARCH = $2" > config.mk

68 echo "CPU = $3" >> config.mk

69 echo "BOARD = $4" >> config.mk

71 [ "$5" ] && [ "$5" != "NULL" ] && echo "VENDOR = $5" >> config.mk

73 [ "$6" ] && [ "$6" != "NULL" ] && echo "SOC = $6" >> config.mk

}

Create the header file include/config.h related to the development board. Include the ./include/configs/100ask24x0.h file. Many configurations of uboot need to change this file.

{

85 echo "#include " >>config.h

}

}


3. Summarize what happens after executing the make 100ask24x0_config command


a. Create a link to the platform/development board //Establish a soft link. Eventually, the main Makefile will call the soft link and finally locate the file


1) Create a soft link ./include/asm to ./include/asm-arm


2) Create a soft link ./include/asm-arm/arch to ./include/asm-arm/arch-arm920t


3) Establish a soft link ./include/asm/arm/proc-armv to connect to ./include/asm-arm/proc


b. Create the include file include/config.mk for Make, and finally determine the variables ARCH=arm;CPU=arm920t;BOARD=100ask24x0;SOC=s3c2440 for the top-level Makefile to call as variables.


c. Create the header file include/config.h related to the development board. The final uboot code will include ./inculde/configs/100ask24x0.h. This file is very important, and many uboot configurations are implemented in this file.


Keywords:u-boot  make Reference address:u-boot make_config execution process analysis

Previous article:Analysis of the execution process of make all in u-boot
Next article:Analysis of start.S of ARM920T in u-boot

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号