#! /Bin/sh-e
# Script to create header files and links to configure
# A script configuration file that generates the header file and connection file. This configuration file is mainly used for three things, which will be described in the following sections.
# U-boot for a specific board.
# The purpose is to configure uboot for a specific Board
# Parameters: target architecture CPU board [Vendor] [SOC]
# Input parameters (6): Target Board, architecture, CPU, board type, developer, and on-chip system
# (C) 2002-2006 denx software engineering, Wolfgang Denk <[email protected]>
#
Append = No # default: Create New config file append = no is a flag. After reading this article, you will understand
Board_name = "" # name to print in make output the name of the Development Board.
######################################## ######################################## ###########
# The following two lines are the two lines of code in the top-layer makefile when we execute make smdk2410_config.
# $ (Mkconfig) is the script mkconfig we are currently analyzing,
# $ (@: _ Config =), arm, ARM920T, smdk2410, null, and s3c24x0 are the six parameters passed to the mkconfig script in sequence.
# Smdk2410_config: unconfig
# @ $ (Mkconfig) $ (@: _ Config =) arm ARM920T smdk2410 null s3c24x0
######################################## ######################################## ###########
# --), --),-N) What does it mean? It seems you have to learn shell !!!
While [$ #-GT 0]; do # "$ #" is a special variable of shell, meaning "number of parameters passed to the script ", when the number of parameters passed to the mkconfig script is greater than 0...
Case "$1" in #$1 is the shell location variable. This case statement should be used to determine the first parameter. The first parameter is $ (@: _ Config = ), should it be smdk2410_config?
--) Shift; break ;;
--) Shift; append = yes; // I still haven't understood these words!
-N) shift; board_name = "$ {1% % _ config}"; shift ;;
*) Break ;;
Esac
Done
["$ {Board_name}"] | board_name = "$1" # If the board name is ...., or the name of the Board is $1. What is this statement ??????? ,
[$ #-Lt 4] & Exit 1 # exit if the number of parameters is smaller than 4
[$ #-GT 6] & Exit 1 # exit if the number of parameters is greater than 6
Echo "processing ing for $ {board_name} board..." # We should be familiar with this sentence. When you execute make smdk2410_config, the statement will be displayed in detail.
#
# Create link to architecture specific Headers
# Generate a header file with links pointing to a specific architecture
If ["$ srctree "! = "$ Objtree"]; then # If the source code directory is not the target directory, it indicates that we have specified our target directory.
Mkdir-p $ {objtree}/include #. Then, create the $ {objtree}/include directory. Note that this include directory is the include directory under the target storage directory.
Mkdir-p ${objtree}/include2 # create the ${objtree}/include2 directory. The include2 directory is also the include2 directory under the target storage directory.
CD ${objtree}/include2 # Go To The ${objtree}/include2 directory
Rm-f asm # Delete the ASM directory under include2
# Create a soft connection to the corresponding file or folder in the include2 folder, that is, the "first thing" done by the mkconfig script, that is, create a link
Ln-S ${srctree}/include/ASM-$2 ASM # if it is an arm system, then ASM-$2 is ASM-arm (here the value of the $2 position variable is arm)
Lnprefix = ".../../include2/ASM/" # the prefix of the link is ".../../include2/ASM /"
CD ../include # enter the include directory
Rm-rf asm-$2 # Delete the ASM-$2 Directory (ASM-arm at this time)
Rm-f asm # Delete the ASM directory.
Mkdir ASM-$2 # in the $ {srctree}/include directory, recreate the directory ASM-$2
Ln-s ASM-$2 ASM # then create a soft link
Else # If the source code directory is the target storage directory, that is, the target storage directory is not customized.
CD./include # Go To The include directory under the uboot top-level directory
Rm-f asm # Delete the ASM directory
Ln-s ASM-$2 ASM # establish a soft connection ln-s ASM-arm ASM
Fi
Rm-f asm-$2/arch # Delete ASM-arm/Arch
If [-z "$6"-o "$6" = "null"]; then # if the length of the position parameter $6 string is 0 or null
Ln-S $ {lnprefix} arch-$3 ASM-$2/arch # build soft link: ln-s arch-arm920t ASM-arm/arch, Here lnprefix = ".. /.. /include2/ASM /"
Else
Ln-S $ {lnprefix} arch-$6 ASM-$2/arch # Otherwise build soft link: ln-s arch-s3c24x0 ASM-arm/Arch
Fi
If ["$2" = "arm"]; then # If the location parameter $2 is "arm", delete ASM-arm/proc
Rm-f asm-$2/proc
Ln-S $ {lnprefix} proc-armv ASM-$2/proc # Build link $ {lnprefix} proc-armv ASM-arm/proc
Fi
# This is the second thing this script does. Generate the/include/config. mk/configuration file.
# Create include file for make
# Generate the config. m configuration file for make
# The content in include/config. mk is very simple. Several variables are defined:
Echo "arch = $2"> config. mk
Echo "CPU = $3"> config. mk
Echo "board = $4"> config. mk
["$5"] & ["$5 "! = "Null"] & Echo "vendor = $5"> config. mk # If the developer vendor is specified, define it in config. mk: vendor = $5
["$6"] & ["$6 "! = "Null"] & Echo "Soc = $6"> config. MK # If the SoC On-chip system is specified. MK defines it: SOC = $6, Here it should be SOC = s3c24x0
# This is the third thing this script does, including the header file/include/config. h
# Create board specific header file
If ["$ APPEND" = "yes"] # append to existing Config File
Then
Echo> config. h additional
Else
> Config. h # create new config file Reconstruction
Fi
Echo "/* automatically generated-do not edit */"> config. h # You can open the/include/config. h file to see it at a glance.
Echo "# include <configs/$ 1.h>"> config. h
# Append # include <configs/smdk2410.h> to include config. h In the header file.
Exit 0 normal exit
Detailed analysis of mkconfig script configuration file in U-Boot-1.1.6 top-level directory