行业知识
在基于全志V851se的TinyVision上手动构建 Linux 6.1 + Debian 12 镜像
构建 SyterKit 作为 Bootloader
SyterKit ���一个纯裸机框架,用于 TinyVision 或者其他 v851se/v851s/v851s3/v853 等芯片的开发板,SyterKit 使用 CMake 作为构建系统构建,支持多种应用与多种外设驱动。同时 SyterKit 也具有启动引导的功能,可以替代 U-Boot 实现快速启动
获取 SyterKit 源码
SyterKit 源码位于GitHub,可以前往下载。
git clone GitHub - YuzukiHD/SyterKit: SyterKit is a baremetal framework, As bootloader, MPU framework, Support T113, V853, H618, T527, Running on SRAM
从零构建 SyterKit
构建 SyterKit 非常简单,只需要在 Linux 操作系统中安装配置环境即可编译。SyterKit 需要的软件包有:
- gcc-arm-none-eabi
- CMake
对于常用的 Ubuntu 系统,可以通过如下命令安装
sudo apt-get updatesudo apt-get install gcc-arm-none-eabi cmake build-essential -y
然后新建一个文件夹存放编译的输出文件,并且进入这个文件夹
mkdir buildcd build
然后运行命令编译 SyterKit
cmake ..make
编译后的可执行文件位于 build/app 中,这里包括 SyterKit 的多种APP可供使用。
这里我们使用的是 syter_boot 作为启动引导。进入 syter_boot 文件夹,可以看到这些文件
由于 TinyVision 是 TF 卡启动,所以我们需要用到 syter_boot_bin_card.bin
编译 Linux-6.1 内核
由于 Debian 12 配套的内核是 Linux 6.1 LTS,所以这里我们选择构建 Linux 6.1 版本内核。
搭建编译环境
安装一些必要的安装包
sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf build-essential libncurses5-dev zlib1g-dev gawk flex bison quilt libssl-dev xsltproc libxml-parser-perl mercurial bzr ecj cvs unzip lsof
获取内核源码
内核源码托管在 Github 上,可以直接获取到,这里使用 --depth=1 指定 git 深度为 1 加速下载。
git clone GitHub - YuzukiHD/TinyVision: TinyVision - A Tiny Linux Board / IPC / Server / Router / And so on... --depth=1
然后进入内核文件夹
cd kernel/linux-6.1
配置内核选项
应用 defconfig
CROSS_COMPILE=arm-linux-gnueabihf- make ARCH=arm tinyvision_defconfig
进入 menuconfig 配置选项
CROSS_COMPILE=arm-linux-gnueabihf- make ARCH=arm menuconfig
进入 General Setup ->,选中 Control Group Support
前往 File Systems 找到 FUSE (Filesystem in Userspace) support
前往 File Systems 找到 Inotify support for userspace
编译内核
CROSS_COMPILE=arm-linux-gnueabihf- make ARCH=arm
使用 debootstrap 构建 debian rootfs
准备环境,依赖
下载安装依赖环境
sudo apt install debootstrap qemu qemu-user-static qemu-system qemu-utils qemu-system-misc binfmt-support dpkg-cross debian-ports-archive-keyring --no-install-recommends
生成目标镜像,配置环境,这里我们生成一个 1024M 的镜像文件用于存放 rootfs
dd if=/dev/zero of=rootfs.img bs=1M count=1024mkdir rootfsmkfs.ext4 rootfs.imgsudo mount rootfs.img rootfs
开始构建基础 rootfs
这里我们选择最新的 debian12 (bookwarm) 作为目标镜像,使用清华源来构建,输出到目标目录 rootfs_data 文件夹中。新版本的 debootstrap 只需要运行一次即可完成两次 stage 的操作,相较于老版本方便许多。
sudo debootstrap --arch=armhf bookworm rootfs_data Index of /debian/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
看到 I: Base system installed successfully. 就是构建完成了
等待构建完成后,使用chroot进入到目录,这里编写一个挂载脚本方便挂载使用,新建文件 ch-mount.sh 并写入以下内容:
#!/bin/bashfunction mnt() { echo "MOUNTING" sudo mount -t proc /proc proc sudo mount -t sysfs /sys sys sudo mount -o bind /dev dev sudo mount -o bind /dev/pts dev/pts sudo chroot }function umnt() { echo "UNMOUNTING" sudo umount proc sudo umount sys sudo umount dev/pts sudo umount dev}if [ "" == "-m" ] && [ -n "" ] ;then mnt elif [ "" == "-u" ] && [ -n "" ];then umnt 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 trailing '/')" echo "" echo "For example: ch-mount -m /media/sdcard/" echo "" echo 1st parameter : echo 2nd parameter : fi然后赋予脚本执行的权限
chmod 777 ch-mount.sh
- 使用 ./ch-mount.sh -m rootfs_data 挂载
- 使用 ./ch-mount.sh -u rootfs_data 卸载
执行挂载,可以看到进入了 debian 的 rootfs
配置系统字符集,选择 en_US 作为默认字符集
export LC_ALL=en_US.UTF-8apt-get install localesdpkg-reconfigure locales
选择一个就可以
直接 OK 下一步
安装 Linux 基础工具
apt install sudo ssh openssh-server net-tools ethtool wireless-tools network-manager iputils-ping rsyslog alsa-utils bash-completion gnupg busybox kmod wget git curl --no-install-recommends
安装编译工具
apt install build-essential
安装 Linux nerd 工具
apt install vim nano neofetch
设置本机入口 ip 地址
cat /etc/network/interfaces