OrangePI Zero最新源码制作Debian系统


作者:guowenxue 来源:凌云物网智科实验室 时间:2017-11-28

版权:  凌云物网智科实验室< www.iot-yun.com >

声明:  本文档由凌云物网智科实验室郭工编著,只用于实验室内部教学和学员学习使用。未经许可任何人不得以任何形式上传到网上共享或通过其他形式传播!

作者:  郭文学< QQ: 281143292  guowenxue@gmail.com>

版本:  v1.0.0

 

 

本文介绍了OrangePI最新的u-boot、Linux内核源码编译过程,以及使用 Jessie(Debian8) 或 Stretch(Debian 9)作为根文件系统制作SD卡启动盘的过程。

 

编译测试环境:  ubuntu-16.04 X86_64

 

Know issues:  1, WiFi 和 以太网卡驱动不支持

 

一、交叉编译器脚本:

 

交叉编译器使用Linaro官方下载的gcc 6.1版本,Linux最新内核编译要求6.0以上版本的gcc。

 

lingyun@lingyun-ubuntu16:~/orangepi/crosstool$ vim build.sh

#!/bin/bash
# This shell script used to download and install Linaro cross compiler, test and running on Ubuntu-12.04.5
# Author: guowenxue<guowenxue@gmail.com>
# Linaro Oiffical download address:
# LingYun Studio FTP download address
CROSSTOOL=gcc-linaro-6.1.1-2016.08-`uname -p`_arm-linux-gnueabi
CROSSPACK=${CROSSTOOL}.tar.xz
INST_PATH=/opt
INST_DIR=linaro-gcc6.1
if [ “$(id -u)” != “0” ] ; then
   echo “ERROR: This shell script must run as root”
   echo “Usage: sudo $0”
   exit;
fi
function disp_banner()
{
   echo “”
   echo “+————————————————————————“
   echo “| $1”
   echo “+————————————————————————“
   echo “”
}
function download_crosstool()
{
   if [ ! -f ${CROSSPACK} ] ; then
      wget ${DL_ADDR}/${CROSSPACK}
      if [ $? != 0 ] ; then
        disp_banner  “ERROR: Download crosstool ${CROSSPACK} failure!”
        exit 1;
      fi
   fi
}
function decompress_crosstool()
{
   if [ -f ${CROSSPACK} ] ; then
      xz -d ${CROSSPACK}
   fi
   if [ -f ${CROSSTOOL}.tar ] ; then
      tar -xf ${CROSSTOOL}.tar -C ${INST_PATH}
   fi
   rm -f  ${CROSSTOOL}.tar*
}
function complete_install()
{
   cd ${INST_PATH}
   chmod a+rx ${CROSSTOOL}
   mv ${CROSSTOOL} ${INST_DIR}
   cd ${INST_DIR}/bin
   for file in `ls arm-*-gnueabi-*` ; do
       sym_file=arm-linux-`echo $file | awk -F ‘-‘ ‘{print $NF}’`
       ln -s $file $sym_file > /dev/null 2>&1
   done
}
if [ -d ${INST_PATH}/${INST_DIR} ] ; then
   disp_banner “Crosstool already installed:  ${INST_PATH}/${INST_DIR}”
   exit 2;
fi
download_crosstool
decompress_crosstool
complete_install
${INST_PATH}/${INST_DIR}/bin/arm-linux-gcc -v > /dev/null 2>&1
if [ $? != 0 ] ; then
   disp_banner “ERROR: Install crosstool ${CROSSTOOL} failure!”
else
   disp_banner “Congratulation: Install crosstool ${CROSSTOOL} successfully!”
fi

 

lingyun@lingyun-ubuntu16:~/orangepi/crosstool$ chmod a+x build.sh

lingyun@lingyun-ubuntu16:~/orangepi/crosstool$ sudo ./build.sh

 

二、u-boot编译脚本

 

lingyun@lingyun-ubuntu16:~/orangepi/bootloader$ vim build.sh

