目录
获取ubuntu-base
到ubuntu官网下载Ubuntu-base https://cdimage.ubuntu.com/ubuntu-base/releases/20.04.5/release/
cd ~/hi3798mv100/rootfs
mkdir ubuntu_rootfs
sudo tar -xzvf ubuntu-base-20.04.5-base-armhf.tar.gz -C ubuntu_rootfs
sudo cp /etc/resolv.conf ubuntu_rootfs/etc/resolv.conf #配置网络域名解析
sudo vi ubuntu_rootfs/etc/apt/sources.list #替换软件源
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
这里使用清华软件源更多详情查看https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu-ports/
#1.安装qemu-user-static仿真器
sudo apt install qemu-user-static
#2.拷贝 qemu-aarch64-static 到 ubuntu_rootfs/usr/bin/ 目录下。
sudo cp /usr/bin/qemu-aarch64-static ubuntu_rootfs/usr/bin/
编写挂载脚本
#!/bin/bash
function mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
#sudo mount -t devpts -o gid=5,mode=620 devpts ${2}dev/pts
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
function umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ];
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or both parameters were missing"
echo ""
echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full path of rootfs directory(with tralling '/')"
echo ""
echo "For example: ch-mount -m /media/sdcard"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : $[2]
fi
#增加脚本执行权限
sudo chmod +x mount.sh
#挂载根文件系统
./mount.sh -m ubuntu_rootfs/
#退出根文件系统
exit
#卸载根文件系统
./mount.sh -u ubuntu_rootfs/
挂载ubuntu_rootfs
./mount.sh -m ubuntu_rootfs/
接下来的操作将在ubuntu-base 20.04 rootfs中进行
更新软件源
apt update
Ign:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal InRelease
Ign:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-updates InRelease
Ign:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-backports InRelease
Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Err:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal Release
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Err:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-updates Release
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Err:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-backports Release
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown. Could not handshake: Error in the certificate verification. [IP: 101.6.15.130 443]
Reading package lists... Done
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal-updates/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal-backports/InRelease: No system certificates available. Try installing ca-certificates.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal-updates/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/dists/focal-backports/Release: No system certificates available. Try installing ca-certificates.
E: The repository 'https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-backports Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
这种报错需要修改软件源/etc/apt/sources.list 将其中的https全部替换成http
exit
sudo ./mount.sh -u ubuntu_rootfs/
sudo vi ubuntu_rootfs/etc/apt/sources.list #修改成http
sudo ./
apt update #此时应该可以成功更新
安装常用软件
apt install sudo vim language-pack-en-base
apt install systemd #安装系统服务管理器,安装过程需要手动选择地区
apt install net-tools #包含ifconfig命令
apt install usbutils #包含lsusb命令
apt install iputils-ping #包含ping命令
apt install htop #htop命令查看系统资源情况与负载
apt install ifupdown #网络管理工具,会创建/etc/network目录并生成interfaces配置文件
apt install udev #设备管理,能够将串口作为控制台
启动systemd系统与服务管理器
ln -s /lib/systemd/systemd /sbin/init
## 账号设置
```bash
passwd root #设置root用户密码
adduser ubuntu #新增普通用户“ubuntu”
passwd ubuntu
为普通用户增加sudo权限
vi /etc/sudoers
在root ALL=(ALL:ALL) ALL下一行添加ubuntu ALL=(ALL:ALL) ALL
网络 DHCP 配置
echo auto eth0 > /etc/network/interfaces.d/eth0
echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
设置本机名称和ip地址
echo "hi3798mv100" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 hi3798mv100" >> /etc/hosts
清理apt
apt autoremove
apt-get autoclean
apt-get clean
apt clean
退出根文件系统
exit
./mount.sh -u ubuntu_rootfs/
打包rootfs
创建打包脚本
vi img.sh
#!/bin/bash
set -x
rootfs=$(mktemp -d)
dd if=/dev/zero of=$1 bs=1M count=1500
mkfs.ext4 -F -L linuxroot $1
mount $1 $rootfs
cp -rfp $2* $rootfs
umount $rootfs
e2fsck -p -f $1
resize2fs -M $1
执行脚本
sudo ./img.sh rootfs.img ubuntu_rootfs/
ubuntu:~/hi3798mv100/rootfs$ ll -h
total 440M
drwxrwxr-x 3 marsa marsa 4.0K Mar 24 17:52 ./
drwxrwxr-x 4 marsa marsa 4.0K Mar 24 15:05 ../
-rwxrwxr-x 1 marsa marsa 195 Mar 24 17:50 img.sh*
-rwxrwxr-x 1 marsa marsa 859 Mar 24 15:06 mount.sh*
-rw-r--r-- 1 root root 577M Mar 24 17:55 rootfs.img
-rw-rw-r-- 1 marsa marsa 23M Mar 24 15:33 ubuntu-base-20.04.5-base-armhf.tar.gz
drwxrwxr-x 17 marsa marsa 4.0K Mar 24 16:28 ubuntu_rootfs/
rootfs大小修改
修改分区表
生成的rootfs镜像577MB远超了SDK编译出的分区表规定范围,这会导致内核挂载不上rootfs。
首先修改分区表。
修改后类似下图,把rootfs长度改为-把cadata分区删除
修改fastboot参数
烧录完镜像启动机顶盒
Press Ctrl+C to stop autoboot
fastboot# <INTERRUPT>
fastboot# <INTERRUPT>
fastboot# <INTERRUPT>
fastboot# <INTERRUPT>
fastboot# <INTERRUPT> #ctrl + c 取消自动启动
fastboot# printenv #查看环境变量
baudrate=115200
ipaddr=192.168.1.10
netmask=255.255.255.0
gatewayip=192.168.1.1
serverip=192.168.1.1
bootcmd=mmc read 0 0x1FFFFC0 0x21000 0x4000;bootm 0x1FFFFC0
bootargs_512M=mem=512M mmz=ddr,0,0,320M vmalloc=500M
bootargs_768M=mem=768M mmz=ddr,0,0,400M vmalloc=500M
bootargs_1G=mem=1G mmz=ddr,0,0,400M vmalloc=500M
bootargs_2G=mem=2G mmz=ddr,0,0,600M vmalloc=500M
bootargs=console=ttyAMA0,115200 root=/dev/mmcblk0p12 rootfstype=ext4 rootwait blkdevparts=mmcblk0:1M(boot),1M(bootargs),4M(baseparam),4M(pqparam),4M(logo),4M(deviceinfo),4M(softwareinfo),4M(loaderdb),32M(loader),8M(trustedcore),8M(kernel),128M(rootfs),8M(cadata),-(others)
bootdelay=0
stdin=serial
stdout=serial
stderr=serial
ethaddr=2A:95:54:F6:55:BF
ver=Fastboot 3.3.0 (xtao@ubuntu) (May 05 2017 - 11:31:39)
Environment size: 775/65532 bytes
bootargs内核参数指定了串口号为ttyAMA0,这也是上文制作rootfs时链接串口终端时使用ttyAMA0端口号的原因
修改bootargs中的分区信息
setenv bootargs console=ttyAMA0,115200 root=/dev/mmcblk0p12 rootfstype=ext4 rootwait blkdevparts=mmcblk0:1M(boot),1M(bootargs),4M(baseparam),4M(pqparam),4M(logo),4M(deviceinfo),4M(softwareinfo),4M(loaderdb),32M(loader),8M(trustedcore),8M(kernel),-(ubuntu)
saveenv
reset
至此能够挂载rootfs,但是内核还需要配置dev挂载并打开cgroup才能完成进入到登录linux账号阶段
内核配置
修改Makefile
查看编译SDK时make做了什么事情
ubuntu:~/hi3798mv100/HiSTBLinuxV100R005C00SPC050$ pwd
/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050
ubuntu:~/hi3798mv100/HiSTBLinuxV100R005C00SPC050$ source env.sh
ubuntu:~/hi3798mv100/HiSTBLinuxV100R005C00SPC050$ make build -n
make prebuilts_compose
echo "make prebuilts over"
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/boot all O=/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/boot
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/tools/linux/utils all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/rootfs all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/common/api all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/api all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/api/higo all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/api/jpeg all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/api/png all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/api/gpu all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/api/omx all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/component all
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/component/directfb all
make rootbox_compose
echo "rootbox is ready"
make cramfs squashfs extfs
rm -rf /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/image/hi_kernel.bin /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/image/apploader.bin /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/image/rootfs.squashfs
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/sample all
make signature
#### make "build -n" completed successfully! ####
定位到了编译内核的指令,再次查看是如何编译内核的
ubuntu:~/hi3798mv100/HiSTBLinuxV100R005C00SPC050$ make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel all -n
make: Entering directory '/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel'
test -d /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/image/emmc_image || mkdir -p /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/image/emmc_image
(cd /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y/drivers && rm -rf common && ln -s /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/common/drv common)
(cd /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y/drivers && rm -rf msp && ln -s /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/msp/drv msp)
(cd /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y/drivers && rm -rf wifi && ln -s /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/component/wifi/drv wifi)
(cd /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y/drivers && rm -rf bluetooth_usb && ln -s /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/component/bluetooth/drv bluetooth_usb)
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y ARCH=arm \
CROSS_COMPILE=arm-histbv310-linux- \
O=/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y \
\
CFLAGS_KERNEL= AFLAGS_KERNEL= hi3798mv100_defconfig
make pcie_config
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y ARCH=arm \
CROSS_COMPILE=arm-histbv310-linux- \
O=/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y \
\
CFLAGS_KERNEL= AFLAGS_KERNEL= oldconfig
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y ARCH=arm \
CROSS_COMPILE=arm-histbv310-linux- \
O=/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y \
CONFIG_MSP=y \
HI_CONFIG_WIFI= \
HI_CONFIG_BLUETOOTH= \
CONFIG_ADVCA= \
\
CFLAGS_KERNEL= AFLAGS_KERNEL= uImage modules
cp -f /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y/arch/arm/boot/uImage /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/image/emmc_image/hi_kernel.bin
mkdir -p /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/kmod/usb
cp -f /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y/drivers/usb/host/*.ko /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/kmod/usb/
(for file in ; do ( \
mkdir -p /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/kmod/sata && cp $file /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/kmod/sata/ \
) done )
(find /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y/drivers/common -name "*.ko" | xargs cp -f -t /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/kmod/)
(find /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y/drivers/msp -name "*.ko" | xargs cp -f -t /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/kmod/)
make: Leaving directory '/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel'
#### make "-C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel all -n" completed successfully! ####
这段是我们需要的代码,实际完成编译内核的工作
make -C /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y ARCH=arm \
CROSS_COMPILE=arm-histbv310-linux- \
O=/home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y \
CONFIG_MSP=y \
HI_CONFIG_WIFI= \
HI_CONFIG_BLUETOOTH= \
CONFIG_ADVCA= \
\
CFLAGS_KERNEL= AFLAGS_KERNEL= uImage modules
把变量写到Makefile文件中
KBUILD_OUTPUT的路径要根据自己的机器做出修改
这样就可以通过make menuconfig 和 make uImage完成内核配置与编译
ubuntu:~/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y$ git diff Makefile
diff --git a/source/kernel/linux-4.4.y/Makefile b/source/kernel/linux-4.4.y/Makefile
index ff936c886..2d3be4f1c 100644
--- a/source/kernel/linux-4.4.y/Makefile
+++ b/source/kernel/linux-4.4.y/Makefile
@@ -72,7 +72,7 @@ endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
-
+KBUILD_VERBOSE = 1
ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
@@ -120,7 +120,7 @@ ifeq ($(KBUILD_SRC),)
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif
-
+KBUILD_OUTPUT := /home/marsa/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y
# That's our default target when none is given on the command line
PHONY := _all
_all:
@@ -252,6 +252,8 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
# "make" in the configured kernel build directory always uses that.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
+ARCH :=arm
+CROSS_COMPILE :=arm-histbv310-linux-
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
@@ -259,6 +261,13 @@ CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
UTS_MACHINE := $(ARCH)
SRCARCH := $(ARCH)
+CONFIG_MSP:=y
+HI_CONFIG_WIFI:=
+HI_CONFIG_BLUETOOTH:=
+CONFIG_ADVCA:=
+CFLAGS_KERNEL:=
+AFLAGS_KERNEL:=
+
# Additional ARCH settings for x86
ifeq ($(ARCH),i386)
SRCARCH := x86
内核配置
ubuntu:~/hi3798mv100/HiSTBLinuxV100R005C00SPC050/source/kernel/linux-4.4.y$make menuconfig
配置dev
键入/搜索devtmp 确保这两个配置项都打开了,按下数字 1 2 可快速定位到配置项
配置cgroups
确保cgroups打开
至此rootfs已经可以成功启动。使得linux正常工作还需要继续配置
配置ANDROID_PARANOID_NETWORK
ANDROID_PARANOID_NETWORK默认是打开的,这里我们需要关闭它,不然没法正常上网
配置USB
这三个配置项默认是编译成模块,这里把它们修改成编译进内核
配置CH340驱动(非必要)
make uImage -j16
生成的内核镜像是
~/hi3798mv100/HiSTBLinuxV100R005C00SPC050/out/hi3798mv100/hi3798mdmo1f/obj/source/kernel/linux-4.4.y/arch/arm/boot/uImage
烧录完成扩容rootfs
root@hi3798mv100:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
mmcblk0 179:0 0 7.3G 0 disk
|-mmcblk0p1 179:1 0 1M 0 part
|-mmcblk0p2 179:2 0 1M 0 part
|-mmcblk0p3 179:3 0 4M 0 part
|-mmcblk0p4 179:4 0 4M 0 part
|-mmcblk0p5 179:5 0 4M 0 part
|-mmcblk0p6 179:6 0 4M 0 part
|-mmcblk0p7 179:7 0 4M 0 part
|-mmcblk0p8 259:0 0 4M 0 part
|-mmcblk0p9 259:1 0 32M 0 part
|-mmcblk0p10 259:2 0 8M 0 part
|-mmcblk0p11 259:3 0 8M 0 part
`-mmcblk0p12 259:4 0 7.2G 0 part /
mmcblk0boot0 179:8 0 4M 1 disk
mmcblk0boot1 179:16 0 4M 1 disk
mmcblk0rpmb 179:24 0 4M 0 disk
mmcblk1 179:32 0 14.9G 0 disk
|-mmcblk1p1 179:33 0 14.9G 0 part
`-mmcblk1p2 179:34 0 57M 0 part
root@hi3798mv100:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 737M 479M 204M 71% /
devtmpfs 291M 0 291M 0% /dev
tmpfs 291M 0 291M 0% /dev/shm
tmpfs 59M 64K 59M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 291M 0 291M 0% /sys/fs/cgroup
root@hi3798mv100:~# resize2fs /dev/mmcblk0p12
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mmcblk0p12 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p12 is now 1889792 (4k) blocks long.
root@hi3798mv100:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.1G 483M 6.3G 7% /
devtmpfs 291M 0 291M 0% /dev
tmpfs 291M 0 291M 0% /dev/shm
tmpfs 59M 64K 59M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 291M 0 291M 0% /sys/fs/cgroup
后言
Ubuntu20.04 rootfs 制作与网上教程大致一样,本人照葫芦画瓢的结果就是最后kernel没有找到合适的初始化进程最后选择了最低优先级的/bin/sh作为初始进程。结果就是pid 1 的进程是sh,这很难搞。
最后安装了systemd并创建符号链接/sbin/init才让rootfs看起来比较靠谱。
不清楚为什么网上的教程不需要安装systemd
参考链接
https://blog.csdn.net/weixin_46025014/article/details/131682463
https://www.cnblogs.com/milton/p/17599562.html
https://www.jianshu.com/p/0a0066d10190