这篇文章介绍如何构建一个完整基于ARM的Ubuntu系统。
由于改文章当初写的时候是发表在国外产品论坛上面,故保留了原文内容。
使用到的硬件平台:Geekbox
补充说明:
虽然Geekbox是基于8核64Bits Cortex-A53 ARMV8架构的CPU,该方法构建的时候采用了向下兼容的32Bits的ARMV7架构。因此,该方法适用于Cortex-A7/A9/A15/A17/A12架构的ARM处理器。
In this guide, we will describe how to build an ubuntu system for Geekbox from scratch.
Different ways to achieve it:Preparations
1. Create the working directories$ install -d ~/project/geekbox/ubuntu/{linux,initrd,rootfs,prebuilts,archives/{ubuntu-core,debs,hwpacks},images,utils,scripts}
$ cd ~/project/geekbox/ubuntu
$ git clone https://github.com/geekboxzone/lollipop_u-boot u-boot
$ git clone https://github.com/geekboxzone/lollipop_kernel -b ubuntu linux
$ git clone https://github.com/geekboxzone/lollipop_prebuilts_gcc_linux-x86_aarch64_aarch64-linux-android-4.9.git prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/
Note the full path of "prebuilts/gcc/linux-x86/arm/arm-eabi-4.6", just to keep Makefile@linux happy
$ git clone https://github.com/gouwa/initrd.git initrd
$ git clone https://github.com/geekboxzone/ubuntu_hwpacks.git archives/hwpacks
$ wget -P archives/ubuntu-core http://cdimage.ubuntu.com/ubuntu-core/releases/14.04.3/release/ubuntu-core-14.04.3-core-armhf.tar.gz
Visit the following link for the more versions:
$ git clone https://github.com/geekboxzone/utils.git -b ubuntu utils
[Optional]If you want to run the command in any path:
$ sudo cp -a utils/upgrade_tool /usr/local/bin
$ git clone https://github.com/neo-technologies/rockchip-mkbootimg.git mkbootimg
Build and install mkbootimg tools:
$ make -C mkbootimg/
$ sudo make install -C mkbootimg/
The above steps will generate some files in /usr/local/bin/
$ git clone https://github.com/geekboxzone/ubuntu_scripts.git scripts
$ make rk3368_box_defconfig -C u-boot/
$ make ARCHV=aarch64 -C u-boot/
$ cp -a u-boot/RK3368MiniLoaderAll_V*.bin u-boot/uboot.img u-boot/trust.img images/
$ alias Make='make ARCH=arm64'
$ Make -C linux ugeekbox_defconfig
$ Make -C linux geekbox.img -j8
or 7.9-inch CrossDisplay
$ Make -C linux cross.img -j8
$ cp -a linux/resource.img images/
$ make -C initrd
SHA match for u-boot:
$ truncate -s "%4" images/initrd.img
View SecureNSModeBootImageShaCheck() function in following file for the information:
$ mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk images/initrd.img -o images/ramfs.img
$ dd if=/dev/zero of=images/rootfs.img bs=1M count=256
Modify the count value as you want.
$ mkfs.ext4 -F -L linuxroot images/rootfs.img
Notice: "linuxroot" is the volume-label of the rootfs, it MUST BE EXACTLY MATCH the CMDLINE in parameter:
CMDLINE: console=ttyS2 root=LABEL=linuxroot
Otherwise, there will be similar mistakes as follow when mount the rootfs:
$ rm -rf rootfs && mkdir rootfs
$ sudo mount -o loop images/rootfs.img rootfs
$ sudo rm -rf rootfs/lost+found
$ sudo tar xzf archives/ubuntu-core/ubuntu-core-14.04.3-core-armhf.tar.gz -C rootfs/
Tips: ubuntu-core is the minimal root file system.
$ sudo cp -a archives/hwpacks/system/ rootfs/
$ sudo cp archives/hwpacks/wifibt/wifion rootfs/usr/local/bin/
$ sudo cp archives/hwpacks/wifibt/wifioff rootfs/usr/local/bin/
$ sudo cp archives/hwpacks/wifibt/wifi.conf rootfs/etc/init
$ sudo cp archives/hwpacks/wifibt/bluetooth.conf rootfs/etc/init
$ sudo cp archives/hwpacks/wifibt/bluetooth-ap6354.conf rootfs/etc/init
$ sudo sed -e 's/tty1/ttyS2/g' -e '/^exec/c exec /sbin/getty -a root -L 115200 ttyS2 vt100' < rootfs/etc/init/tty1.conf > ttyS2.conf
$ sudo mv ttyS2.conf rootfs/etc/init/ttyS2.conf
$ echo Geekbox > hostname
$ sudo mv hostname rootfs/etc/hostname
$ upgrade_tool ul images/RK3368MiniLoaderAll_V2.40.bin
$ upgrade_tool di -p utils/rockdev/parameter
$ upgrade_tool di uboot images/uboot.img
$ upgrade_tool di trust images/trust.img
$ upgrade_tool di resource images/resource.img
$ upgrade_tool di ramfs images/ramfs.img
$ upgrade_tool di linuxroot images/rootfs.img
$ upgrade_tool rd
Notice: root access is necessary if you haven't setup udev rules.
root@Geekbox:~# echo auto eth0 > /etc/network/interfaces.d/eth0
root@Geekbox:~# echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
root@Geekbox:~# ln -fs /run/resolvconf/resolv.conf /etc/resolv.conf
root@Geekbox:~# ifup eth0
root@Geekbox:~# resize2fs /dev/disk/by-label/linuxroot
Tips: the default volume size of root partition is specify in the first step of [Build the rootfs].
root@Geekbox:~# apt-get update
root@Geekbox:~# apt-get upgrade
root@Geekbox:~# apt-get install ubuntu-desktop
root@Geekbox:~# apt-get install openssh-server
root@Geekbox:~# scp /var/cache/apt/archives/*.deb [email protected]:project/geekbox/ubuntu/archives/debs
If you did this, next time when you rebuilt the ubuntu system,
root@Geekbox:~# scp [email protected]:project/geekbox/ubuntu/archives/debs/*.deb /var/cache/apt/archives/
root@Geekbox:~# apt-get update && apt-get upgrade && apt-get install ubuntu-desktop
This will save you a lot of time to download them from the website.
root@Geekbox:~# reboot
T.B.D.
1> ubuntu system depth optimization