U-boot root directory mkconfig File learning notes

Source: Internet
Author: User

In compiling the Zedboard u-boot.elf (SSBL), you know the steps to compile U-boot, and U-boot, which uses version 2014.4. Since the zc702 Development Board is now in use, you should compile the u-boot using the following command:

1. Make Zynq_zc70x_config

2. Make


The 1th and 2nd commands will execute the makefile file in the root directory, but the makefile file will determine if the make command is followed by a _config parameter. If you bring it, you will execute the mkconfig-a zynq_zc70x command. Otherwise, the large command that generates the U-boot.bin is executed.


Here Mkconfig did a few things:

1. Get the target board parameters from Boards.cfg and pass the parameters to 8 variables.

2. Do some folder links under/arch/arm/include/asm.

3. Generate Config.mk and Config.h files under the./include/directory.

#!/bin/sh-e

# Script to CreateHeader files and links to configure

# U-boot for aspecific board.

#

# parameters:target Architecture CPU Board [VENDOR] [SOC]

#

# (C) 2002-2013denx software Engineering, Wolfgang Denk <[email protected]>

#

#SPDX-license-identifier:gpl-2.0+

#

Append=no # default:create new config file

Board_name= "" # NAME to print on make output

Targets= ""

Arch= ""

Cpu= ""

Board= ""

Vendor= ""

Soc= ""

Options= ""


# The order we execute is Mkconfig–a zynq_zc70x, so $ #值为2, value is-A, the following conditions meet

if [\ ($#-eq 2\)-a \ ("$" = "-a" \)]; Then

# Automatic Mode

Line= ' awk ' ($!~/^#/&& $7 ~/^ ' "$ $" ' $/') {print $, $ $, $ $, $4, $ $, $6, $7, $8} ' $srctree/boards.cfg ' # Find the zynq_zc70x corresponding line in the board.cfg and pay the entire line value .

If [-Z "$line"]; Then #line variable to null indicates that the Target Board information was not found in the Boards.cfg

echo "MAKE: * * * No rule tomake target \ ' $2_config '. Stop. " >&2

Exit 1

Fi

Set ${line} #set用于在脚本内部给出其运行参数, so this time the script run parameter becomes the value of line: Active arm armv7 zynq Xilinx zynq Zy nq_zc70x-


# Add default board name if needed

[$# = 3] && set ${line} ${1}

Fi

# because we didn't pass it on to Mkconfig . any of the options, so while the code in the loop does not work.

While [$#-gt0]; Do

Case "$" in

--) shift; break;;

-a) shift; Append=yes;;

-N) Shift; Board_name= "${7%_config}"; shift;

-T) shift; Targets= "' Echo $ | Sed ' s:_:: G ' ${targets} '; shift;

*) break;;

Esac

Done

# The number of parameters is less 7 or greater than 8 exit, now the parameter is 8 , do not exit

