learning armbian steps(11) ----- armbian 源码分析

Posted lianghong881018

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了learning armbian steps(11) ----- armbian 源码分析相关的知识,希望对你有一定的参考价值。

接下来我们来分析一下uboot的编写过程:

从 lib/compilation.sh  89开始阅读:

 89 compile_uboot()
 90 
 91         # not optimal, but extra cleaning before overlayfs_wrapper should keep sources directory clean
 92         if [[ $CLEAN_LEVEL == *make* ]]; then
 93                 display_alert "Cleaning" "$BOOTSOURCEDIR" "info"
 94                 (cd $SRC/cache/sources/$BOOTSOURCEDIR; make clean > /dev/null 2>&1)
 95         fi
 96 
 97         if [[ $USE_OVERLAYFS == yes ]]; then
 98                 local ubootdir=$(overlayfs_wrapper "wrap" "$SRC/cache/sources/$BOOTSOURCEDIR" "u-boot_$LINUXFAMILY_$BRANCH")
 99         else
100                 local ubootdir="$SRC/cache/sources/$BOOTSOURCEDIR"
101         fi
102         cd "$ubootdir"
103 
104         # read uboot version
105         local version=$(grab_version "$ubootdir")
106 
107         display_alert "Compiling u-boot" "$version" "info"
108 
109         local toolchain=$(find_toolchain "$UBOOT_COMPILER" "$UBOOT_USE_GCC")
110         [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "$UBOOT_COMPILERgcc $UBOOT_USE_GCC"
111 
112         display_alert "Compiler version" "$UBOOT_COMPILERgcc $(eval env PATH=$toolchain:$PATH $UBOOT_COMPILERgcc -dumpversion)" "info"

89-112行,主是是进行uboot源代码的目录 cache/sources/u-boot-am335x/ti-u-boot-2017.01 ,获取uboot的版本信息,找到交叉编译工具链,并导出至环境变量当中。

overlayfs_wrapper

grap_version

find_toolchain

这三个shell函数可自动阅读。

 lib/compilation.sh 继续阅读

113 
114         # create directory structure for the .deb package
115         local uboot_name=$CHOSEN_UBOOT_$REVISION_$ARCH
116         rm -rf $SRC/.tmp/$uboot_name
117         mkdir -p $SRC/.tmp/$uboot_name/usr/lib/u-boot,$uboot_name $SRC/.tmp/$uboot_name/DEBIAN
118 

113-118行 创建uboot相关的临时目录。

 

119         # process compilation for one or multiple targets
120         while read -r target; do
121                 local target_make=$(cut -d; -f1 <<< $target)
122                 local target_patchdir=$(cut -d; -f2 <<< $target)
123                 local target_files=$(cut -d; -f3 <<< $target)
124 
125                 display_alert "Checking out sources"
126                 git checkout -f -q HEAD
127 
128                 if [[ $CLEAN_LEVEL == *make* ]]; then
129                         display_alert "Cleaning" "$BOOTSOURCEDIR" "info"
130                         (cd $SRC/cache/sources/$BOOTSOURCEDIR; make clean > /dev/null 2>&1)
131                 fi
132 
133                 advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "$target_patchdir" "$BRANCH" "$LINUXFAMILY-$BOARD-$BRANCH"
134 
135                 # create patch for manual source changes
136                 [[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot"
137 
138                 if [[ -n $ATFSOURCE ]]; then
139                         local atftempdir=$SRC/.tmp/atf-$LINUXFAMILY-$BOARD-$BRANCH
140                         cp -Rv $atftempdir/*.bin .
141                 fi
142 
143                 eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$PATH 144                         ‘make $CTHREADS $BOOTCONFIG CROSS_COMPILE="$CCACHE $UBOOT_COMPILER"‘ 2>&1 145                         $PROGRESS_LOG_TO_FILE:+‘ | tee -a $DEST/debug/compilation.log‘ 146                         $OUTPUT_VERYSILENT:+‘ >/dev/null 2>/dev/null‘
147 
148                 # armbian specifics u-boot settings
149                 [[ -f .config ]] && sed -i ‘s/CONFIG_LOCALVERSION=""/CONFIG_LOCALVERSION="-armbian"/g‘ .config
150                 [[ -f .config ]] && sed -i ‘s/CONFIG_LOCALVERSION_AUTO=.*/# CONFIG_LOCALVERSION_AUTO is not set/g .config
151                 if [[ $BOOTBRANCH == "tag:v2018".* ]]; then
152                         [[ -f .config ]] && sed -i s/^.*CONFIG_ENV_IS_IN_FAT.*/# CONFIG_ENV_IS_IN_FAT is not set/g .config
153                         [[ -f .config ]] && sed -i s/^.*CONFIG_ENV_IS_IN_EXT4.*/CONFIG_ENV_IS_IN_EXT4=y/g .config
154                         [[ -f .config ]] && sed -i s/^.*CONFIG_ENV_IS_IN_MMC.*/# CONFIG_ENV_IS_IN_MMC is not set/g .config
155                         [[ -f .config ]] && sed -i s/^.*CONFIG_ENV_IS_NOWHERE.*/# CONFIG_ENV_IS_NOWHERE is not set/g .config | echo "# CONFIG_ENV_IS_NOWHERE is not set" >> .config
156                         [[ -f .config ]] && echo CONFIG_ENV_EXT4_INTERFACE="mmc" >> .config
157                         [[ -f .config ]] && echo CONFIG_ENV_EXT4_DEVICE_AND_PART="0:auto" >> .config
158                         [[ -f .config ]] && echo CONFIG_ENV_EXT4_FILE="/boot/boot.env" >> .config
159                 fi
160                 [[ -f tools/logos/udoo.bmp ]] && cp $SRC/packages/blobs/splash/udoo.bmp tools/logos/udoo.bmp
161                 touch .scmversion
162 
163                 # $BOOTDELAY can be set in board family config, ensure autoboot can be stopped even if set to 0
164                 [[ $BOOTDELAY == 0 ]] && echo -e "CONFIG_ZERO_BOOTDELAY_CHECK=y" >> .config
165                 [[ -n $BOOTDELAY ]] && sed -i "s/^CONFIG_BOOTDELAY=.*/CONFIG_BOOTDELAY=$BOOTDELAY/" .config || [[ -f .config ]] && echo "CONFIG_BOOTDELAY=$BOOTDELAY" >> .config
166 
167                 eval CCACHE_BASEDIR="$(pwd)" env PATH=$toolchain:$PATH 168                         make $target_make $CTHREADS CROSS_COMPILE="$CCACHE $UBOOT_COMPILER" 2>&1 169                         $PROGRESS_LOG_TO_FILE:+ | tee -a $DEST/debug/compilation.log 170                         $OUTPUT_DIALOG:+ | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." $TTY_Y $TTY_X 171                         $OUTPUT_VERYSILENT:+ >/dev/null 2>/dev/null
172 
173                 [[ $PIPESTATUS[0] -ne 0 ]] && exit_with_error "U-boot compilation failed"
174 
175                 [[ $(type -t uboot_custom_postprocess) == function ]] && uboot_custom_postprocess
176 
177                 # copy files to build directory
178                 for f in $target_files; do
179                         local f_src=$(cut -d: -f1 <<< $f)
180                         if [[ $f == *:* ]]; then
181                                 local f_dst=$(cut -d: -f2 <<< $f)
182                         else
183                                 local f_dst=$(basename $f_src)
184                         fi
185                         [[ ! -f $f_src ]] && exit_with_error "U-boot file not found" "$(basename $f_src)"
186                         cp $f_src $SRC/.tmp/$uboot_name/usr/lib/$uboot_name/$f_dst
187                 done
188         done <<< "$UBOOT_TARGET_MAP"

 

以上是关于learning armbian steps(11) ----- armbian 源码分析的主要内容,如果未能解决你的问题,请参考以下文章

Python - 7 Steps to Mastering Machine Learning With Python

TensorFlow by Google一个计算机视觉示例Machine Learning Foundations: Ep #2 - First steps in computer vision(代码

如何在启动时在 Armbian 上激活虚拟环境?

余弦衰减学习率与linear warmup结合版代码

在 Armbian 上从 i2c 2 读取 BME680

First Steps with TensorFlow代码解析