#!/bin/bash
# Descripion:  This shell script used to cross compile u-boot for OrangePi Zero
#     Author:  GuoWenxue<guowenxue@gmail.com>
#  ChangeLog:
UBOOT_VERSION=u-boot-2017.11
BOARD=orangepi_zero
CPU_CORE=`cat /proc/cpuinfo | grep processor | wc -l`
PRJ_PATH=`pwd`
PATCH_FILE=${PRJ_PATH}/patch/${UBOOT_VERSION}.patch
INST_PATH=${PRJ_PATH}/../images
IMG_NAME=${UBOOT_VERSION}-sunxi-with-spl.bin
if [ -z “$CROSS” ] ; then
    CROSS=/opt/linaro-gcc6.1/bin/arm-linux-gnueabi-
fi
function msg_banner()
{
    echo “”
    echo “+———————————————————————–“
    echo “|  $1 “
    echo “+———————————————————————–“
    echo “”
}
function check_result()
{
    if [ $? != 0 ] ; then
       echo “”
       echo “+———————————————————————–“
       echo “|  $1 “
       echo “+———————————————————————–“
       echo “”
       exit ;
    fi
}
function disp_banner()
{
   echo “”
   echo “*******************************************************”
   echo “*     Cross compile $UBOOT_VERSION for $BOARD now…       “
   echo “*******************************************************”
   echo “”
}
#===============================================================
#                   Script excute body start                   =
#===============================================================
msg_banner ” Cross compile $UBOOT_VERSION for $BOARD now “
# If $UBOOT_VERSION not set, then abort this cross compile
if [ -z $UBOOT_VERSION ] ; then
    msg_banner “ERROR: Please choose a valid version to cross compile”
    exit 1;
fi
# download u-boot source code packet
if [ ! -d $UBOOT_VERSION ] ; then
   SRC_PACKET=${UBOOT_VERSION}.tar.bz2
   if [ ! -s $SRC_PACKET ] ; then
      msg_banner “packet  $SRC_PACKET not exist, download it now”
      wget $DL_ADDR
      check_result “ERROR: Download $DL_ADDR failure, exit now… “
   fi
   msg_banner ” decompress the source code patcket”
   tar -xjf $SRC_PACKET
   check_result “ERROR: decompress $SRC_PACKET failure “
fi
#Start to cross compile the source code and install it now
cd $UBOOT_VERSION
if [ ! -d $INST_PATH ] ; then
    mkdir -p $INST_PATH
fi
if [  -n “$PATCH_FILE” ] ; then
   if [  -f $PATCH_FILE ] ; then
      msg_banner ” patch for $PATCH_FILE”
      patch -p1 < $PATCH_FILE
   fi
fi
msg_banner “start cross compile $UBOOT_VERSION … “
grep “ARCH=arm” Makefile > /dev/null
if [ $? != 0  ] ; then
   sed -i “/HOSTARCH HOSTOS/a\export CROSS_COMPILE=${CROSS}” Makefile
   sed -i ‘/HOSTARCH HOSTOS/a\export ARCH=arm’ Makefile
fi
#If don’t do “make $BOARD_config”, it will configure for the board first
if [ ! -s include/config.mk ] ; then
    make ${BOARD}_defconfig
fi
make -j${CPU_CORE}
cp u-boot-sunxi-with-spl.bin  $INST_PATH/${IMG_NAME}
cp u-boot-sunxi-with-spl.bin  $PRJ_PATH/${IMG_NAME}

 

lingyun@lingyun-ubuntu16:~/orangepi/bootloader$ chmod a+x build.sh

lingyun@lingyun-ubuntu16:~/orangepi/bootloader$ ./build.sh

 

三、Linux内核编译脚本

 

lingyun@lingyun-ubuntu16:~/orangepi/kernel$ vim build.sh

#!/bin/bash
KERNEL_VERSION=linux-4.14
PRJ_PATH=`pwd`
PATCH_PATH=${PRJ_PATH}/patch
INST_PATH=${PRJ_PATH}/../images
CPU_CORE=`cat /proc/cpuinfo | grep processor | wc -l`
if [ -z “$CROSS” ] ; then
    CROSS=/opt/linaro-gcc6.1/bin/arm-linux-gnueabi-
