learning armbian steps(8) ----- armbian 源码分析(三)

怎甘沉沦 提交于 2021-01-02 15:18:51

在lib/main.sh当中

13 if [[ $(basename $0) == main.sh ]]; then
 14         echo "Please use compile.sh to start the build process"
 15         exit -1
 16 fi
 17 
 18 # default umask for root is 022 so parent directories won't be group writeable without this
 19 # this is used instead of making the chmod in prepare_host() recursive
 20 umask 002
 21 
 22 # destination
 23 DEST=$SRC/output
 24 
 25 TTY_X=$(($(stty size | awk '{print $2}')-6)) # determine terminal width
 26 TTY_Y=$(($(stty size | awk '{print $1}')-6)) # determine terminal height
 27

13-16行,由于 main.sh脚本的执行需要在compile.sh内 被调用,不可以直接通过lib/main.sh,在上一节当中我们总结了compile.sh的功能。

23行,设置最终镜像默认的输出目录

25-25行,主要是后面会使用dialog命令做人机交互时,用来设置对话框的大小。TTY_X TTY_Y会根据终端的变化而变化。

在lib/main.sh当中

28 # We'll use this title on all menus
 29 backtitle="Armbian building script, http://www.armbian.com | Author: Igor Pecovnik"
 30 
 31 # if language not set, set to english
 32 [[ -z $LANGUAGE ]] && export LANGUAGE="en_US:en"
 33 
 34 # default console if not set
 35 [[ -z $CONSOLE_CHAR ]] && export CONSOLE_CHAR="UTF-8"
 36 
 37 [[ -z $FORCE_CHECKOUT ]] && FORCE_CHECKOUT=yes
 38

29行,用来设置对话框的标题

32行,用来设置LANGUAGE

35行,用来设置终端的输出字符集

37行,用来设置变量FORCE_CHECKOUT,后面拉取代码时会用到,在lib/generate.sh脚本,在fetch_from_repo() 钩子函数当中会用到,如下所示:

261 # working directory is not clean
262 if [[ $FORCE_CHECKOUT == yes ]]; then
263      display_alert "Checking out"
264      git checkout -f -q HEAD

 继续回到lib/mian.sh当中,如下所示:加载相关的脚本函数,在后面的编译过程当中会用到,里面的内容比较多,我们在调用到的时候再进行详细分析

39 # Load libraries
 40 source $SRC/lib/debootstrap-ng.sh                       # System specific install
 41 source $SRC/lib/image-helpers.sh                        # helpers for OS image building
 42 source $SRC/lib/distributions.sh                        # System specific install
 43 source $SRC/lib/desktop.sh                                      # Desktop specific install
 44 source $SRC/lib/compilation.sh                          # Patching and compilation of kernel, uboot, ATF
 45 source $SRC/lib/makeboarddeb.sh                         # Create board support package
 46 source $SRC/lib/general.sh                              # General functions
 47 source $SRC/lib/chroot-buildpackages.sh                 # Building packages in chroot

 

继续阅读lib/main.sh

