简介
让一个arm的开发板跑Ubuntu需要什么呢?
- Bootloader
这里选用官方给的uboot,用于引导初始化配置cpu。 - linux内核
这里选用官方给的linux4.13 - 根文件系统
这里用Ubuntu-base,好处就是不用编译直接用 - 64位虚拟机
推荐vmware16
虚拟机
在电脑上安装vmware16,自己找安装包和激活码,然后去下面这个网址安装Ubuntu20.04或者其他版本的镜像Ubuntu20.04桌面版下载
安装好后在控制台执行下面命令给Ubuntu的apt换源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.buckup
sudo gedit /etc/apt/sources.list
会弹出个文本编辑器
输入下面的代码
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
然后习惯性更新一下
sudo apt update
sudo apt upgrade
然后安装需要的软件
sudo apt install git make qemu-user-static net-tools gparted vsftpd ssh lsb-core lib32stdc++6
安装交叉编译器,因为我们需要在x86环境下编译arm,下载这个:交叉编译器,或者点击这个链接自己选择版本:交叉编译器
下载好后用filezila传到虚拟机里面。
解压
sudo cp gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz /usr/local/arm/ -f
cd /usr/local/arm/
sudo tar -xf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
sudo gedit /etc/profile
最后面输入如下所示内容:
export PATH=$PATH:/usr/local/arm/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin
最后检查一下安装完成没,用命令行查看一下版本
arm-linux-gnueabihf-gcc -v
开始!
假如我们在目录:/home/你的名字/Licheepi_zero里面
克隆一下uboot,如果下载失败就用迅雷下载这个链接:uboot,或者去这个链接下载:uboot_github
git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current
克隆一下linux,如果下载失败就用迅雷下载这个链接:linux4.13,或者去这个链接下载:linux4.13_github
git clone https://github.com/Lichee-Pi/linux.git -b zero-4.13.y
下载一下ubuntu-base,如果下载失败就去这个链接下载:ubuntu-base16.04
wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04.6-base-armhf.tar.gz
mkdir ubuntu-base-16.04
sudo tar -xzf ubuntu-base-16.04.6-base-armhf.tar.gz -C ./ubuntu-base-16.04
开始编译uboot
假如我们在目录:/home/你的名字/Licheepi_zero里面
cd uboot
touch auto.sh
sudo chmod 777 auto.sh
gedit ./auto.sh
输入下面的代码
下面的LicheePi_Zero_480x272LCD_defconfig可以换成LicheePi_Zero_defconfig
#!/bin/bash
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make distclean
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LicheePi_Zero_480x272LCD_defconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make menuconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j2
退出后,假如我们在目录:/home/你的名字/Licheepi_zero/uboot里面
./auto.sh
中间会跳出一个界面,按两下esc退出,选择ok
等待
等待
ok呢
开始编译linux
假如我们在目录:/home/你的名字/Licheepi_zero里面
cd linux
touch auto.sh
sudo chmod 777 auto.sh
gedit ./auto.sh
输入下面的代码
#!/bin/bash
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make distclean
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make licheepi_zero_defconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make menuconfig
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make -j2 -s
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make dtbs
退出后,假如我们在目录:/home/你的名字/Licheepi_zero/uboot里面
./auto.sh
中间会跳出一个界面,按两下esc退出,选择ok
等待
等待
ok呢
开始准备Ubuntu
假如我们在目录:/home/你的名字/Licheepi_zero里面
cd ubuntu-base-16.04
sudo cp /usr/bin/qemu-arm-static ./usr/bin/
sudo cp /etc/resolv.conf ./etc/resolv.conf
sudo gedit ./etc/apt/sources.list
这里要用 ubuntu16.04 的 ARM 源,不能找成了 X86 的源。
在文本的最后加入下面的代码
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
然后编写挂载的脚本
touch gz.sh xz.sh
sudo chmod 777 gz.sh xz.sh
gedit ./gz.sh
写入下面代码
#!/bin/bash
echo "MOUNTING"
sudo mount -t proc /proc /home/你的名字/Licheepi_zero/ubuntu-base-16.04/proc
sudo mount -t sysfs /sys /home/你的名字/Licheepi_zero/ubuntu-base-16.04/sys
sudo mount -o bind /dev /home/你的名字/Licheepi_zero/ubuntu-base-16.04/dev
sudo mount -o bind /dev/pts /home/你的名字/Licheepi_zero/ubuntu-base-16.04/dev/pts
sudo chroot /home/你的名字/Licheepi_zero/ubuntu-base-16.04
推出后
gedit ./xz.sh
写入下面代码
#!/bin/bash
echo "UNMOUNTING"
sudo umount /home/你的名字/Licheepi_zero/ubuntu-base-16.04/proc
sudo umount /home/你的名字/Licheepi_zero/ubuntu-base-16.04/sys
sudo umount /home/你的名字/Licheepi_zero/ubuntu-base-16.04/dev/pts
sudo umount /home/你的名字/Licheepi_zero/ubuntu-base-16.04/dev
然后就可以进入Ubuntu-base了!
假如我们在目录:/home/你的名字/Licheepi_zero/ubuntu-base-16.04里面
./gz.sh
就会下面这样!
apt update
apt install sudo nano vim kmod net-tools ethtool ifupdown language-pack-en-base rsyslog htop ssh iputils-ping
设置一下root用户的密码
passwd root
设置一下普通用户
adduser 你的名字
设置一下新建的用户可以用sudo命令
su //切换回 root 用户
chmod u+w /etc/sudoers
nano /etc/sudoers
找到“root ALL=(ALL:ALL) ALL”这一行
加入
你的名字 ALL= NOPASSWD:ALL
最重要的来了设置一下串口终端
ls /etc/systemd/system/getty.target.wants/gett*
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyS0.service
这样就可以用uart0控制荔枝派啦
。
。
。
。
。
。
。
。
。
。
。
。
。
。
。
后面的东西再说