fi
function msg_banner()
{
    echo “”
    echo “+———————————————————————–“
    echo “|  $1 “
    echo “+———————————————————————–“
    echo “”
}
function check_result()
{
    if [ $? != 0 ] ; then
       echo “”
       echo “+———————————————————————–“
       echo “|  $1 “
       echo “+———————————————————————–“
       echo “”
       exit ;
    fi
}
# download and decompress source code
if [ ! -d ${KERNEL_VERSION} ] ; then
    if [ ! -f ${KERNEL_VERSION}.tar.gz ] ; then
       msg_banner “packet ${KERNEL_VERSION}.tar.gz not exist, download it now”
       wget $DL_ADDR
       check_result “ERROR: Download $DL_ADDR failure, exit now… “
    fi
    msg_banner “decompress ${KERNEL_VERSION} source code…”
    tar -xzf ${KERNEL_VERSION}.tar.gz
    check_result “ERROR: decompress ${KERNEL_VERSION} source code failure!!”
fi
cd ${KERNEL_VERSION}
# Patch
if [ -f ${PATCH_PATH}$/{KERNEL_VERSION}.patch ] ; then
    msg_banner “patch ${PATCH_PATH}/${KERNEL_VERSION}.patch “
    patch -p1 < ${PATCH_PATH}/${KERNEL_VERSION}.patch
fi
# copy configure file
if [ ! -f .config ] ; then
    echo “copy configure file ${PATCH_PATH}/${KERNEL_VERSION}”
    cp ${PATCH_PATH}/${KERNEL_VERSION}.config .config
fi
msg_banner “start cross compile ${KERNEL_VERSION} now…”
make -j${CPU_CORE} ARCH=arm CROSS_COMPILE=${CROSS} LOADADDR=0x40008000 uImage dtbs modules
check_result “ERROR: cross compile ${KERNEL_VERSION} source code failure!!”
cp arch/arm/boot/uImage ${PRJ_PATH}
cp arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dtb ${PRJ_PATH}
cp arch/arm/boot/uImage ${INST_PATH}
cp arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dtb ${INST_PATH}

 

lingyun@lingyun-ubuntu16:~/orangepi/kernel$ chmod a+x build.sh

lingyun@lingyun-ubuntu16:~/orangepi/kernel$ ./build.sh

 

四、使用debootstrap构建Debian Jessie 根文件系统

 

参考链接:

使用debootstrap来构建文件系统          https://www.cnblogs.com/aaronLinux/p/6886163.html

 

lingyun@lingyun-ubuntu16:~/orangepi/rootfs$  vim build.sh   该脚本使用debootstrap下载并更新Debian的ARM发行版本(armhf)并修改部分系统配置文件

#!/bin/bash
#distro=stretch
distro=jessie
rootfs_dir=rootfs_${distro}
DEF_PASSWD=orangepi
if [ “$(id -u)” != “0” ] ; then
   echo “ERROR: This shell script must run as root”
   echo “Usage: sudo $0”
   exit;
fi
function msg_banner()
{
    echo “”
    echo “+———————————————————————–“
    echo “|  $1 “
    echo “+———————————————————————–“
    echo “”
}
function check_result()
{
    if [ $? != 0 ] ; then
       echo “”
       echo “+———————————————————————–“
       echo “|  $1 “
       echo “+———————————————————————–“
       echo “”
       exit ;
    fi
}
function install_tools()
{
    msg_banner “install dependend system tools…”
    apt-get install -y qemu qemu-user qemu-user-static binfmt-support debootstrap dosfstools
}
function debootstrap_checkout()
{
    msg_banner “debootstrap checkout rootfs tree to ${rootfs_dir} start…”
    debootstrap –foreign –no-check-gpg –include=ca-certificates –arch=armhf ${distro} ${rootfs_dir} \
    cp $(which qemu-arm-static) ${rootfs_dir}/usr/bin
    chroot ${rootfs_dir} /debootstrap/debootstrap  –second-stage –verbose
    ls ${rootfs_dir}
}
function update_rootfs_conf()
{
    msg_banner “update rootfs configuration…”
    echo deb http://mirrors.ustc.edu.cn/debian/ ${distro} main > ${rootfs_dir}/etc/apt/sources.list
    echo “OrangePiZero” > ${rootfs_dir}/etc/hostname
    echo “Debian ${distro} released by LingYun IoT Studio” > ${rootfs_dir}/etc/issue
    echo -e 127.0.0.1\\tOrangePiZero > ${rootfs_dir}/etc/hosts
    cat > ${rootfs_dir}/etc/network/interfaces << EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
EOF
}
install_tools
debootstrap_checkout
update_rootfs_conf
if [ ! -f ${rootfs_dir}/usr/bin/qemu-arm-static ] ; then
   cp $(which qemu-arm-static) ${rootfs_dir}/usr/bin