49 # compress and remove old logs
50 mkdir -p $DEST/debug
51 (cd $DEST/debug && tar -czf logs-$(<timestamp).tgz *.log) > /dev/null 2>&1
52 rm -f $DEST/debug/*.log > /dev/null 2>&1
53 date +"%d_%m_%Y-%H_%M_%S" > $DEST/debug/timestamp
54 # delete compressed logs older than 7 days
55 (cd $DEST/debug && find . -name '*.tgz' -mtime +7 -delete) > /dev/null
56 
57 if [[ $PROGRESS_DISPLAY == none ]]; then
58 OUTPUT_VERYSILENT=yes
59 elif [[ $PROGRESS_DISPLAY == dialog ]]; then
60 OUTPUT_DIALOG=yes
61 fi
62 if [[ $PROGRESS_LOG_TO_FILE != yes ]]; then unset PROGRESS_LOG_TO_FILE; fi
63 
64 SHOW_WARNING=yes
65 
66 if [[ $USE_CCACHE != no ]]; then
67 CCACHE=ccache
68 export PATH="/usr/lib/ccache:$PATH"
69 # private ccache directory to avoid permission issues when using build script with "sudo"
70 # see https://ccache.samba.org/manual.html#_sharing_a_cache for alternative solution
71 [[ $PRIVATE_CCACHE == yes ]] && export CCACHE_DIR=$SRC/cache/ccache
72 else
73 CCACHE=""
74 fi

49-56行,主要是对之前的log文件进行压缩,并删除超过7天的log.

57-62行,由于之前的PROGRESS_DISPLAY  PROGRESS_LOG_TO_FILE 都没有设置,流程不会被执行。

64行, 设置SHOW_WARNING=yes

66-71行,由于在config-default.conf当中, USE_CCACHE没有被默认设置,67 68 这两行会被执行

在lib/main.sh当中会调用到prepare_host,

76 # Check and install dependencies, directory structure and settings
 77 prepare_host

 该脚本函数在lib/general.sh, 第501行当中有定义,我们来看一下实现

495 # prepare_host
496 #
497 # * checks and installs necessary packages
498 # * creates directory structure
499 # * changes system settings
500 #
501 prepare_host()
502 {
503         display_alert "Preparing" "host" "info"
504 
505         if [[ $(dpkg --print-architecture) != amd64 ]]; then
506                 display_alert "Please read documentation to set up proper compilation environment"
507                 display_alert "http://www.armbian.com/using-armbian-tools/"
508                 exit_with_error "Running this tool on non x86-x64 build host in not supported"
509         fi
510 
511         # exit if package manager is running in the back
512         while true; do
513                 fuser -s /var/lib/dpkg/lock
514                 if [[ $? = 0 ]]; then
515                                 display_alert "Package manager is running in the background." "retrying in 30 sec" "wrn"
516                                 sleep 30
517                         else
518                                 break
519                 fi
520         done
521 
522         # need lsb_release to decide what to install
523         if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' lsb-release 2>/dev/null) != *ii* ]]; then
524                 display_alert "Installing package" "lsb-release"
525                 apt -q update && apt install -q -y --no-install-recommends lsb-release
526         fi
527 
528         # packages list for host
529         # NOTE: please sync any changes here with the Dockerfile and Vagrantfile
530         local hostdeps="wget ca-certificates device-tree-compiler pv bc lzop zip binfmt-support build-essential ccache debootstrap ntpdate \
531         gawk gcc-arm-linux-gnueabihf qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev fakeroot \
532         parted pkg-config libncurses5-dev whiptail debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl rsync libssl-dev \
533         nfs-kernel-server btrfs-tools ncurses-term p7zip-full kmod dosfstools libc6-dev-armhf-cross \
534         curl patchutils python liblz4-tool libpython2.7-dev linux-base swig libpython-dev aptly acl \
535         locales ncurses-base pixz dialog systemd-container udev lib32stdc++6 libc6-i386 lib32ncurses5 lib32tinfo5 \
536         bison libbison-dev flex libfl-dev"
537 
538         local codename=$(lsb_release -sc)
539         display_alert "Build host OS release" "${codename:-(unknown)}" "info"
540 
541         # Ubuntu Xenial x86_64 is the only fully supported host OS release
542         # Ubuntu Bionic x86_64 support is WIP, especially for building full images and additional packages
543         # Using Docker/VirtualBox/Vagrant is the only supported way to run the build script on other Linux distributions
544         #
545         # NO_HOST_RELEASE_CHECK overrides the check for a supported host system
546         # Disable host OS check at your own risk, any issues reported with unsupported releases will be closed without a discussion
547         if [[ -z $codename || "xenial bionic" != *"$codename"* ]]; then
548                 if [[ $NO_HOST_RELEASE_CHECK == yes ]]; then
549                         display_alert "You are running on an unsupported system" "${codename:-(unknown)}" "wrn"
550                         display_alert "Do not report any errors, warnings or other issues encountered beyond this point" "" "wrn"
551                 else
552                         exit_with_error "It seems you ignore documentation and run an unsupported build system: ${codename:-(unknown)}"
553                 fi
554         fi
555 
556         if grep -qE "(Microsoft|WSL)" /proc/version; then
557                 exit_with_error "Windows subsystem for Linux is not a supported build environment"
558         fi
559 
560         grep -q i386 <(dpkg --print-foreign-architectures) || dpkg --add-architecture i386
561         if systemd-detect-virt -q -c; then
562                 display_alert "Running in container" "$(systemd-detect-virt)" "info"
563                 # disable apt-cacher unless NO_APT_CACHER=no is not specified explicitly
564                 if [[ $NO_APT_CACHER != no ]]; then
565                         display_alert "apt-cacher is disabled in containers, set NO_APT_CACHER=no to override" "" "wrn"
566                         NO_APT_CACHER=yes
567                 fi
568                 CONTAINER_COMPAT=yes
569                 # trying to use nested containers is not a good idea, so don't permit EXTERNAL_NEW=compile
570                 if [[ $EXTERNAL_NEW == compile ]]; then
571                         display_alert "EXTERNAL_NEW=compile is not available when running in container, setting to prebuilt" "" "wrn"
572                         EXTERNAL_NEW=prebuilt
573                 fi
574                 SYNC_CLOCK=no
575         fi
576 
577         # warning: apt-cacher-ng will fail if installed and used both on host and in container/chroot environment with shared network
578         # set NO_APT_CACHER=yes to prevent installation errors in such case
579         if [[ $NO_APT_CACHER != yes ]]; then hostdeps="$hostdeps apt-cacher-ng"; fi
580 
581         local deps=()
582         local installed=$(dpkg-query -W -f '${db:Status-Abbrev}|${binary:Package}\n' '*' 2>/dev/null | grep '^ii' | awk -F '|' '{print $2}' | cut -d ':' -f 1)
583 
584         for packet in $hostdeps; do
585                 if ! grep -q -x -e "$packet" <<< "$installed"; then deps+=("$packet"); fi
586         done
587 
588         # distribution packages are buggy, download from author
589         if [[ ! -f /etc/apt/sources.list.d/aptly.list ]]; then
590                 display_alert "Updating from external repository" "aptly" "info"
591                 apt-key adv --keyserver pool.sks-keyservers.net --recv-keys ED75B5A4483DA07C >/dev/null 2>&1
592                 echo "deb http://repo.aptly.info/ squeeze main" > /etc/apt/sources.list.d/aptly.list
593         fi
594 
595         if [[ ${#deps[@]} -gt 0 ]]; then
596                 display_alert "Installing build dependencies"
597                 apt -q update
598                 apt -y upgrade
599                 apt -q -y --no-install-recommends install "${deps[@]}" | tee -a $DEST/debug/hostdeps.log
600                 update-ccache-symlinks
601         fi
602 
603         # Temorally broken in Bionic, reverting to prvious version
604         # https://github.com/aptly-dev/aptly/issues/740
605         if [[ $(dpkg -s aptly | grep '^Version:' | sed 's/Version: //') != "1.2.0" && "$codename" == "bionic" ]]; then
606                 apt -qq -y --allow-downgrades install aptly=1.2.0
607         fi
608 
609         # sync clock
610         if [[ $SYNC_CLOCK != no ]]; then
611                 display_alert "Syncing clock" "host" "info"
612                 ntpdate -s ${NTP_SERVER:- time.ijs.si}
613         fi
614 
615         if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' 'zlib1g:i386' 2>/dev/null) != *ii* ]]; then
616                 apt install -qq -y --no-install-recommends zlib1g:i386 >/dev/null 2>&1
617         fi
618 
619         # enable arm binary format so that the cross-architecture chroot environment will work
620         if [[ $KERNEL_ONLY != yes ]]; then
621                 modprobe -q binfmt_misc
622                 mountpoint -q /proc/sys/fs/binfmt_misc/ || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
623                 test -e /proc/sys/fs/binfmt_misc/qemu-arm || update-binfmts --enable qemu-arm
624                 test -e /proc/sys/fs/binfmt_misc/qemu-aarch64 || update-binfmts --enable qemu-aarch64
625         fi
626 
627         # create directory structure
628         mkdir -p $SRC/{cache,output,userpatches}
629         if [[ -n $SUDO_USER ]]; then
630                 chgrp --quiet sudo cache output userpatches
631                 # SGID bit on cache/sources breaks kernel dpkg packaging
632                 chmod --quiet g+w,g+s output userpatches
633                 # fix existing permissions
634                 find $SRC/output $SRC/userpatches -type d ! -group sudo -exec chgrp --quiet sudo {} \;
635                 find $SRC/output $SRC/userpatches -type d ! -perm -g+w,g+s -exec chmod --quiet g+w,g+s {} \;
636         fi
637         mkdir -p $DEST/debs/extra $DEST/{config,debug,patch} $SRC/userpatches/overlay $SRC/cache/{sources,toolchains,utility,rootfs} $SRC/.tmp
638 
639         find $SRC/patch -type d ! -name . | sed "s%/patch%/userpatches%" | xargs mkdir -p
640 
641         # download external Linaro compiler and missing special dependencies since they are needed for certain sources
642 
643         # Use backup server by default to balance the load
644 
645         ARMBIANSERVER=dl.armbian.com
646 
647         local toolchains=(
648                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz"
649                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-4.9.4-2017.01-x86_64_aarch64-linux-gnu.tar.xz"
650                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi.tar.xz"
651                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz"
652                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu.tar.xz"
653                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabi.tar.xz"
654                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf.tar.xz"
655                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz"
656                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-6.4.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz"
657                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz"
658                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz"
659                 "https://${ARMBIANSERVER}/_toolchains/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi.tar.xz"
660                 )
661 
662         for toolchain in ${toolchains[@]}; do
663                 download_toolchain "$toolchain"
664         done
665 
666         rm -rf $SRC/cache/toolchains/*.tar.xz $SRC/cache/toolchains/*.tar.xz.asc
667         local existing_dirs=( $(ls -1 $SRC/cache/toolchains) )
668         for dir in ${existing_dirs[@]}; do
669                 local found=no
670                 for toolchain in ${toolchains[@]}; do
671                         local filename=${toolchain##*/}
672                         local dirname=${filename//.tar.xz}
673                         [[ $dir == $dirname ]] && found=yes
674                 done
675                 if [[ $found == no ]]; then
676                         display_alert "Removing obsolete toolchain" "$dir"
677                         rm -rf $SRC/cache/toolchains/$dir
678                 fi
679         done
680 
681         # download etcher CLI utility
682         download_etcher_cli
683 
684         [[ ! -f $SRC/userpatches/customize-image.sh ]] && cp $SRC/config/templates/customize-image.sh.template $SRC/userpatches/customize-image.sh
685 
686         if [[ ! -f $SRC/userpatches/README ]]; then
687                 rm -f $SRC/userpatches/readme.txt
688                 echo 'Please read documentation about customizing build configuration' > $SRC/userpatches/README
689                 echo 'http://www.armbian.com/using-armbian-tools/' >> $SRC/userpatches/README
690         fi
691 
692         # check free space (basic)
693         local freespace=$(findmnt --target $SRC -n -o AVAIL -b 2>/dev/null) # in bytes
694         if [[ -n $freespace && $(( $freespace / 1073741824 )) -lt 10 ]]; then
695                 display_alert "Low free space left" "$(( $freespace / 1073741824 )) GiB" "wrn"
696                 # pause here since dialog-based menu will hide this message otherwise
697                 echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
698                 read
699         fi
700 }
701

  

 该函数的功能主要:由于armbian的开发环境只支持ubuntu 16.04 18.04,且必须在64位机器上面安装,开发环境需要安装相关的软件包,通过查询已安装的软件包,然后把缺失的软件包都安装上

