本文主要是介绍如何编辑内核,u-boot,ubuntu-base-arm64根文件系统,并通过脚本合成镜像。
先说一下本文的主角,本文主角是ROC-RK3328-CC,开发板。这款开发板的独到之处是,在200块钱左右便拥有ddr4内存,usb3.0接口。ddr4的作用见仁见智(我感觉比较有用,所以放弃了rock64),但usb3.0的便利显而易见的。据我测试,usb3.0接hub,可以拖4块硬盘,共计4tb,朋友的拖了两个硬盘,共8tb(超过3tb需要转换为gpt分区),无压力。比较可惜的是我没有千兆路由器,不然可以测试一下传输速度。据脚本测试的硬盘数据是153mb/s,还算不错。我目前只是用来做nas,所以我的镜像制作教程当中没有介绍如何安装桌面,而且我觉得,开发板安装桌面的话,并不高效(这点要看用途)。开发板的尺寸和树莓派3相差无几,实测可放入树莓派3的外壳。
下面步入正题
建议git过程在vps上操作,这样节省时间,也可以下载我打包和编译好的文件:链接:https://pan.baidu.com/s/1kNegH8swdEvCKwMCxVd2pQ 密码:t6k1
1.安装环境
$ sudo vi /etc/apt/sources.list
//在sources.list末尾添加
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
保存
$ sudo apt-get update
$ sudo apt-get install mingw32
$ sudo apt-get install git repo gnupg flex bison gperf build-essential \
zip tar curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 cmake tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386 lzop
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 \
/usr/lib/i386-linux-gnu/libGL.so
$ sudo apt-get install gcc-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu device-tree-compiler lzop libncurses5-dev \
libssl1.0.0 libssl-dev
$ sudo apt-get install swig libpython-dev
$ sudo apt-get install binfmt-support qemu-user-stati
$ sudo dpkg -i ubuntu-build-service/packages/*
$ sudo apt-get install -f
2.git
- kernel
$ git clone https://github.com/FireflyTeam/kernel.git
- uboot
$ git clone https://github.com/FireflyTeam/u-boot.git
- build
$ git clone https://github.com/FireflyTeam/build.git
- rkbin
$ git clone https://github.com/FireflyTeam/rkbin.git
3.编译
- uboot
$ ./build/mk-uboot.sh roc-rk3328-cc
- kernel
$ ./build/mk-kernel.sh roc-rk3328-cc
- 制作根文件(rootfs),较长,单独说。
- 生成系统镜像
$ ./build/mk-image.sh -c rk3328 -t system -r out/ubuntu-rootfs.img
3.1制作根文件
这一步需要安装软件,建议一定要在vps上操作。
-
-
- 在/root下创建文件夹
$ mkdir rootfs && cd rootfs
- 下载根文件和挂载脚本
$ wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.4/release/ubuntu-base-16.04.4-base-arm64.tar.gz $ mkdir ubuntu-rootfs $ sudo tar -xvf ubuntu-base-16.04.4-base-arm64.tar.gz -C ubuntu-rootfs $ wget https://raw.githubusercontent.com/psachin/bash_scripts/master/ch-mount.sh
如果vps上一定要有qemu-user-static,
apt-get install -y qemu-user-static
- 安装前修改配置
修改/root/rootfs/ubuntu-rootfs/etc/apt/sources.list,将deb-src开头的所有库的注释去掉 - 移动模拟器并挂载
$ cp /usr/bin/qemu-aarch64-static /root/rootfs/ubuntu-rootfs/usr/bin $ cp -b /etc/resolv.conf /root/rootfs/ubuntu-rootfs/etc/ $ sudo bash ch-mount.sh -m /root/rootfs/ubuntu-rootfs
- 安装软件
此时已经进入了arm64模拟器,这时安装的软件全都是适配arm64的$ sudo apt-get -y update && apt-get -y upgrade && apt-get install -y rsyslog bash-completion language-pack-en-base sudo ssh net-tools ethtool wireless-tools xfce4-power-manager network-manager iputils-ping alsa-utils htop python-gobject-2 python-gtk2 resolvconf tzdata python-apt wget vim software-properties-common python-software-properties --no-install-recommends
- 系统设置
配置ssh$ sudo vi /etc/ssh/sshd_config
将root登录设置为yes
配置开机自动拨号$ vi /etc/network/interfaces
写入
auto eth0 iface eth0 inet dhcp
设置root
$ passwd root
输入两次密码
设置主机名和帐号$ echo 'firefly' > /etc/hostname $ echo '127.0.0.1 localhost firefly' >> /etc/hosts
设置时区和DNS
$ dpkg-reconfigure resolvconf $ dpkg-reconfigure tzdata
- 退出模拟器并制作容器
$exit $ sudo bash ch-mount.sh -u /root/rootfs/ubuntu-rootfs $ dd if=/dev/zero of=ubuntu-rootfs.img bs=1M count=4096
- 制作镜像
$ sudo mkfs.ext4 ubuntu-rootfs.img $ mkdir ubuntu-mount $ sudo mount ubuntu-rootfs.img /root/rootfs/ubuntu-mount/ $ sudo cp -rp /root/rootfs/ubuntu-rootfs/* /root/rootfs/ubuntu-mount/ $ sudo umount /root/rootfs/ubuntu-mount $ e2fsck -p -f ubuntu-rootfs.img $ resize2fs -M ubuntu-rootfs.img
- 将
ubuntu-rootfs.img
下载回本地/out目录下
我比较喜欢建立一个简单的http服务器下载$ wget https://github.com/sssvip/simple-file-server/releases/download/v0.1.1/simple-file-server_0.1.1_linux_amd64.tar.gz $ tar -zxf simple-file-server_0.1.1_linux_amd64.tar.gz $ chmod 777 simplefileserver $ ./simplefileserver 8080
访问ip:8080可见ubuntu-rootfs.img,使用IDM下载速度飞快。
- 在/root下创建文件夹
-
以上便是我折腾开发板系统的教程,全是自学,没啥基础,不免有错,欢迎纠正,共同学习。