fi
cp update.sh ${rootfs_dir}/usr/bin
chmod a+x ${rootfs_dir}/usr/bin/update.sh
echo “Run 2 commands in chroot jail:   1: update.sh   2: exit”
sudo chroot ${rootfs_dir} /bin/bash
sudo rm -rf ${rootfs_dir}/usr/bin/update.sh
sudo rm -rf ${rootfs_dir}/usr/bin/qemu-arm-static

 

 

lingyun@lingyun-ubuntu16:~/orangepi/rootfs$ vim update.sh     该脚本使用chroot命令更新根文件系统里的信息,包括安装缺少的软件并默认创建2个用户: lingyun和orangepi,root和orangepi密码为orangepi, lingyun密码为lingyun

#!/bin/bash
function apt_update()
{
   apt-get update
   apt-get install -y –no-install-recommends locales sudo bc ssh ntpdate gettext autoconf wpasupplicant openssh-server
   apt-get clean
     # Fix Securecrt SSH2 logon bug
     grep aes256-cbc ${rootfs_dir}/etc/ssh/sshd_config  > /dev/null 2>&1
     if [ $? != 0 ] ; then
        echo “” >> ${rootfs_dir}/etc/ssh/sshd_config
        echo “Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc” >> ${rootfs_dir}/etc/ssh/sshd_config
    fi
}
function create_users()
{
   GROUP_NAME=orangepi
   USERS_NAME=”lingyun orangepi”
   grep ${GROUP_NAME} /etc/group > /dev/null 2>&1
   if [ $? != 0 ] ; then
      echo “create group ${GROUP_NAME}”
      addgroup ${GROUP_NAME}
      addgroup root ${GROUP_NAME}
   fi
   echo root:orangepi | chpasswd
   for user in $USERS_NAME ; do
       grep $user /etc/passwd > /dev/null 2>&1
       if [ $? != 0 ] ; then
          echo “create user $user”
          useradd -m $user -g $GROUP_NAME
          echo $user:$user | chpasswd
          usermod -a -G $GROUP_NAME,sudo $user
        fi
   done
}
export LC_ALL=C
export LANGUAGE=C
export LANG=C
apt_update
create_users

 

 

guowenxue@guowenxue-ubuntu:~/debian_rootfs$ chmod a+x build.sh

lingyun@lingyun-ubuntu16:~/orangepi/rootfs$ sudo ./build.sh

