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

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

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行,在后续我们继续分析编译脚本。

learning armbian steps(9) ----- armbian 源码分析(四)的更多相关文章

  1. 使用react全家桶制作博客后台管理系统 网站PWA升级 移动端常见问题处理 循序渐进学.Net Core Web Api开发系列【4】:前端访问WebApi [Abp 源码分析]四、模块配置 [Abp 源码分析]三、依赖注入

    使用react全家桶制作博客后台管理系统   前面的话 笔者在做一个完整的博客上线项目,包括前台.后台.后端接口和服务器配置.本文将详细介绍使用react全家桶制作的博客后台管理系统 概述 该项目是基 ...

  2. ABP源码分析四:Configuration

    核心模块的配置 Configuration是ABP中设计比较巧妙的地方.其通过AbpStartupConfiguration,Castle的依赖注入,Dictionary对象和扩展方法很巧妙的实现了配 ...

  3. ABP源码分析四十:ZERO的Application和Tenant

    ABP的Zero模块以数据库为数据源实现了ABP框架中的tenant management (multi-tenancy), role management, user management, ses ...

  4. ABP源码分析四十一:ZERO的Audit,Setting,Background Job

    AuditLog: 继承自Entity<long>的实体类.封装AuditLog的信息. AuditingStore: 实现了IAuditingStore接口,实现了将AuditLog的信 ...

  5. ABP源码分析四十二:ZERO的身份认证

    ABP Zero模块通过自定义实现Asp.Net Identity完成身份认证功能, 对Asp.Net Identity做了较大幅度的扩展.同时重写了ABP核心模块中的permission功能,以实现 ...

  6. ABP源码分析四十三:ZERO的本地化

    ABP Zero模块扩展了ABP基础框架中的本地化功能,实现了通过数据库管理本地化的功能.其通过数据库保存本地化语言及其资源. ApplicationLanguage:代表本地化语言的实体类.一种语言 ...

  7. ABP源码分析四十四:ZERO的配置

    ABP Zero模块中需要配置的地方主要集中在三块:配置静态的role,配置外部认证源,以及配置本地化语言和资源. UserManagementConfig/IUserManagementConfig ...

  8. ABP源码分析四十五:ABP ZERO中的EntityFramework模块

    AbpZeroDbContext:配置ABP.Zero中定义的entity的Dbset EntityFrameworkModelBuilderExtensions:给PrimitiveProperty ...

  9. ABP源码分析四十六:ABP ZERO中的Ldap模块

    通过AD作为用户认证的数据源.整个管理用户认证逻辑就在LdapAuthenticationSource类中实现. LdapSettingProvider:定义LDAP的setting和提供Defaut ...

  10. ABP源码分析四十七:ABP中的异常处理

    ABP 中异常处理的思路是很清晰的.一共五种类型的异常类. AbpInitializationException用于封装ABP初始化过程中出现的异常,只要抛出AbpInitializationExce ...

随机推荐

  1. python并发编程之多进程(实践篇)

    一 multiprocessing模块介绍 python中的多线程无法利用多核优势,如果想要充分地使用多核CPU的资源,在python中大部分情况需要使用多进程.Python提供了multiproce ...

  2. idea 如何加入插件SonarLint

    idea 如何加入插件SonarLint   IDEA的插件安装有两种方法:一是在线安装:二是离线安装,即将插件的安装包下载以后从本地安装.   一.在线安装的过程:         1.打开IDEA ...

  3. Scrapy里Selectors 四种基础的方法

    在Scrapy里面,Selectors 有四种基础的方法xpath():返回一系列的selectors,每一个select表示一个xpath参数表达式选择的节点css():返回一系列的selector ...

  4. Linux 网络工具netcat(nc)的应用

    NETCAT netcat是Linux常用的网络工具之一,它能通过TCP和UDP在网络中读写数据,通过与其他工具结合和重定向,可以在脚本中以多种方式使用它. netcat所做的就是在两台电脑之间建立链 ...

  5. 【USB】struct usb_device_id 结构体详解

    struct usb_device_id { /* which fields to match against? */ __u16 match_flags; //说明使用哪种匹配方式 /* Used ...

  6. HTTP协议探究(四):TCP和TLS优化

    一 复习与目标 1 复习 简单密码学.对称加密与非对称加密 数字签名.数字证书 SSL/TLS HTTPS = HTTP + SSL/TLS,SSL/TLS为HTTP提供了保密性.完整性和鉴别性 2 ...

  7. 旋转动画(RotateTransform)

    Silverlight的基础动画包括偏移.旋转.缩放.倾斜和翻转动画,这些基础动画毫无疑问是在Silverlight中使用得最多的动画效果,其使用也是非常简单的.相信看过上一篇<偏移动画(Tra ...

  8. WPF DataGrid数据绑定

    <DataGrid Name="date_grid" Grid.Column="0" ItemsSource="{Binding Portinf ...

  9. 【Struts2】 国际化

    一.概述 二.Struts2中国际化: 2.1 问题1 全局 局部 2.2 问题2 2.3 问题3 2.4 问题4 在Action中怎样使用 在JSP页面上怎样使用 一.概述 同一款软件 可以为不同用 ...

  10. shiro系列二、身份验证和授权

    一.身份验证 先来看看身份验证的流程 流程如下: 1.首先调用Subject.login(token)进行登录,其会自动委托给Security Manager,调用之前必须通过SecurityUtil ...