由于我们不是在docker容器当中编译,所以不必关心561-575行的内容,609-613行会同步网络时间,

619-625行,在本机挂载arm rootfs是需要binfmt_mist驱动的支持,参考:https://en.wikipedia.org/wiki/Binfmt_misc

Miscellaneous Binary Format(binfmt_misc)机制,可以通过要打开文件的特性来选择到底使用哪个程序来打开,该机制根据文件的元属性来选择合适的程序将其打开。

627-639行,创建相关的目录结构

645-664行,下载工具链

682行, 下载etcher_cli工具

692-700行,用于检测硬盘空间是否足够搭建开发环境

 

继续回到lib/mian.sh

79 # if KERNEL_ONLY, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu
 80 
 81 if [[ -z $KERNEL_ONLY ]]; then
 82         options+=("yes" "U-boot and kernel packages")
 83         options+=("no" "Full OS image for flashing")
 84         KERNEL_ONLY=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags --menu "Select what to build" \
 85                 $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
 86         unset options
 87         [[ -z $KERNEL_ONLY ]] && exit_with_error "No option selected"
 88 
 89 fi
 90 
 91 if [[ -z $KERNEL_CONFIGURE ]]; then
 92         options+=("no" "Do not change the kernel configuration")
 93         options+=("yes" "Show a kernel configuration menu before compilation")
 94         KERNEL_CONFIGURE=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags --menu "Select the kernel configuration" \
 95                 $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
 96         unset options
 97         [[ -z $KERNEL_CONFIGURE ]] && exit_with_error "No option selected"
 98 
 99 fi
