在上一节的分析当中,我们知道是通过对话框来选择到底编译的是哪块板子,基于什么样的配置。

接下来我们来拿一个实例来分析一下具体的案例,我们会选中如下所示的版本

iotx-3                 AM335X 1Gb SoC eMMC
相当于BOARD=iotx-3 BOARD_TYPE=conf
接下来还是回到lib/main.sh当中
 source $SRC/config/boards/${BOARD}.${BOARD_TYPE}
LINUXFAMILY="${BOARDFAMILY}"

169行 相当于获取$SRC/config/boards/iotx-3.conf 当中设置的变量

170行 相当于设置LINUXFAMILY=cloudwsn,这个和iotx-3.conf内部的配置有关

来看一下iotx-3.conf的内容:

# AM335X 1Gb SoC eMMC
BOARD_NAME="IOTX-3"
BOARDFAMILY="cloudwsn"
BOOTCONFIG="am335x_iotx3_config"
MODULES="hci_uart gpio_sunxi rfcomm hidp bonding spi_sun7i"
MODULES_NEXT="bonding"
#
KERNEL_TARGET="default,dev"
CLI_TARGET="stretch,xenial:next"
DESKTOP_TARGET="xenial:default,next"
#
CLI_BETA_TARGET="" uboot_custom_postprocess() {
local tftpdir="/tftpboot" if [ -f MLO -a -e ${tftpdir} ];then
cp MLO ${tftpdir}/cloudwsn-IOTX3-runtime-uboot.MLO
fi if [ -f u-boot.img -a -e ${tftpdir} ];then
cp u-boot.img ${tftpdir}/cloudwsn-IOTX3-runtime-uboot.img
fi
} BOOTENV_FILE="cloudwsn-default.txt"

第一行板子的具体描述,接下来设置了相关的变量,后续我们会看到这些变量使用的地放。

继续回到lib/main.sh当中

 [[ -z $KERNEL_TARGET ]] && exit_with_error "Board configuration does not define valid kernel config"

172行 说明KERNEL_TARGET 变量是必须存在于iotx-3.conf 文件当中的,如果新增一块板子该变量是必须存在的,否则会报错。

继续阅读lib/main.sh脚本:

 if [[ -z $BRANCH ]]; then
options=()
[[ $KERNEL_TARGET == *default* ]] && options+=("default" "Vendor provided / legacy (3.4.x - 4.4.x)")
[[ $KERNEL_TARGET == *next* ]] && options+=("next" "Mainline (@kernel.org) (4.x)")
[[ $KERNEL_TARGET == *dev* && $EXPERT = yes ]] && options+=("dev" "\Z1Development version (4.x)\Zn")
# do not display selection dialog if only one kernel branch is available
if [[ "${#options[@]}" == ]]; then
BRANCH="${options[0]}"
else
BRANCH=$(dialog --stdout --title "Choose a kernel" --backtitle "$backtitle" --colors \
--menu "Select the target kernel branch\nExact kernel versions depend on selected board" \
$TTY_Y $TTY_X $(($TTY_Y - )) "${options[@]}")
fi
unset options
[[ -z $BRANCH ]] && exit_with_error "No kernel branch selected"
[[ $BRANCH == dev && $SHOW_WARNING == yes ]] && show_developer_warning
else
[[ $KERNEL_TARGET != *$BRANCH* ]] && exit_with_error "Kernel branch not defined for this board" "$BRANCH"
fi

174-192行, 执行的结果就是设置 BRANCH=default

继续阅读lib/main.sh