[$#-lt 7]&& exit 1

[$#-gt 8]&& exit 1


#${7%_config} means to remove the _config suffix if $7 ends with the _config suffix. Because now $7=zynq_zc70x, so Config_name is waiting for zynq_zc70x

# Strip alloptions and/or _config suffixes

Config_name= "${7%_config}"

["${board_name}"] | | Board_name= "${7%_config}" #BOARD_NAME为 empty, so at this time board_name is also equal to zynq_zc70x .

Arch= "$" #arch =arm

Cpu= ' echo $ | awk ' BEGIN {FS = ': '}; {print '} ' #cpu =armv7

Spl_cpu= ' echo $ |awk ' BEGIN {FS = ': '}; {print $} ' #spl_cpu =armv7

If ["$cpu" = "-"]; Then

cpu=

Fi

["$6"! = "-"] && board= "$6" #board =zynq

["$ $" = "-"] && vendor= "$" #vendor =xilinx

["$4"! = "-"] && soc= "$4" #soc =zynq

#$8 to be "-" , do not execute code

[$#-gt 7]&& ["$8"! = "-"] && {

# Check if we have a board config name inthe options field

# The Options Field Mave has a boardconfig name and a list

# of options, both separated by a colon (': '); The options are

# Separated by commas (', ').

#

# Check for Board name

tmp= "${8%:*}"

If ["$tmp"]; Then

Config_name= "$tmp"

Fi

# Check If we have a colon ...

if ["${tmp}"! = "$8"]; Then

options=${8#*:}

Targets= "' Echo ${options} |sed ' s:,:: G ' ${targets}"

Fi

}

#如果ARCH已经有值了, then test whether arch and arch match. (Arch is now arch)

if ["${arch}"-A "${arch}"! = "${arch}"; Then

echo "Failed: \ $ARCH =${arch}, shouldbe ' ${arch} ' for ${board_name}" 1>&2

Exit 1

Fi

#

# Test aboveneeded aarch64, now we need arm

#

if ["${arch}" = "aarch64"]; Then

Arch= "Arm"

Fi


# at this Options is empty, so the output configuringfor zynq_zc70x Board ...

If ["$options"]; Then

echo "Configuring for ${board_name}-BOARD: ${config_name}, Options: ${options}"

Else

echo "Configuring for ${board_name}board ..."

Fi

#以下操作主要是创建一些文件夹链接

#KBUILD_SRC, the path values for Objtree and Srctree are performed in Makefile mkconfig-a zynq_zc70x Command was set before.

#kbuild_src is empty,Objtree, Srctree is the root directory path

#

# Create link Toarchitecture Specific headers

#

If [-N "$KBUILD _src"]; Then #KBUILd_src is empty, so go to the Else statement

Mkdir-p ${objtree}/include

lnprefix=${srctree}/arch/${arch}/include/asm/

CD ${objtree}/include

Mkdir-p ASM

Else

CD arch/${arch}/include #进入./arch/arm/include directory

Fi

Rm-f asm/arch #直接删除当前目录下asm/arch directory

if ["${soc}"]; Then #soc为zynq, enter the IF branch

Ln-s ${lnprefix}arch-${soc} asm/arch #将asm/arch link to arch-zynq directory, lnprefix= ""

elif ["${cpu}"]; Then

Ln-s ${LNPREFIX}ARCH-${CPU} asm/arch

Fi

If [-Z "$KBUILD _src"]; Then #KBUILD_SRC Empty, go to the root directory under the include directory

CD ${srctree}/include

Fi

#

# Create Includefile for Make

###################################################

After executing the following code, create the Config.mk file in the root include directory and write:

ARCH = Arm

CPU = ARMv7

BOARD = Zynq

VENDOR =xilinx

SOC = Zynq

###################################################

(echo "ARCH = ${arch}"

if [!-Z "$SPL _cpu"]; Then

Echo ' Ifeq ($ (config_spl_build), y) '

echo "CPU = ${spl_cpu}"

echo "Else"

echo "CPU = ${cpu}"

echo "EndIf"

Else

echo "CPU = ${cpu}"

Fi

echo "BOARD = ${board}"

["${vendor}"] && echo "vendor = ${vendor}"

["${soc}"] && echo "SOC = ${soc}"

Exit 0) >config.mk

# Assign boarddirectory to Boardir variable

If [-Z "${vendor}"]; Then #vendor不为空, go to the Else branch

Boarddir=${board}

Else

Boarddir=${vendor}/${board} #BOARDDIR =xilinx/zynq

Fi

#

# Create boardspecific Header file

#####################################################

after executing the following code, in the root directory include created under directory config.h file and write:

/*automatically generated-do not edit */

#defineCONFIG_SYS_ARCH "Arm"

#define CONFIG_SYS_CPU "ARMv7"

#defineCONFIG_SYS_BOARD "Zynq"

#defineCONFIG_SYS_VENDOR "Xilinx"

#defineCONFIG_SYS_SOC "Zynq"

#defineCONFIG_BOARDDIR Board/xilinx/zynq

#include <config_cmd_defaults.h>

#include <config_defaults.h>

#include <configs/zynq_zc70x.h>

#include <asm/config.h>

#include <config_fallbacks.h>

#include <config_uncmd_spl.h>

#####################################################

If ["$APPEND" = "yes"] #Append to existing config file

Then

Echo >> config.h

Else

> config.h # Create new config file

Fi

echo "/*automatically generated-do not edit */" >>config.h

For I in${targets}; Do

I= "' Echo ${i} | Sed '/=/{s/=//;q;}; {s/$/1/;} ' `"

echo "#define CONFIG_${I}" >>CONFIG.H;

Done

echo "#defineCONFIG_SYS_ARCH \" ${arch}\ "" >> config.h

echo "#defineCONFIG_SYS_CPU \" ${cpu}\ "" >> config.h

echo "#defineCONFIG_SYS_BOARD \" ${board}\ "" >> config.h

["${vendor}"] && echo "#define config_sys_vendor\" ${vendor}\ ">> config.h

["${soc}"] && echo "#define CONFIG_SYS_SOC \" ${soc}\ ">> config.h

["${board}"] && echo "#define CONFIG_BOARDDIR board/$BOARDDIR" >> config.h

#将输入的内容追加到config. h until an identity such as "EOF" appears.

Cat << eof>> Config.h

#include <config_cmd_defaults.h>

#include <config_defaults.h>

#include <configs/${CONFIG_NAME}.h>

#include <asm/config.h>

#include <config_fallbacks.h>

#include <config_uncmd_spl.h>

Eof

Exit 0

U-boot root directory mkconfig File learning notes

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.