前言:

这篇文章介绍如何构建一个完整基于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:

  1. Build the whole system in host PC with Chroot(emulator)

  2. Build in a removable media device, such as: SDCard or UDisk

  3. Build in the target device directly 【current article】

Before starting

Carry on the following questions before you start your work:

Q: What is included in an ubuntu system?

A: Bootloader & ramfs(kernel + initrd) & rootfs

Q: how to manage your ubuntu projects

A: Continue current reading and think about your own manage mothod.

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
  1. Download the bootloader source code
$ git clone https://github.com/geekboxzone/lollipop_u-boot u-boot
  1. Download the linux kernel source code
$ git clone https://github.com/geekboxzone/lollipop_kernel -b ubuntu linux
  1. Download the toolchain
$ 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*
  1. Download the initrd
$ git clone https://github.com/gouwa/initrd.git initrd
  1. Download the hardware packages for Geekbox
$ git clone https://github.com/geekboxzone/ubuntu_hwpacks.git archives/hwpacks
  1. Download the ubuntu-core
$ 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:
# [url]http://cdimage.ubuntu.com/ubuntu-core/releases[/url]
  1. Download the rockchip upgrade tool, note to specify the 'ubuntu' branch:
$ 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
  1. Download the rockchip mkbootimg tools
$ 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/``` *See utils/mkbootimg/README.md file for more information* All the preparatory works above are necessary to build an ubuntu. And we also offter some scripts to do thus work: 10. [Optional]Download the scripts:
```bash
$ git clone https://github.com/geekboxzone/ubuntu_scripts.git scripts

All the steps above just need to run one time, even if you will build the Ubuntu system many times.

Build the bootloader

  1. Compile:
$ make rk3368_box_defconfig -C u-boot/$ make ARCHV=aarch64 -C u-boot/
  1. Copy the images to the image directory:
$ cp -a u-boot/RK3368MiniLoaderAll_V*.bin u-boot/uboot.img u-boot/trust.img images/

Build the initial ramdisk

  1. Compile the kernel
$ 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
  1. Copy the images to the image directory:
$ cp -a linux/resource.img images/
  1. Compile the initrd
$ make -C initrd

SHA match for u-boot:

$ truncate -s '%4' images/initrd.img

#View SecureNSModeBootImageShaCheck() function in following file for the information:
#u-boot/board/rockchip/common/SecureBoot/SecureVerify.c
  1. Generate the ramfs.img
$ mkbootimg --kernel linux/arch/arm64/boot/Image --ramdisk images/initrd.img -o images/ramfs.img

Build the rootfs

Notice: Many following steps need the root privileges, do not forget to type sudo if necessary.

  1. Create a blank image file using dd:
$ dd if=/dev/zero of=images/rootfs.img bs=1M count=256

# Modify the count value as you want.

# NOTE: if you want to build the rootfs on the host PC, recommend 2.5GB for GUI building.
  1. Create linux filesystem on the newly created image:
$ 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:

[quote]Gave up waiting for root device.  Common problems:

 - Boot args (cat /proc/cmdline)

   - Check rootdelay= (did the system wait long enough?)

   - Check root= (did the system wait for the right device?)

 - Missing modules (cat /proc/modules; ls /dev)

ALERT!  /dev/disk/by-label/ does not exist.  Dropping to a shell!

(initramfs)[/quote]
  1. Confirm that rootfs is an empty directory!!!
$ rm -rf rootfs && mkdir rootfs
  1. Loop mount the the new image:
$ sudo mount -o loop images/rootfs.img rootfs
  1. Remove the unnecessary files
$ sudo rm -rf rootfs/lost+found
  1. Extract the ubuntu-core tarball into the mounted dir:
$ 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.
  1. Add hardware packages
$ sudo cp -a archives/hwpacks/system/ rootfs/
  1. Add Wifi & Bluetooth support
