Reprinted please indicate the source: http://blog.csdn.net/shiyi_2012/article/details/7420459
You can find a uboot source code.
First, go to the top-level makefile. There are many different board configurations, such:
Gec2440_config: unconfig
@ $ (Mkconfig) $ (@: _ Config =) arm ARM920T gec2440 Samsung s3c24x0
1. The first step to configure and compile uboot is make ***** _ config. Since it is make, you have to execute makefile. Makefile includes many of the above statements, make ***** _ config. the first execution is the above configuration information. @ $ (Mkconfig) is defined before makefile. @ $ (mkconfig): =
$ (Srctree)/mkconfig, that is, the mkconfig file in the root directory. $ (@: _ Config =) means make ***** _ config's _ config to go. Therefore, gec2440_config executes./mkconfig gec2440 arm
ARM920T gec2440 Samsung s3c24x0. The role of unconfig is to remove the original configuration information, that is, the reciprocal relationship between make *** _ config and make unconfig.
2. OK. Now execute make gec2440_config, the following will appear:
Grouping ing for gec2440 board...
Now let's take a look at the changes. Because the above command is equivalent to executing./mkconfig arm
ARM920T gec2440 Samsung s3c24x0. So go to the mkconfig file in the root directory first.
First, make it clear :. /mkconfig gec2440 arm ARM920T gec2440 Samsung s3c24x0 makes $0 =. /mkconfig, $1 = arm, $2 = ARM920T, $3 = gec2440, $4 = Samsung, $5 = s3c24x0
The content of mkconfig is as follows:
Append = No # Remember that the initial value of append is no
Board_name = ""
Targets = ""
# The following code is not executed (while --- done), because./mkconfig arm ARM920T gec2440 Samsung s3c24x0 does not --,-a,-N,-T
While [$ #-GT 0]; do
Case "$1" in
--) Shift; break ;;
-A) shift; append = yes ;;
-N) shift; board_name = "$ {1% % _ config}"; shift ;;
-T) shift; targets = "'echo $1 | SED's: _: g'' $ {targets}"; shift ;;
*) Break ;;
Esac
Done
["$ {Board_name}"] | board_name = "$1" // board_name = gec2440
[$ #-Lt 4] & Exit 1
[$ #-GT 6] & Exit 1
If ["$ {arch}"-a "$ {arch }"! = "$2"]; then
Echo "failed: \ $ arch =$ {arch}, shocould be '$ 2' for $ {board_name}" 1> & 2
Exit 1
Fi
// Print the config for gec2440 board on the terminal ....
Echo "grouping ing for $ {board_name} board ..."
#
# Generate a link file
#
If ["$ srctree "! = "$ Objtree"]; then // whether to compile uboot in the source code directory. If not, run the following command. Else indicates that uboot is compiled in the source code directory.
Mkdir-p $ {objtree}/include
Mkdir-p ${objtree}/include2
CD ${objtree}/include2
Rm-F ASM
Ln-S ${srctree}/include/ASM-$2 ASM
Lnprefix = ".../../include2/ASM /"
CD ../include
Rm-rf asm-$2
Rm-F ASM
Mkdir ASM-$2
Ln-s ASM-$2 ASM
Else
CD./include // enter include
Rm-F ASM
Ln-s ASM-$2 ASM // ln-s include/ASM-arm ASM
Fi
Rm-f asm-$2/arch // Delete include/ASM-arm/Arch
If [-z "$6"-o "$6" = "null"]; then // because $6 = s3c24x0, run
Ln-S $ {lnprefix} arch-$3 ASM-$2/Arch
Else
Ln-S $ {lnprefix} arch-$6 ASM-$2/arch // ln-s include/arch-s3c24x0 include/ASM-arm/Arch
Fi
If ["$2" = "arm"]; then
Rm-f asm-$2/proc // Delete include/ASM-arm/proc
Ln-S $ {lnprefix} proc-armv ASM-$2/proc // ln-s include/proc-arm ASM-arm/Pro
Fi
#
# Create include file for make
#
Echo "arch = $2"> config. mk/arch = arm, put include/config. mk
Echo "CPU = $3"> config. mk // CPU = ARM920T, put includde/config. mk
Echo "board = $4"> config. mk // board = gec2440, put it in include/config. mk
["$5"] & ["$5 "! = "Null"] & Echo "vendor = $5"> config. mk
// Verdor = samaung, put include/config. mk
["$6"] & ["$6 "! = "Null"] & Echo "Soc = $6"> config. mk
// SOC = s3c24x0, put it in include/config. mk
#
# Create board specific header file
#
If ["$ APPEND" = "yes"] # The first line knows, append = No
Then
Echo> config. h
Else
> Config. h
# Generate the config. h file, which is located in the include directory
Echo "/* automatically generated-do not edit */"> config. h
For I in $ {targets}; do
Echo "# define config_mk _ $ {I} 1"> config. h;
// Add "# define config_mk _ $ {I} 1 to the generated config. h file
Done
Echo "# include <configs/$ 1.h>"> config. h // config. h file contains the header file "# include <configs/gec2440.h>
Echo "# include <ASM/config. h>"> config. h // config. h file contains the header file "# include <ASM/config. h>
Exit 0
3. The red part above is the changed part. Let's look at the source code in reality,
After you execute make gec2440_config, go to the source code.
The first is that arch, CPU, board, verdor, and SOC are assigned values,
And add it to the include/config. mk file,
The content of my config. mk file is as follows:
Arch = arm
CPU = ARM920T
Board = gec2440
Vendor = Samsung
SOC = s3c24x0
The second is to take a look at the link file. My situation is as follows:
Go to the include directory:
# Ll
Lrwxrwxrwx 1 Root 7 04-01 21:36 ASM-> ASM-arm
Go to the include/ASM-arm directory:
Lrwxrwxrwx 1 Root 12 04-01 arch-> arch-s3c24x0
............
Lrwxrwxrwx 1 Root 9 04-01 21:36 proc-> proc-armv
The third is to generate a new file in the include directory: config. H. contains several header files. My files are:
/* Automatically generated-do not edit */
# Include <configs/gec2440.h>
# Include <ASM/config. h>