Description Now uboot has done a lot like the kernel. The main point is that uboot also uses the dtb method to separate the device tree from the code (of course it can be controlled by macros). Project-x/u-boot/configs/TIny210_defconfig CONFIG_OF_CONTROL=y / / is used to indicate whether the use of dtb CONFIG_OF_SEPARATE=y // Whether to separate dtb and uboot So in the uboot compilation, the biggest difference with spl is to compile dtb. (The previous spl we did not use dtb, of course, it seems that you can also use dtb, but I have not tried it). For the mini2440 development board, compiling U-Boot requires executing the following command: $ make mini2440_config $ make all Compile U-Boot with the above command, all the files generated by the compilation are saved in the source code directory. In order to keep the source code directory clean, you can use the following command to output the compiled file to an external directory instead of the source code directory. The following two methods output the compiled file to the /tmp/build directory: $ export BUILD_DIR=/tmp/build $ make mini2440_config $ make all or $ make O=/tmp/build mini2440_config (note the letter O instead of the number 0) $ make all In order to simplify the analysis process and facilitate the reader's understanding, this is mainly for the first compilation method (target output to the source code directory) for analysis. Compile the overall process According to the file description generated by I and 2, the simple process is as follows: (1) Generation of built-in.o in each directory Source file, code file compilation, assembly target file, and built-in target file connected to directory object file (2) u-boot is generated by connecting all the built-in.o with u-boot.lds as the connection script. The built-in target file uses u-boot.lds as the connection script for unified connection u-boot (3) Generate u-boot-nodtb.bin from u-boot U-bootobjcopy action removes the symbol information table u-boot-nodtb.bin (4) by generating uboot dtb file Dts file dtc compile, package dtb file u-boot.dtb (5) Generate u-boot-dtb.bin from u-boot-nodtb.bin and u-boot.dtb U-boot-nodtb.bin and u-boot.dtb add two files u-boot-dtb.bin (6) Copy u-boot.bin from u-boot-dtb.bin U-boot-dtb.bin copy u-boot.bin At the beginning of U-Boot, there are some code related to the host software and hardware environment, which is executed once each time the make command is executed. (1) Define the host system architecture HOSTARCH := $(shell uname -m | \ Sed-e s/i.86/i386/ \ -es/sun4u/sparc64/ \ -es/arm.*/arm/ \ -es/sa110/arm/ \ -es/powerpc/ppc/ \ -es/ppc64/ppc/ \ -es/macppc/ppc/) "sed -e" means followed by a series of command scripts, and the expression "s/abc/def/" means that from the standard input, the content is "abc" and then replaced with "def". The "abc" expression can use "." as a wildcard. The command "uname –m" will output the architecture type of the host CPU. The author's computer uses the CPU of the Intel Core2 series, so "uname–m" outputs "i686". "i686" can match "i.86" in the command "sed -es/i.86/i386/", so the Makefile will be executed on the author's machine and HOSTARCH will be set to "i386". (2) Define the host operating system type HOSTOS := $(shell uname -s | tr'[:upper:]' '[:lower:]' | \ Sed -e 's/cygwin.*/cygwin/') "uname –s" outputs the host kernel name. The author uses the Linux distribution Ubuntu 9.10, so the result of "uname –s" is "Linux". "tr '[:upper:]' '[:lower:]'" converts all uppercase letters in standard input to lowercase letters in response. So the result of the implementation is to set HOSTOS to "linux". (3) define the shell that executes the shell script # Set shell to bash if possible, otherwisefall back to sh SHELL := $(shell if [ -x" BASH"];thenecho BASH; \ Elseif [ -x /bin/bash ]; then echo /bin/bash; \ Elsecho sh; fi; fi) The effect of "$$BASH" is essentially the generation of the string "$BASH" (the effect of the previous $ sign is to indicate that the second $ is a normal character). If the "$BASH" environment variable is defined in the shell that executes the current Makefile, and the file "$BASH" is an executable file, the value of SHELL is "$BASH". Otherwise, if "/bin/bash" is an executable file, the SHELL value is "/bin/bash". If neither of the above is true, assign "sh" to the SHELL variable. Since the author's machine has a bash shell installed and "$BASH" is defined in the shell default environment variable, SHELL is set to $BASH. (4) Set the compilation output directory Ifdef O Ifeq ("$(origin O)", "command line") BUILD_DIR := $(O) Endif Endif The result of the function $( origin, variable) is a string. The output is determined by the variable variable definition. If the variable is defined on the command line, the origin function returns the value "command line". If the command "exportBUILD_DIR=/tmp/build" is executed on the command line, the "$(origin O)" value is "command line" and the BUILD_DIR is set to "/tmp/build". Ifneq ($(BUILD_DIR),) Saved-output := $(BUILD_DIR) # Attempt to create a output directory. $(shell [ -d ${BUILD_DIR} ] || mkdir -p${BUILD_DIR}) If the directory indicated by ${BUILD_DIR} is not defined, the directory is created. # Verify if it was successful. BUILD_DIR := $(shell cd $(BUILD_DIR)&& /bin/pwd) $(if $(BUILD_DIR),,$(error output directory“$(saved-output)†does not exist)) Endif # ifneq ($(BUILD_DIR),) If $(BUILD_DIR) is empty, it is assigned the current directory path (source code directory). Also check if the $(BUILD_DIR) directory exists. OBJTREE :=$(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) SRCTREE :=$(CURDIR) TOPDIR :=$(SRCTREE) LNDIR :=$(OBJTREE) ... MKCONFIG :=$(SRCTREE)/mkconfig ... Ifneq ($(OBJTREE),$(SRCTREE)) Obj := $(OBJTREE)/ Src := $(SRCTREE)/ Else Obj := Src := Endif The CURDIR variable indicates the current working directory of Make. Since Make currently executes the Makefile in the U-Boot top-level directory, CURDIR is now the U-Boot top-level directory. After executing the above code, SRCTREE, src variable is the top directory of U-Boot code, and OBJTREE, obj variable is the output directory. If BUILD_DIR environment variable is not defined, SRCTREE, src variable and OBJTREE, obj variable are U-Boot Source code directory. MKCONFIG represents the mkconfig script in the U-Boot root directory. Circuit Test Pen ,Electrical Pen Test,Electrical Test Pen,Test Pencil YINTE TOOLS (NINGBO) CO., LTD , https://www.yinte-tools.com
First, uboot compile and generate files