$ 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
`` 9. Setup serial console, booting as root user:
```bash
$ sudo sed -e 's/tty1/ttyS2/g' -e '/^exec/c exec /sbin -a root -L 115200 ttyS2 vt100' < rootfs/etc/init/tty1.conf > ttyS2.conf
$ sudo mv ttyS2.conf rootfs/etc/init/ttyS2.conf
  1. Setup the hostname:
$ echo Geekbox > hostname$ sudo mv hostname rootfs/etc/hostname

Congratulations!

At this point, you have completed all the minimal-ubuntu images.

And so, all you should do is to burn these images down to device.

Download the images

  1. Download the U-Boot first-level loader
$ upgrade_tool ul images/RK3368MiniLoaderAll_V2.40.bin
  1. Download the parameter
$ upgrade_tool di -p utils/rockdev/parameter
  1. Download the U-Boot second-level loader
$ upgrade_tool di uboot images/uboot.img$ upgrade_tool di trust images/trust.img
  1. Download the resource.img
$ upgrade_tool di resource images/resource.img
  1. Download the ramfs.img
$ upgrade_tool di ramfs images/ramfs.img
  1. Download the rootfs.img
$ upgrade_tool di linuxroot images/rootfs.img
  1. Boot the device
$ upgrade_tool rd

# Notice: root access is necessary if you haven't setup udev rules.
#View our Wiki for more information:[url]http://forum.geekbox.tv/viewtopic.php?f=2&t=42[/url]

Graphic desktop environment

NOTE: The following commands need run on your Geekbox target!

  1. Plug-in a cable, then setup the network:
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
  1. Extend the root partition:
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].
  1. Install desktop packages
root@Geekbox:~# apt-get update
root@Geekbox:~# apt-get upgrade
root@Geekbox:~# apt-get install ubuntu-desktop
  1. [Optional]For bad network environment, such as: China.

Backup the ubuntu deb packages:

root@Geekbox:~# apt-get install openssh-server
root@Geekbox:~# scp /var/cache/apt/archives/*.deb gouwa@192.168.1.168:project/geekbox/ubuntu/archives/debs # If you did this, next time when you rebuilt the ubuntu system,
# you can manually pull the deb packages into the apt debs archives path of target-device: # root@Geekbox:~# scp gouwa@192.168.1.168: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.
  1. Reboot and enjoy your hard but challenging work
root@Geekbox:~# reboot

T.B.D.

1> ubuntu system depth optimization

2> Building the arm64 ubuntu system

References

  1. [url]http://androtab.info/miniroot/[/url]

  2. [url]http://androtab.info/radxa_rock/ubuntu/[/url]

  3. [url]http://wiki.radxa.com/Rock/ubuntu[/url]

  4. [url]http://wiki.t-firefly.com/index.php/Firefly-RK3288/en[/url]

  5. [url]https://wiki.ubuntu.com/ARM/RootfsFromScratch[/url]

  6. [url]https://github.com/neo-technologies/rockchip-mkbootimg[/url]

  7. [url]https://github.com/neo-technologies/rkflashtool.git[/url]

  8. [url]https://wiki.debian.org/initramfs[/url]

  9. [url]http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/ramfs-rootfs-initramfs.txt?id=HEAD[/url]

Arm-Linux 移植 Ubuntu的更多相关文章

  1. arm linux 移植 x265

    背景 本来想着把 x265编译到ffmpeg里面,搞定了x265的编译:但是一直报ERROR: x265 not found using pkg-config这个错误,我按照网上的资料,查看了ffbu ...

  2. Linux 安装 go 以及 arm linux 移植 go

    背景 Go是一门全新的静态类型开发语言,具有自动垃圾回收,丰富的内置类型,函数多返回值,错误处理,匿名函数,并发编程,反射等特性. 从Go1.4之后Go语言的编译器完全由Go语言编写,所以为了从源代码 ...

  3. arm linux 移植支持 HP打印机

    背景 由于业务需要,需要hi3531d主板上加入对于HP打印机的支持. 通过与产品经理,技术主管的沟通:通用支持是不现实的,只要求彩色打印,先不考虑打印机的价格,只要支持一款打印机即可. 注意: Li ...

  4. arm linux 移植 MQTT (paho、mosquitto)

    前言 我们在这里做2件事情: 1)编译 paho.mqtt.mosquitto 2个开源项目的c版本库(mosquitto库没有用上) 2)编译好 依赖 paho.mqtt的库编写例程 + mosqu ...

  5. arm linux 移植 ffmpeg 库 + x264

    背景 Ffmpeg 中带有h264的解码,没有编码,需要添加x264.libx264是一个自由的H.264编码库,是x264项目的一部分,使用广泛,ffmpeg的H.264实现就是用的libx264. ...

  6. arm linux 移植 PHP

    背景: PHP 是世界上最好的语言. host平台 :Ubuntu 16.04 arm平台 : 3531d arm-gcc :4.9.4 php :7.1.30 zlib :1.2.11 libxml ...

  7. arm linux 移植 gdb/gdbserver

    背景 调试工具gdb的使用对于嵌入式Linux开发人员来说是一项不可少的技能. 目前,嵌入式 Linux系统中,主要有三种远程调试方法,分别适用于不同场合的调试工作:用ROM Monitor调试目标机 ...

  8. arm linux 移植 rsync

    背景: 在产品开发中可以使用rsync进行大文件的拷贝,断点续传. host平台 :Ubuntu 16.04 arm平台 : 3531d   rsync   :3.1.3 arm-gcc :4.9.4 ...

  9. arm linux 移植 jpeg

    背景: host平台 :Ubuntu 16.04 arm平台 : S5P6818 jpeg :v9c arm-gcc :4.8.1 主机准备: 运行以下脚本: ## # Copyright By Sc ...

  10. arm linux 移植 udhcp 与 使用

    背景 在一些网络环境下,需要静态IP不够现实,需要使用DHCP进行自动获取IP地址. udhcpc是一个面向嵌入式系统的非常小的DHCP客户端,字母的缩写微μ- DHCP -客户端client(μDH ...

随机推荐

  1. web优化(一 前端)

    当我们在浏览器地址栏中输入一个URL的时候,网页开始请求,我们在页面上看到的内容就是许多个HTTP请求从服务器返回的数据展示,这些展示的快慢很大程度依赖前端的优化,怎样做好前端的优化,我这里总结了几点 ...

  2. centos7使用docker制作tomcat本地镜像

    1.安装Docker 安装docker前请确认当前linux的内核版必须是3.10及以上 命令: uname  -r 1).yum install -y yum-utils device-mapper ...

  3. vue 之 axios Vue路由与element-UI

    一. 在组件中使用axios获取数据 1. 安装和配置axios 默认情况下,我们的项目中并没有对axios包的支持,所以我们需要下载安装. 在项目根目录中使用 npm安装包 npm install ...

  4. Servlet 学习(六)

    会话 1.定义 一般意义会话:指两人以上的对话(多用于学习别种语言或方言时) 计算机中的会话:客户端和服务器的通讯 web客户端 A ------>Tomcat web客户端 B ------& ...

  5. Codeforces 601A:The Two Routes 宽搜最短路径

    A. The Two Routes time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. bash脚本编程

    一.bash中的变量 变量类型: 本地变量:只对当前shell进程有效,对其子shell以及其它shell都无效;   定义变量:[set]Var_name="value" 变量赋 ...

  7. 【PAT甲级】1005 Spell It Right (20 分)

    题意: 给出一个非零整数N(<=10^100),计算每位之和并用英文输出. AAAAAccepted code: #include<bits/stdc++.h> using name ...

  8. 自定义Toast排队重复显示问题:

    原文 http://blog.csdn.net/baiyuliang2013/article/details/38655495Toast是安卓系统中,用户误操作时或某功能执行完毕时,对用户的一种提示, ...

  9. Codeforces1307C. Cow and Message

    读题,我们知道选1个.选2个的时候是没有冲突的,大于2个的时候就有限制,那么我们观察是否可以把大于2个的情况都转换一下,可以发现,如果有一个串的长度大于2,且出现的次数大于2,那么,组成这个串里必定有 ...

  10. uniGUI之学习方法(18)

    官方例子D:\Program Files\FMSoft\Framework\uniGUI\Demos\Desktop 在Design里Main上右键,View as Form看到变化的属性. 看出变化 ...