learning armbian steps(10) ----- armbian 源码分析(五)

2022-11-06,,,,

在上一节的分析当中,已经知道了uboot kernel的源代码路径及编译选项,以及rootfs的版本,相关信息如下所示:

## BUILD CONFIGURATION

Build target:
Board: iotx-3
Branch: default
Desktop: Kernel configuration:
Repository: git://git.ti.com/processor-sdk/processor-sdk-linux.git
Branch: branch:processor-sdk-linux-04.03.00
Config file: linux-cloudwsn-default U-boot configuration:
Repository: git://git.ti.com/ti-u-boot/ti-u-boot.git
Branch: branch:ti-u-boot-2017.01
Config file: am335x_iotx3_config Partitioning configuration:
Root partition type: ext4
Boot partition type: (none)
User provided boot partition size: 0
Offset: 4 CPU configuration:
- with interactive
Displaying message: Downloading sources info
Displaying message: Checking git sources u-boot-am335x ti-u-boot-2017.01 info

 继续回到/ib/mian.sh当中

 # optimize build time with % CPU usage
CPUS=$(grep -c 'processor' /proc/cpuinfo)
if [[ $USEALLCORES != no ]]; then
CTHREADS="-j$(($CPUS + $CPUS/2))"
else
CTHREADS="-j1"
fi start=`date +%s`

219-225行的代码用来判断是否满负荷编译代码

227行,将编译的起始秒数保存至start变量当中。

接着看lib/main.sh脚本:

 [[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"

 # ignore updates help on building all images - for internal purposes
# fetch_from_repo <url> <dir> <ref> <subdir_flag>
if [[ $IGNORE_UPDATES != yes ]]; then
display_alert "Downloading sources" "" "info"
fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"
fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"
if [[ -n $ATFSOURCE ]]; then
fetch_from_repo "$ATFSOURCE" "$ATFDIR" "$ATFBRANCH" "yes"
fi
fetch_from_repo "https://github.com/linux-sunxi/sunxi-tools" "sunxi-tools" "branch:master"
fetch_from_repo "https://github.com/rockchip-linux/rkbin" "rkbin-tools" "branch:29mirror"
fetch_from_repo "https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell" "marvell-tools" "branch:A3700_utils-armada-17.10"
fetch_from_repo "https://github.com/armbian/odroidc2-blobs" "odroidc2-blobs" "branch:master"
fi if [[ $BETA == yes ]]; then
IMAGE_TYPE=nightly
elif [[ $BETA != "yes" && $BUILD_ALL == yes && -n $GPG_PASS ]]; then
IMAGE_TYPE=stable
else
IMAGE_TYPE=user-built
fi

228-252行代码:主要是用于通过git 拉取相关的代码。相关的源代码会保存至caach/sources 目录下面,如下所示, 默认的IMAGE_TYPE=user-built

cache/sources$ ls -al
total
drwxrwxr-x root root 1月 : .
drwxrwxr-x root sudo 1月 : ..
drwxrwxr-x root root 1月 : armbian-config
drwxrwxr-x root root 1月 : armbian-firmware
drwxrwxr-x root root 1月 : armbian-firmware-full
drwxrwxr-x root root 1月 : armbian-firmware-git
drwxrwxr-x root root 1月 : hostapd-cloudwsn
drwxrwxr-x root root 1月 : linux-am335x
drwxrwxr-x root root 1月 : marvell-tools
drwxrwxr-x root root 1月 : odroidc2-blobs
drwxrwxr-x root root 1月 : rkbin-tools
drwxrwxr-x root root 1月 : rs485-cloudwsn
drwxrwxr-x root root 1月 : rt8188eu
drwxrwxr-x root root 1月 : sunxi-tools
drwxrwxr-x root root 1月 : u-boot-am335x

继续阅读lib/main.sh

 compile_sunxi_tools
install_rkbin_tools

这两个工具在自已配置的板子上面是用不到的,所示跳过不分析。

这个跟厂家的镜像打包有关系统,比如rockchip的RK3328 会通过rkbin_tools工具将其uboot kernel rootfs,打包成GPT格式的镜像。

通过dd命令或者通过带校验功能的etcher命令进行烧录。

继续阅读lib/main.sh  257行开始:

 BOOTSOURCEDIR=$BOOTDIR/${BOOTBRANCH##*:}
LINUXSOURCEDIR=$KERNELDIR/${KERNELBRANCH##*:}
[[ -n $ATFSOURCE ]] && ATFSOURCEDIR=$ATFDIR/${ATFBRANCH##*:} # define package names
DEB_BRANCH=${BRANCH//default}
# if not empty, append hyphen
DEB_BRANCH=${DEB_BRANCH:+${DEB_BRANCH}-}
CHOSEN_UBOOT=linux-u-boot-${DEB_BRANCH}${BOARD}
CHOSEN_KERNEL=linux-image-${DEB_BRANCH}${LINUXFAMILY}
CHOSEN_ROOTFS=linux-${RELEASE}-root-${DEB_BRANCH}${BOARD}
CHOSEN_DESKTOP=armbian-${RELEASE}-desktop
CHOSEN_KSRC=linux-source-${BRANCH}-${LINUXFAMILY}

相关的变量如下所示:

BOOTSOURCEDIR=u-boot-am335x/ti-u-boot-2017.01
LINUXSOURCEDIR=linux-am335x/processor-sdk-linux-04.03.00

CHOSE_UBOOT=linux-u-boot-iotx-3
CHOSE_KERNEL=linux-image-cloudwsn
CHOSE_ROOTFS=linux--root-iotx-3
CHOSE_DESKTOP=armbian--desktop
CHOSE_KSRC=linux-source-default-cloudwsn

继续阅读lib/main.sh

 # Compile u-boot if packed .deb does not exist
if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
if [[ -n $ATFSOURCE ]]; then
compile_atf
fi
compile_uboot
fi # Compile kernel if packed .deb does not exist
if [[ ! -f $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
compile_kernel
fi

上述的代码主要是判断uboot kernel 的deb包是否存在,否则的话就通过shell函数 compile_uboot compile_kernel进行编译。

我们先来看一下compile_boot

先跳至在 lib/compilation.sh:当中,里面有compile_uboot的实现,然后再回到/lib/main.sh脚本当中

compile_uboot()。

在下一章节我们会来好好分析compile_uboot的编译过程。

learning armbian steps(10) ----- armbian 源码分析(五)的相关教程结束。

《learning armbian steps(10) ----- armbian 源码分析(五).doc》

下载本文的Word格式文档,以方便收藏与打印。