+———————————————————————–
|  install dependend system tools…
+———————————————————————–
Reading package lists… Done
Building dependency tree
Reading state information… Done
binfmt-support is already the newest version (2.1.6-1).
debootstrap is already the newest version (1.0.78+nmu1ubuntu1.5).
dosfstools is already the newest version (3.0.28-2ubuntu0.1).
qemu is already the newest version (1:2.5+dfsg-5ubuntu10.16).
qemu-user is already the newest version (1:2.5+dfsg-5ubuntu10.16).
qemu-user-static is already the newest version (1:2.5+dfsg-5ubuntu10.16).
0 upgraded, 0 newly installed, 0 to remove and 129 not upgraded.
+———————————————————————–
|  debootstrap checkout rootfs tree to rootfs_jessie start…
+———————————————————————–
I: Retrieving InRelease
I: Failed to retrieve InRelease
I: Retrieving Release
I: Validating Packages
—- 开始下载Debian Rootfs —-
I: Configuring systemd…
I: Configuring ca-certificates…
I: Base system installed successfully.
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
+———————————————————————–
|  update rootfs configuration…
+———————————————————————–
Run 2 commands in chroot jail:   1: update.sh   2: exit
root@lingyun-ubuntu16:/# update.sh
Ign http://mirrors.ustc.edu.cn jessie InRelease
Get:1 http://mirrors.ustc.edu.cn jessie Release.gpg [2373 B]
Get:2 http://mirrors.ustc.edu.cn jessie Release [148 kB]
Get:3 http://mirrors.ustc.edu.cn jessie/main armhf Packages [6645 kB]
Get:4 http://mirrors.ustc.edu.cn jessie/main Translation-en [4582 kB]
—- 开始安装update.sh中定义的缺失的软件—-
Processing triggers for libc-bin (2.19-18+deb8u10) …
Processing triggers for systemd (215-17+deb8u7) …
create group orangepi
Adding group `orangepi’ (GID 1000) …
Done.
Adding user `root’ to group `orangepi’ …
Adding user root to group orangepi
Done.
modify root password to orangepi
create user lingyun with password lingyun
create user orangepi with password orangepi
root@lingyun-ubuntu16:/# exit
exit

 

lingyun@lingyun-ubuntu16:~/orangepi/rootfs$ ls

build.sh  rootfs_jessie  update.sh

 

 

五、SD卡启动盘制作

 

参考链接:

SD Card Layout:   http://linux-sunxi.org/Bootable_SD_card

 

Building a Custom Mainline Linux Kernel System on the Orange Pi PC:  https://notsyncing.net/?p=blog&b=2016.orangepi-pc-custom-kernel

全志平台 script.bin 分析:  http://blog.csdn.net/jklinux/article/details/73603980

 

5.1 SD卡分区

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ ls

sun8i-h2-plus-orangepi-zero.dtb  u-boot-2017.11-sunxi-with-spl.bin  uImage

 

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ ls /dev/sd*             查看当前的SD卡设备名:

/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb  /dev/sdb1 /dev/sdb2

 

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=10          清除SD卡上的分区和以前的信息

 

10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 2.58874 s, 4.1 MB/s

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ ls /dev/sdb*

/dev/sdb

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ sudo fdisk /dev/sdb      SD卡重新分区表: sdb1分区vfat格式给Boot分区,  sdb2分区ext4格式给根文件系统分区;

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x64677a32.
Command (m for help): m  打印帮助信息
Help:
  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag
  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition
  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)
  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file
  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes
  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table
Command (m for help): p  打印当前分区表
Disk /dev/sdb: 7.3 GiB, 7822376960 bytes, 15278080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x64677a32
Command (m for help): n  创建一个新的分区,该分区为boot分区,vfat格式
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15278079, default 2048): 2048  第一个分区起始地址为2048,前面的留给u-boot
Last sector, +sectors or +size{K,M,G,T,P} (2048-15278079, default 15278079): +15M  设置分区大小为15M
Created a new partition 1 of type ‘Linux’ and of size 15 MiB.
Command (m for help): n  再创建第二个分区,该分区为系统分区,ext4格式
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (32768-15278079, default 32768): 32768  第二个分区起始地址
Last sector, +sectors or +size{K,M,G,T,P} (32768-15278079, default 15278079):  回车   剩余的空间都划到第二个分区里
Created a new partition 2 of type ‘Linux’ and of size 7.3 GiB.
Command (m for help): w   写保存
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ ls /dev/sdb*

/dev/sdb  /dev/sdb1  /dev/sdb2

lingyun@lingyun-ubuntu16:~/orangepi/images$ sudo mkfs.vfat /dev/sdb1

lingyun@lingyun-ubuntu16:~/orangepi/images$ sudo mkfs.ext4 /dev/sdb2

 

5.2 烧录u-boot

 

lingyun@lingyun-ubuntu16:~/orangepi/images$  dd if=u-boot-2017.11-sunxi-with-spl.bin  of=/dev/sdb bs=1024 seek=8   烧录u-boot

 

 

5.1 烧录Linux内核和根文件系统

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ vim update_sdcard.sh  该脚本用来更新SD卡上的启动镜像文件和根文件系统树

#!/bin/bash
PRJ_PATH=`pwd`/../
#DEB_DISTRO=stretch
DEB_DISTRO=jessie
ROOTFS_PATH=${PRJ_PATH}/rootfs/rootfs_${DEB_DISTRO}
SDCARD=/dev/sdb
PART_BOOT=${SDCARD}1
PART_ROOTFS=${SDCARD}2
if [ “$(id -u)” != “0” ] ; then
   echo “ERROR: This shell script must run as root”
   echo “Usage: sudo $0”
   exit;
fi
function msg_banner()
{
    echo “”
    echo “+———————————————————————–“
    echo “|  $1 “
    echo “+———————————————————————–“
    echo “”
}
function check_result()
{
    if [ $? != 0 ] ; then
       echo “”
       echo “+———————————————————————–“
       echo “|  $1 “
       echo “+———————————————————————–“
       echo “”
       exit ;
    fi
}
function create_bootscr()
{
    msg_banner “create boot.scr”
    cat > boot.cmd << EOF
#COMMON SETTINGS
setenv fdt_high ffffffff
#Settings for booting from the card.
setenv loadkernel fatload mmc 0 \$kernel_addr_r uImage
setenv loaddtb fatload mmc 0 \$fdt_addr_r sun8i-h2-plus-orangepi-zero.dtb
setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw init=/sbin/init rootwait panic=10
setenv uenvcmd run loadkernel \&\& run loaddtb \&\& bootm \$kernel_addr_r – \$fdt_addr_r
run uenvcmd
EOF
    mkimage -C none -A arm -T script -d boot.cmd boot.scr
    rm -f boot.cmd
}
function update_boot()
{
    if [ ! -b $PART_BOOT  -o  ! -b $PART_ROOTFS ] ; then
       msg_banner “ERROR: $PART_BOOT or $PART_ROOTFS not exist, exit now”
       exit ;
    fi
    create_bootscr
    msg_banner “update SD Card boot partition [${PART_BOOT}] for u-boot and kernel”
    mkdir -p mnt
    mount -t vfat ${PART_BOOT} mnt/
    cp boot.scr uImage  sun8i-h2-plus-orangepi-zero.dtb mnt/ && sync
    ls mnt/
    umount mnt/
    rm -rf mnt
}
function update_system()
{
    if [ ! -b $PART_BOOT  -o  ! -b $PART_ROOTFS ] ; then
       msg_banner “ERROR: $PART_BOOT or $PART_ROOTFS not exist, exit now”
       exit ;
    fi
       if [ ! -d ${ROOTFS_PATH}/bin ] ; then
          msg_banner “ERROR: $ROOTFS_PATH not exist, exit now”
          exit ;
       fi
    msg_banner “update SD Card rootfs partition [${PART_ROOTFS}] from debian ${DEB_DISTRO}”
    mkdir -p mnt
    mount -t ext4 ${PART_ROOTFS} mnt/
    rm -rf mnt/*
    cp -af ${PRJ_PATH}/rootfs/rootfs_${DEB_DISTRO}/* mnt/ && sync
    ls mnt/
    umount mnt/
    rm -rf mnt
}
if [ ! -b $SDCARD ] ; then
   msg_banner “ERROR: SD Card $SDCARD not exist, exit now”
   exit;
fi
update_boot
update_system
msg_banner “update SD Card linux system done”

 

lingyun@lingyun-ubuntu16:~/orangepi/images$ sudo  ./update_sdcard.sh

+———————————————————————–
|  create boot.scr
+———————————————————————–
Image Name:
Created:      Mon Nov 27 09:24:05 2017
Image Type:   ARM Linux Script (uncompressed)
Data Size:    427 Bytes = 0.42 kB = 0.00 MB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 419 Bytes = 0.41 kB = 0.00 MB
+———————————————————————–
|  update SD Card boot partition [/dev/sdb1] for u-boot and kernel
+———————————————————————–
boot.scr  sun8i-h2-plus-orangepi-zero.dtb  System Volume Information  u-boot-2017.11-sunxi-with-spl.bin  uImage
+———————————————————————–
|  update SD Card rootfs partition [/dev/sdb2] from debian jessie
+———————————————————————–
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
+———————————————————————–
|  update SD Card linux system done
+———————————————————————–

 

六、系统启动信息

 

U-Boot 2017.11 (Nov 26 2017 – 19:25:48 +0800) Allwinner Technology
CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi Zero
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
*** Warning – bad CRC, using default environment
In:    serial
Out:   serial
Err:   serial
Net:   phy interface0
eth0: ethernet@1c30000
starting USB…
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0
scanning bus 0 for devices… 1 USB Device(s) found
       scanning usb for storage devices… 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1…
Found U-Boot script /boot.scr
reading /boot.scr
491 bytes read in 16 ms (29.3 KiB/s)
## Executing script at 43100000
reading uImage
3745272 bytes read in 193 ms (18.5 MiB/s)
reading sun8i-h2-plus-orangepi-zero.dtb
14236 bytes read in 28 ms (496.1 KiB/s)
## Booting kernel from Legacy Image at 42000000 …
   Image Name:   Linux-4.14.0
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3745208 Bytes = 3.6 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum … OK
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
   Loading Kernel Image … OK
   Using Device Tree in place at 43000000, end 4300679b
Starting kernel …
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.0 (lingyun@lingyun-ubuntu16) (gcc version 6.1.1 20160711 (Linaro GCC 6.1-2016.08)) #1 SMP Mon Nov 27 10:10:54 CST 2017
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Xunlong Orange Pi Zero
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] random: fast init done
[    0.000000] percpu: Embedded 16 pages/cpu @dffad000 s33740 r8192 d23604 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw init=/sbin/init rootwait panic=10
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 509632K/524288K available (6144K kernel code, 303K rwdata, 1396K rodata, 1024K init, 254K bss, 14656K reserved, 0K cma-reserved, 0K highmem)
—- 其他信息省略 —-
[    1.265490] hub 4-0:1.0: USB hub found
[    1.269274] hub 4-0:1.0: 1 port detected
[    1.273873] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.285912] sunxi-mmc 1c10000.mmc: allocated mmc-pwrseq
[    1.570909] sunxi-mmc 1c10000.mmc: base:0xe0891000 irq:24
[    1.576390] sun6i-rtc 1f00000.rtc: setting system clock to 1970-01-01 04:09:34 UTC (14974)
[    1.584899] vcc3v0: disabling
[    1.587866] vcc5v0: disabling
[    1.590830] ALSA device list:
[    1.593813]   No soundcards found.
[    1.611834] mmc1: new high speed SDIO card at address 0001
[    1.623124] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.631276] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    1.638789] devtmpfs: mounted
[    1.642850] Freeing unused kernel memory: 1024K
[    1.857131] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)
[    1.870697] systemd[1]: Detected architecture ‘arm’.
Welcome to Debian GNU/Linux 8 (jessie)!
[    1.915387] systemd[1]: Failed to insert module ‘autofs4’
[    1.920948] systemd[1]: Failed to insert module ‘ipv6’
[    1.927616] systemd[1]: Set hostname to <OrangePiZero>.
[    2.301401] systemd[1]: Cannot add dependency job for unit dbus.socket, ignoring: Unit dbus.socket failed to load: No such file or directory.
[    2.314209] systemd[1]: Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory.
[    2.330970] systemd[1]: Starting Forward Password Requests to Wall Directory Watch.
[    2.338985] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[    2.346667] systemd[1]: Expecting device dev-ttyS0.device…
         Expecting device dev-ttyS0.device…
[  OK  ] Reached target Remote File Systems (Pre).
[  OK  ] Reached target Encrypted Volumes.
[  OK  ] Reached target Paths.
[  OK  ] Reached target Swap.
[  OK  ] Created slice Root Slice.
[  OK  ] Created slice User and Session Slice.
[  OK  ] Listening on Delayed Shutdown Socket.
[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Listening on udev Control Socket.
[  OK  ] Listening on udev Kernel Socket.
[  OK  ] Listening on Journal Socket.
[  OK  ] Created slice System Slice.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Created slice system-serial\x2dgetty.slice.
         Starting Increase datagram queue length…
         Starting udev Coldplug all Devices…
         Starting Load Kernel Modules…
         Mounting Debug File System…
         Starting Create Static Device Nodes in /dev…
[  OK  ] Reached target Slices.
         Starting Remount Root and Kernel File Systems…
[  OK  ] Mounted Debug File System.
[  OK  ] Started Increase datagram queue length.
[  OK  ] Started Load Kernel Modules.
[  OK  ] Started Create Static Device Nodes in /dev.
[  OK  ] Started Remount Root and Kernel File Systems.
[  OK  ] Started udev Coldplug all Devices.
         Starting Various fixups to make systemd work better on Debian…
         Starting Load/Save Random Seed…
         Starting udev Kernel Device Manager…
[  OK  ] Reached target Local File Systems (Pre).
[    3.451094] systemd-udevd[98]: starting version 215
[  OK  ] Reached target Local File Systems.
         Starting Create Volatile Files and Directories…
[  OK  ] Reached target Remote File Systems.
         Starting Apply Kernel Variables…
[  OK  ] Listening on Syslog Socket.
[  OK  ] Reached target Sockets.
         Starting Journal Service…
[  OK  ] Started Journal Service.
         Starting Trigger Flushing of Journal to Persistent Storage…
[  OK  ] Started udev Kernel Device Manager.
[  OK  ] Started Various fixups to make systemd work better on Debian.
[  OK  ] Started Load/Save Random Seed.
[  OK  ] Started Create Volatile Files and Directories.
[  OK  ] Started Apply Kernel Variables.
[  OK  ] Found device /dev/ttyS0.
[    3.997698] systemd-journald[121]: Received request to flush runtime journal from PID 1
[  OK  ] Started Trigger Flushing of Journal to Persistent Storage.
         Starting Update UTMP about System Boot/Shutdown…
         Starting LSB: Raise network interfaces….
         Starting Copy rules generated while the root was ro…
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Started Copy rules generated while the root was ro.
[  OK  ] Started LSB: Raise network interfaces..
[  OK  ] Reached target Network.
[  OK  ] Reached target System Initialization.
[  OK  ] Reached target Timers.
[  OK  ] Reached target Basic System.
         Starting Regular background program processing daemon…
[  OK  ] Started Regular background program processing daemon.
         Starting OpenBSD Secure Shell server…
[  OK  ] Started OpenBSD Secure Shell server.
         Starting /etc/rc.local Compatibility…
         Starting getty on tty2-tty6 if dbus and logind are not available…
         Starting System Logging Service…
         Starting Permit User Sessions…
[  OK  ] Started /etc/rc.local Compatibility.
[  OK  ] Started Permit User Sessions.
[  OK  ] Started System Logging Service.
         Starting Getty on tty2…
[  OK  ] Started Getty on tty2.
         Starting Getty on tty1…
[  OK  ] Started Getty on tty1.
         Starting Serial Getty on ttyS0…
[  OK  ] Started Serial Getty on ttyS0.
         Starting Getty on tty3…
[  OK  ] Started Getty on tty3.
         Stopping OpenBSD Secure Shell server…
[  OK  ] Stopped OpenBSD Secure Shell server.
         Starting OpenBSD Secure Shell server…
[  OK  ] Started OpenBSD Secure Shell server.
         Starting Getty on tty4…
[  OK  ] Started Getty on tty4.
         Starting Getty on tty5…
[  OK  ] Started Getty on tty5.
         Stopping OpenBSD Secure Shell server…
[  OK  ] Stopped OpenBSD Secure Shell server.
         Starting OpenBSD Secure Shell server…
[  OK  ] Started OpenBSD Secure Shell server.
         Starting Getty on tty6…
[  OK  ] Started Getty on tty6.
[  OK  ] Started getty on tty2-tty6 if dbus and logind are not available.
         Stopping OpenBSD Secure Shell server…
[  OK  ] Stopped OpenBSD Secure Shell server.
         Starting OpenBSD Secure Shell server…
[  OK  ] Started OpenBSD Secure Shell server.
[  OK  ] Reached target Login Prompts.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes…
[  OK  ] Started Update UTMP about System Runlevel Changes.
Debian jessie released by LingYun IoT Studio
OrangePiZero login: root
Password: 密码 orangepi
[   14.448820] random: crng init done
Linux OrangePiZero 4.14.0 #1 SMP Mon Nov 27 10:10:54 CST 2017 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

 

root@OrangePiZero:~# cd /

root@OrangePiZero:/# ls

bin   dev  home  media  opt   root  sbin  sys  usr

boot  etc  lib   mnt    proc  run   srv   tmp  var

root@OrangePiZero:/# ifconfig -a

lo        Link encap:Local Loopback

inet addr:127.0.0.1  Mask:255.0.0.0

UP LOOPBACK RUNNING  MTU:65536  Metric:1

RX packets:8 errors:0 dropped:0 overruns:0 frame:0

TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:648 (648.0 B)  TX bytes:648 (648.0 B)

root@OrangePiZero:/#

下一篇:
在线咨询
微信号
13554373241
联系方式
135-5437-3241
邮箱
guowenxue@aliyun.com
返回顶部