194 if [[ $KERNEL_ONLY != yes && -z $RELEASE ]]; then
195 options=()
196 options+=("jessie" "Debian 8 Jessie")
197 options+=("stretch" "Debian 9 Stretch")
198 options+=("xenial" "Ubuntu Xenial 16.04 LTS")
199 [[ $EXPERT = yes ]] && options+=("bionic" "Ubuntu Bionic 18.04 LTS")
200 RELEASE=$(dialog --stdout --title "Choose a release" --backtitle "$backtitle" --menu "Select the target OS release" \
201 $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
202 unset options
203 [[ -z $RELEASE ]] && exit_with_error "No release selected"
204 fi
205
206 if [[ $KERNEL_ONLY != yes && -z $BUILD_DESKTOP ]]; then
207 options=()
208 options+=("no" "Image with console interface (server)")
209 options+=("yes" "Image with desktop environment")
210 BUILD_DESKTOP=$(dialog --stdout --title "Choose image type" --backtitle "$backtitle" --no-tags --menu "Select the target image type" \
211 $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
212 unset options
213 [[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"
214 fi
215

194-204行会弹出如下内容,在这里选择rootfs发行版本,在这里假设我们选择xenial , 即设置RELEASE=xenial,该变量会在后续被使用

 jessie   Debian  Jessie

 stretch  Debian  Stretch

 xenial   Ubuntu Xenial 16.04 LTS 

206-215行 会弹出选择的发行版本,是否带桌面功能的版本,在这里我们选择Image with console interface, 即设置BUILD_DESKTOP=no,该变量会在后续被使用。

Image with console interface (server) 

Image with desktop environment

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

 source $SRC/lib/configuration.sh

这里面的内容很多,我们来具体分析一下该脚本到底做了什么事情,对于新增一块板子也是有帮助的。

我们先跳到$SRC/lib/configuration.sh,,分析完了之后,再回到lib/main.sh

整个的configuration.sh,最终的目地就是获取uboot/kernel 的 git repository和branch 及对应的配置以便于后续的编译。

主功的功能有:

设置主机名

HOST=iotx

设置其初始密码

BOOTPWD=1234

设置其文件系统格式

ROOTFS_TYPE=ext4

设置其时区

TZDATA=Asia/Shanghan

设置其版本REVISION

REVISION=5.59

设置如下相关的变量

UBOOT_USE_GCC=> 5.0
KERNEL_USE_GCC=> 5.0
ARCH=armhf

QEMU_BINARY=qemu-arm-static    // 该变量会用于本地挂载arm rootfs当中
ARCHITECTURE=arm
KERNEL_COMPILER=arm-linux-gnueabihf-
UBOOT_COMPILER=arm-linux-gnueabihf-
INITRD_ARCH=arm
BOOTCONFIG_VAR_NAME=BOOTCONFIG_DEFAULT
BOOTCONFIG=am335x_iotx3_config    // uboot configure
LINUXCONFIG=linux-cloudwsn-default  //  kernel configure
BOOTPATCHDIR=u-boot-cloudwsn
KERNELPATCHDIR=cloudwsn-default
DISTRUBUTION=Ubuntu

在其output/debug/output.log  可以找到如下信息

## BUILD CONFIGURATION

Build target:
Board: iotx-
Branch: default
Desktop: Kernel configuration:
Repository: git://git.ti.com/processor-sdk/processor-sdk-linux.git
Branch: branch:processor-sdk-linux-04.03.
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:
Offset: CPU configuration:
- with interactive
Displaying message: Downloading sources info
Displaying message: Checking git sources u-boot-am335x ti-u-boot-2017.01 info

我们再次总结一下当前变量的值:

BOARD=iotx-3

BRANCH=default

BUILD_DESKTOP=no

KERNELSOURCE=git://git.ti.com/processor-sdk/processor-sdk-linux.git

KERNELBRANCH=branch:processor-sdk-linux-04.03.00

LINUXCONFIG=linux-cloudwsn-default

有了如上变量就可以用来编译kernel,加上KERNEL_COMPILER KERNEL_USE_GCC

如下是uboot相关的变量

BOOTSOURCE=git://git.ti.com/ti-u-boot/ti-u-boot.git
BOOTBRANCH=branch:ti-u-boot-2017.01
BOOTCONFIG=am335x_iotx3_config

ROOTFS_TYPE=ext4
BOOTSIZE=0
OFFSET=4

经过上面的初始化之后,接下来就是要开始编译uboot kernel,及构建rootfs.打包镜像。

我们回到 lib/main.sh  216行,在后续我们继续分析编译脚本。

最新文章

  1. Jquery.load() 使用
  2. android 手机屏幕有关的几个工具(屏幕宽高,dp和px互相转换)
  3. [转载]Eclipse调试Java的10个技巧
  4. 快速排序 - C语言
  5. NGUI 使用UITable(或UIGrid)注意事项
  6. 部署新浪SAE web.py Session及图片上传等问题注意事项
  7. 【原】Hadoop伪分布模式的安装
  8. [Effective C++ --014]在资源管理类中小心copying行为
  9. 【转载】最近在用Arrays的asList()生成的List时,List元素的个数时而不正确,数组转化为List,即Arrays.asList(intArray);
  10. HDU1632+半平面交
  11. Ubuntu----1
  12. USB device & USB controller & USB passthrough
  13. AFNetworking GET和POST请求
  14. 第23章 访问者模式(Visitor Pattern)
  15. centos 下 安装mysql
  16. Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3) C. Playing Piano
  17. jmeter遇到问题及解决办法
  18. 三、K8S成功
  19. event & signals & threads
  20. curl发送xml , xml和数组互转

热门文章

  1. PHP内存管理-zendMM
  2. spark异常篇-OutOfMemory:GC overhead limit exceeded
  3. 编写函数模拟strcpy()函数功能
  4. linux 对外开放端口
  5. 怎样快捷获取网页的window对象
  6. RestShrap Simple REST and HTTP Client for .NET 了解
  7. Vim 添加vimgdb支持
  8. 【原创】大叔经验分享(80)openresty(nginx+lua)发邮件
  9. luogu P3773 [CTSC2017]吉夫特
  10. 12.Show Profile