zoukankan      html  css  js  c++  java
  • learning armbian steps(10) ----- armbian 源码分析(五)

    在上一节的分析当中,已经知道了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当中

    218 
    219 # optimize build time with 100% CPU usage
    220 CPUS=$(grep -c 'processor' /proc/cpuinfo)
    221 if [[ $USEALLCORES != no ]]; then
    222         CTHREADS="-j$(($CPUS + $CPUS/2))"
    223 else
    224         CTHREADS="-j1"
    225 fi
    226 
    227 start=`date +%s`
    228 

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

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

    接着看lib/main.sh脚本:

    228 
    229 [[ $CLEAN_LEVEL == *sources* ]] && cleaning "sources"
    230 
    231 # ignore updates help on building all images - for internal purposes
    232 # fetch_from_repo <url> <dir> <ref> <subdir_flag>
    233 if [[ $IGNORE_UPDATES != yes ]]; then
    234         display_alert "Downloading sources" "" "info"
    235         fetch_from_repo "$BOOTSOURCE" "$BOOTDIR" "$BOOTBRANCH" "yes"
    236         fetch_from_repo "$KERNELSOURCE" "$KERNELDIR" "$KERNELBRANCH" "yes"
    237         if [[ -n $ATFSOURCE ]]; then
    238                 fetch_from_repo "$ATFSOURCE" "$ATFDIR" "$ATFBRANCH" "yes"
    239         fi
    240         fetch_from_repo "https://github.com/linux-sunxi/sunxi-tools" "sunxi-tools" "branch:master"
    241         fetch_from_repo "https://github.com/rockchip-linux/rkbin" "rkbin-tools" "branch:29mirror"
    242         fetch_from_repo "https://github.com/MarvellEmbeddedProcessors/A3700-utils-marvell" "marvell-tools" "branch:A3700_utils-armada-17.10"
    243         fetch_from_repo "https://github.com/armbian/odroidc2-blobs" "odroidc2-blobs" "branch:master"
    244 fi
    245 
    246 if [[ $BETA == yes ]]; then
    247         IMAGE_TYPE=nightly
    248 elif [[ $BETA != "yes" && $BUILD_ALL == yes && -n $GPG_PASS ]]; then
    249         IMAGE_TYPE=stable
    250 else
    251         IMAGE_TYPE=user-built
    252 fi

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

    cache/sources$ ls -al
    total 60
    drwxrwxr-x 15 root root 4096 1月  25 09:09 .
    drwxrwxr-x  7 root sudo 4096 1月  24 13:11 ..
    drwxrwxr-x  6 root root 4096 1月  25 09:02 armbian-config
    drwxrwxr-x  4 root root 4096 1月  25 09:02 armbian-firmware
    drwxrwxr-x  4 root root 4096 1月  25 09:09 armbian-firmware-full
    drwxrwxr-x 19 root root 4096 1月  25 09:02 armbian-firmware-git
    drwxrwxr-x  4 root root 4096 1月  24 15:45 hostapd-cloudwsn
    drwxrwxr-x  3 root root 4096 1月  25 14:36 linux-am335x
    drwxrwxr-x  8 root root 4096 1月  24 15:08 marvell-tools
    drwxrwxr-x  6 root root 4096 1月  24 15:08 odroidc2-blobs
    drwxrwxr-x  7 root root 4096 1月  24 15:08 rkbin-tools
    drwxrwxr-x  2 root root 4096 1月  25 09:02 rs485-cloudwsn
    drwxrwxr-x  9 root root 4096 1月  25 09:11 rt8188eu
    drwxrwxr-x  7 root root 4096 1月  24 15:08 sunxi-tools
    drwxrwxr-x  3 root root 4096 1月  24 14:59 u-boot-am335x

    继续阅读lib/main.sh

    254 compile_sunxi_tools
    255 install_rkbin_tools

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

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

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

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

    257 BOOTSOURCEDIR=$BOOTDIR/${BOOTBRANCH##*:}
    258 LINUXSOURCEDIR=$KERNELDIR/${KERNELBRANCH##*:}
    259 [[ -n $ATFSOURCE ]] && ATFSOURCEDIR=$ATFDIR/${ATFBRANCH##*:}
    260 
    261 # define package names
    262 DEB_BRANCH=${BRANCH//default}
    263 # if not empty, append hyphen
    264 DEB_BRANCH=${DEB_BRANCH:+${DEB_BRANCH}-}
    265 CHOSEN_UBOOT=linux-u-boot-${DEB_BRANCH}${BOARD}
    266 CHOSEN_KERNEL=linux-image-${DEB_BRANCH}${LINUXFAMILY}
    267 CHOSEN_ROOTFS=linux-${RELEASE}-root-${DEB_BRANCH}${BOARD}
    268 CHOSEN_DESKTOP=armbian-${RELEASE}-desktop
    269 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  

    275 # Compile u-boot if packed .deb does not exist
    276 if [[ ! -f $DEST/debs/${CHOSEN_UBOOT}_${REVISION}_${ARCH}.deb ]]; then
    277         if [[ -n $ATFSOURCE ]]; then
    278                 compile_atf
    279         fi
    280         compile_uboot
    281 fi
    282 
    283 # Compile kernel if packed .deb does not exist
    284 if [[ ! -f $DEST/debs/${CHOSEN_KERNEL}_${REVISION}_${ARCH}.deb ]]; then
    285         compile_kernel
    286 fi

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

    我们先来看一下compile_boot

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

    compile_uboot()。

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

  • 相关阅读:
    微信小程序之----加载中提示框loading
    微信小程序之----消息提示框toast
    微信小程序之----弹框组件modal
    浅析浏览器的回流与重绘 (Reflow & Repaint)
    关于input的一些问题解决方法分享
    关于js中 toFixed()的一个小坑
    浅谈js中null和undefined的区别
    浅谈JS中的闭包
    浅谈JS中的浅拷贝与深拷贝
    css设置居中的方案总结
  • 原文地址:https://www.cnblogs.com/lianghong881018/p/10736818.html
Copyright © 2011-2022 走看看