100

  

上面的代码会出对话框图,如下链接对dialog进行讲解,看了之后,上述代码就比较容易理解

https://www.cnblogs.com/lianghong881018/p/10315062.html

其实就是弹出如下对话框:

x x U-boot and kernel packages x x
x x Full OS image for flashing x x

 

x x Do not change the kernel configuration x x
x x Show a kernel configuration menu before compilation x x

 

在lib/main.sh 

101 if [[ -z $BOARD ]]; then
102         WIP_STATE=supported
103         WIP_BUTTON='CSC/WIP/EOS'
104         STATE_DESCRIPTION=' - Officially supported boards'
105         temp_rc=$(mktemp)
106         while true; do
107                 options=()
108                 if [[ $WIP_STATE == supported ]]; then
109                         for board in $SRC/config/boards/*.conf; do
110                                 options+=("$(basename $board | cut -d'.' -f1)" "$(head -1 $board | cut -d'#' -f2)")
111                         done
112                 else
113                         for board in $SRC/config/boards/*.wip; do
114                                 options+=("$(basename $board | cut -d'.' -f1)" "\Z1(WIP)\Zn $(head -1 $board | cut -d'#' -f2)")
115                         done
116                         for board in $SRC/config/boards/*.csc; do
117                                 options+=("$(basename $board | cut -d'.' -f1)" "\Z1(CSC)\Zn $(head -1 $board | cut -d'#' -f2)")
118                         done
119                         for board in $SRC/config/boards/*.eos; do
120                                 options+=("$(basename $board | cut -d'.' -f1)" "\Z1(EOS)\Zn $(head -1 $board | cut -d'#' -f2)")
121                         done
122                 fi
123                 if [[ $WIP_STATE != supported ]]; then
124                         cat <<-'EOF' > $temp_rc
125                         dialog_color = (RED,WHITE,OFF)
126                         screen_color = (WHITE,RED,ON)
127                         tag_color = (RED,WHITE,ON)
128                         item_selected_color = (WHITE,RED,ON)
129                         tag_selected_color = (WHITE,RED,ON)
130                         tag_key_selected_color = (WHITE,RED,ON)
131                         EOF
132                 else
133                         echo > $temp_rc
134                 fi
135                 BOARD=$(DIALOGRC=$temp_rc dialog --stdout --title "Choose a board" --backtitle "$backtitle" --scrollbar --colors \
136                         --extra-label "Show $WIP_BUTTON" --extra-button --menu "Select the target board. Displaying:\n$STATE_DESCRIPTION" \
137                         $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
138                 STATUS=$?
139                 if [[ $STATUS == 3 ]]; then
140                         if [[ $WIP_STATE == supported ]]; then
141                                 [[ $SHOW_WARNING == yes ]] && show_developer_warning
142                                 STATE_DESCRIPTION=' - \Z1(CSC)\Zn - Community Supported Configuration\n - \Z1(WIP)\Zn - Work In Progress\n - \Z1(EOS)\Zn - End Of Support'
143                                 WIP_STATE=unsupported
144                                 WIP_BUTTON='supported'
145                         else
146                                 STATE_DESCRIPTION=' - Officially supported boards'
147                                 WIP_STATE=supported
148                                 WIP_BUTTON='CSC/WIP/EOS'
149                         fi
150                         continue
151                 elif [[ $STATUS == 0 ]]; then
152                         break
153                 fi
154                 unset options
155                 [[ -z $BOARD ]] && exit_with_error "No board selected"
156         done
157 fi
158 
159 if [[ -f $SRC/config/boards/${BOARD}.conf ]]; then
160         BOARD_TYPE='conf'
161 elif [[ -f $SRC/config/boards/${BOARD}.csc ]]; then
162         BOARD_TYPE='csc'
163 elif [[ -f $SRC/config/boards/${BOARD}.wip ]]; then
164         BOARD_TYPE='wip'
165 elif [[ -f $SRC/config/boards/${BOARD}.eos ]]; then
166         BOARD_TYPE='eos'
167 fi

101-157行, 通过枚举$SRC/config/boards/下的文件,弹出对话框,来设置BOARD变量。

   x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
   x x                                                                             bananapi               A20 dual core 1Gb SoC                                                                                                        x x
   x x                                                                             bananapim2plus         H3 quad core 1Gb SoC Wifi                                                                                                    x x
   x x                                                                             bananapipro            A20 dual core 1GB SoC WiFi                                                                                                   x x
   x x                                                                             beelinkx2              H3 quad core 1GB SoC WiFi eMMC                                                                                               x x
   x x                                                                             clearfogbase           Marvell Armada 38x 1xmPCIe M.2 2xGBE SFP                                                                                     x x
   x x                                                                             clearfogpro            Marvell Armada 38x 2xmPCIe M.2 GBE Switch SFP                                                                                x x
   x x                                                                             cubietruck             A20 dual core 2Gb SoC Wifi                                                                                                   x x
   x x                                                                             cubox-i                Freescale iMx dual/quad core Wifi                                                                                            x x
   x x                                                                             espressobin            Marvell Armada 37x 1xmPCIe 2xGBE                                                                                             x x
   x x                                                                             helios4                Marvell Armada 388 2GB-ECC 4xSATA 2xUSB3.0 1xGBE                                                                             x x
   x x                                                                             iotx-3                 AM335X 1Gb SoC eMMC                                                                                                          x x
   x x                                                                             lepotato               S905x Le potato quad core 2Gb SoC eMMC                                                                                       x x
   x x                                                                             lime2                  A20 dual core 1Gb SoC eMMC                                                                                                   x x
   x x                                                                             lime-a33               A33 quad core 1Gb SoC                                                                                                        x x
   x x                                                                             lime                   A20 dual core 512Mb SoC                                                                                                      x x
   x x                                                                             micro                  A20 dual core 1Gb SoC eMMC                                                                                                   x x
   x x                                                                             miqi                   RK3288 quad core 2GB SoC GBE                                                                                                 x x
   x x                                                                             nanopiair              H3 quad core 512MB SoC Headless WiFi/BT eMMC                                                                                 x x
   x x                                                                             nanopiduo              H2+ quad core 256/512MB SoC Wi-Fi/Ethernet                                                                                   x x
   x x                                                                             nanopik1plus           H5 quad core 2GB RAM Wifi GBE eMMC                                                                                           x x
   x x                                                                             nanopik2-s905          S905 K2 quad core 2GB SoC WiFi eMMC                                                                                          x x
   x x                                                                             nanopim1               H3 quad core 1Gb SoC                                                                                                         x x
   x x                                                                             nanopim1plus           H3 quad core 1GB SoC GbE/WiFi/BT eMMC                                                                                        x x
   x x                                                                             nanopineo2             H5 quad core 256/512MB SoC Headless GBE                                                                                      x x
   x x                                                                             nanopineo              H3 quad core 256/512MB SoC Headless                                                                                          x x
   x x                                                                             nanopineocore2         H5 quad core 1GB SoC Headless GBE eMMC                                                                                       x x
   x x                                                                             nanopineoplus2         H5 quad core 1GB SoC Headless GBE eMMC WiFi/BT                                                                               x x
   x x                                                                             odroidc1               S805 C1 quad core                                                                                                            x x
   x x                                                                             odroidc2               S905 C2 quad core                                                                                                            x x
   x x                                                                             odroidxu4              Exynos5422 XU3/XU4 octa core                                                                                                 x x
   x x                                                                             orangepi2              H3 quad core 1GB RAM                                                                                                         x x
   x x                                                                             orangepilite           H3 quad core 512MB RAM WiFi                                                                                                  x x
   x x                                                                             orangepione            H3 quad core 512MB RAM                                                                                                       x x
   x x                                                                             orangepipc2            H5 quad core 1GB RAM                                                                                                         x x
   x x                                                                             orangepipc             H3 quad core 1GB RAM                                                                                                         x x
   x x                                                                             orangepipcplus         H3 quad core 1GB RAM WiFi eMMC                                                                                               x x
   x x                                                                             orangepiplus2e         H3 quad core 2GB RAM WiFi eMMC                                                                                               x x
   x x                                                                             orangepiplus           H3 quad core 1GB/2GB RAM WiFi eMMC                                                                                           x x
   x x                                                                             orangepiprime          H5 quad core 2GB RAM Wi-Fi/BT                                                                                                x x
   x x                                                                             orangepi-r1            H2+ quad core 256MB Wi-Fi + dual Ethernet                                                                                    x x
   x x                                                                             orangepiwin            A64 quad core 1GB SoC GBE WiFi                                                                                               x x
   x x                                                                             orangepizero           H2+ quad core 256/512MB SoC Wi-Fi/Ethernet                                                                                   x x
   x x                                                                             orangepizeroplus2-h3   H3 quad core 512MB SoC Wi-Fi/BT                                                                                              x x
   x x                                                                             orangepizeroplus2-h5   H5 quad core 512MB SoC Wi-Fi/BT                                                                                              x x
   x x                                                                             orangepizeroplus       H5 quad core 512MB RAM, GbE, Wi-Fi                                                                                           x x
   x x                                                                             pine64                 A64 quad core 512MB-2GB SoC GBE                                                                                              x x
   x x                                                                             pine64so               A64 quad core 2GB SoC GBE                                                                                                    x x
   x x                                                                             pinebook-a64           A64 quad core 2GB SoC Wi-Fi/BT                                                                                               x x
   x x                                                                             rock64                 RK3328 quad core SoC 1GB-4GB                                                                                                 x x
   x x                                                                             tinkerboard            RK3288 quad core 2GB SoC GBE WiFi                                                                                            x x
   x x                                                                             udoo                   Freescale iMx dual/quad core Wifi                                                                                            x x
   x x                                                                                                                                                                                                                                 x x
   x x                                                                                                                                                                                                                                 x x
   x x                                                                                                                                                                                                                                 x x
   x x                                                                                                                                                                                                                                 x x
   x x                                                                                                                                                                                                                                 x x
   x x                                                                                                                                                                                                                                 x x

 

159-167行,根据$BOARD变量来设置BOARD_TYPE的值。

停一停,到了这一步,其实已经知道我们到底编译的是哪块板子了。接下来就是读取相关的配置。

把uboot kernel相关代码拉下来,并选择对应的rootfs版本,如ubuntu debian等,打包最终的镜像

当然到此处我们也知道如果要自已添加对新板子的支持,$SRC/config/boards/$BOARD.{conf,csc,wip,eos}是必不可少的。

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!