目录
开发环境
硬件:
-
VMWare虚拟机
-
ubuntu18.04系统(4G,120G)
-
瑞芯微的RK3399ProD开发板
软件:
-
交叉编译工具链:aarch64-linux-gnu-
-
烧写工具:AndroidTool_Release_v2.64
-
驱动工具:DriverAssitant_v4.5
uboot移植过程
参考瑞芯微的官方链接
在ubuntu中git uboot源码
git clone https://github.com/rockchip-toybrick/u-boot.git -b master
git clone https://github.com/rockchip-toybrick/rkbin
交叉编译工具(linux-x86)
- 1、在u-boot同级目录创建prebuilts文件夹
- 2、在prebuilts目录下创建gcc文件夹
mkdir prebuilts/gcc -p
- 3、下载交叉编译工具(linux-x86)到gcc目录
cd prebuilts/gcc
git clone https://github.com/rockchip-toybrick/linux-x86.git -b master
修改make.sh设置
进入u-boot目录中,修改make.sh
TOOLCHAIN_ARM32=../prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin
TOOLCHAIN_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin
编译u-boot
cd u-boot
./make.sh rk3399pro
编译成功后得到uboot.img镜像
kernel编译过程
在ubuntu中git kernel源码
在uboot同级目录下下载源码
git clone https://github.com/rockchip-toybrick/kernel.git -b stable
编译kernel
cd kernel
./make.sh linux prod
ubuntu20.04制作
安装 qemu
在 Linux PC 主机上安装模拟器:
sudo apt-get install qemu-user-static
下载和解压 ubuntu-core
GEC3399PRO Ubuntu 根文件系统是基于 Ubuntu base 18.04 来创建的。用户可以到 ubuntu cdimg 下载,选择下载 ubuntu-base-18.04.5-base-arm64.tar.gz
。
下载完之后,创建临时文件夹并解压根文件系统:
mkdir temp
sudo tar -xpf ubuntu-base-18.04.5-base-arm64.tar.gz -C temp
修改根文件系统
准备工作
和temp同级命令中断中输入:
准备网络:
sudo cp -b /etc/resolv.conf temp/etc/resolv.conf
准备 qemu:
sudo cp /usr/bin/qemu-aarch64-static temp/usr/bin/
进入根文件系统进行操作:
sudo chroot temp
更新及安装
- 1、更新:
apt update
apt upgrade
- 2、安装需要的软件
apt install vim git -y
-
3、安装 xubuntu:
apt-get install xubuntu-desktop
可能出现错误:
E: Unable to locate package xxxx
安装包的源没有添加到 /etc/apt/source.list
中,导致无法识别安装包,可以自行添加源,也可以使用下面给出的 source.list
覆盖原来的 /etc/apt/source.list
文件:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates main restricted
## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial universe
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-updates universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-updates universe
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-backports main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security universe
deb http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports/ xenial-security multiverse
-
4、添加用户及设置密码
添加用户:
useradd -s '/bin/bash' -m -G adm,sudo zoroe
给用户设置密码:
passwd zoroe
给root用户设置密码:
passwd root
- 5、串口和终端交互:
ln -s /lib/systemd/system/serial-getty\@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyS0.service
- 6、修改完自己的根文件系统就可以退出了。
exit
制作根文件系统
制作自己的根文件系统,大小依据自己的根文件系统而定,注意依据 temp
文件夹的大小来修改 count
值:
du -sh temp/
mkdir rootfs
dd if=/dev/zero of=linuxroot.img bs=1M count=6144
mkfs.ext4 linuxroot.img
sudo mount linuxroot.img rootfs/
sudo cp -rfp temp/* rootfs/
sudo umount rootfs/
e2fsck -p -f linuxroot.img
resize2fs -M linuxroot.img
这样 linuxroot.img
就是最终的根文件系统映像文件了。
更新系统,登录界面
FAQs
根文件系统加载后,大小不正常,未占满整个分区:
在系统正确加载后执行扩展文件系统命令:
resize2fs /dev/mtd/by-name/linuxroot