进迭bianbu系统制作指南
前言
本文记录了在 Ubuntu 宿主机上,通过 Docker + qemu-user-static 交叉构建环境,从零制作 K1 MUSE Pi — Bianbu 2.1 ROOTFS 的完整流程,最终生成可烧录的 bootfs.ext4 和 rootfs.ext4 分区镜像。
1 环境要求
宿主机:Ubuntu 20.04 / 22.04
Docker CE:已安装
安装定制版 qemu-user-static
# 卸载冲突包
sudo apt-get purge binfmt-support
# 下载安装
wget https://archive.spacemit.com/qem ... 3.23.10.1_amd64.deb
sudo dpkg -i qemu-user-static_8.0.4+dfsg-1ubuntu3.23.10.1_amd64.deb
# 注册并验证
sudo systemctl restart systemd-binfmt.service
wget https://archive.spacemit.com/qemu/rvv && chmod a+x rvv && ./rvv
2构建rootfs
# 启动容器
mkdir ~/bianbu-workspace
docker run --privileged -itd -v ~/bianbu-workspace:/mnt \
--name build-bianbu-rootfs harbor.spacemit.com/bianbu/bianbu:latest
docker exec -it -w /mnt build-bianbu-rootfs bash
# 下载解压基础 rootfs
export BASE_ROOTFS_URL=https://archive.spacemit.com/bianbu-base/bianbu-base-24.04-base-riscv64.tar.gz
export TARGET_ROOTFS=rootfs
wget $BASE_ROOTFS_URL
mkdir -p $TARGET_ROOTFS && sudo tar -zxpf $(basename $BASE_ROOTFS_URL) -C $TARGET_ROOTFS
# 挂载系统资源
sudo mount -t proc /proc $TARGET_ROOTFS/proc
sudo mount -t sysfs /sys $TARGET_ROOTFS/sys
sudo mount -o bind /dev $TARGET_ROOTFS/dev
sudo mount -o bind /dev/pts $TARGET_ROOTFS/dev/pts
3 配置与安装
# DNS
sudo bash -c 'echo "nameserver 8.8.8.8" > $TARGET_ROOTFS/etc/resolv.conf'
# 软件源(v2.1)
export REPO="archive.spacemit.com/bianbu"
cat <<EOF | sudo tee $TARGET_ROOTFS/etc/apt/sources.list.d/bianbu.sources
Types: deb
URIs: https://$REPO/
Suites: noble/snapshots/v2.1 noble-security/snapshots/v2.1 noble-updates/snapshots/v2.1 noble-porting/snapshots/v2.1 noble-customization/snapshots/v2.1 bianbu-v2.1-updates
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/bianbu-archive-keyring.gpg
EOF
# 安装硬件包
sudo chroot $TARGET_ROOTFS /bin/bash -c "apt-get update"
sudo chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades upgrade"
sudo chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install initramfs-tools"
sudo chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-esos img-gpu-powervr k1x-vpu-firmware k1x-cam spacemit-uart-bt spacemit-modules-usrload opensbi-spacemit u-boot-spacemit linux-generic"
# 安装元包(桌面版示例)
sudo chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-minimal"
sudo chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-desktop bianbu-desktop-zh bianbu-desktop-en bianbu-desktop-minimal-en bianbu-standard bianbu-development"
# 修复 DTB 名称
sudo mkdir -p $TARGET_ROOTFS/boot/spacemit/6.6.63
sudo cp $TARGET_ROOTFS/usr/lib/linux-image-6.6.63/spacemit/k1-x_MUSE-Pi.dtb \
$TARGET_ROOTFS/boot/spacemit/6.6.63/mlk-k1-x_MUSE-Pi.dtb
# 清理缓存
sudo chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get clean"
4 通用配置
# 时区 → 上海
sudo chroot $TARGET_ROOTFS /bin/bash -c "echo 'tzdata tzdata/Areas select Asia' | debconf-set-selections"
sudo chroot $TARGET_ROOTFS /bin/bash -c "echo 'tzdata tzdata/Zones/Asia select Shanghai' | debconf-set-selections"
sudo chroot $TARGET_ROOTFS /bin/bash -c "rm -f /etc/timezone /etc/localtime"
sudo chroot $TARGET_ROOTFS /bin/bash -c "dpkg-reconfigure --frontend=noninteractive tzdata"
# root 密码
sudo chroot $TARGET_ROOTFS /bin/bash -c "echo root:bianbu | chpasswd"
# 时间服务器
sudo sed -i 's/^#NTP=.*/NTP=ntp.aliyun.com/' $TARGET_ROOTFS/etc/systemd/timesyncd.conf
5 生成分区镜像
# 1. 取消挂载
sudo umount -l $TARGET_ROOTFS/proc
sudo umount -l $TARGET_ROOTFS/sys
sudo umount -l $TARGET_ROOTFS/dev/pts
sudo umount -l $TARGET_ROOTFS/dev
# 2. 写入 fstab
UUID_BOOTFS=$(uuidgen)
UUID_ROOTFS=$(uuidgen)
cat <<EOF | sudo tee $TARGET_ROOTFS/etc/fstab
UUID=$UUID_ROOTFS / ext4 defaults,noatime,errors=remount-ro 0 1
UUID=$UUID_BOOTFS /boot ext4 defaults 0 2
EOF
# 3. 分离 boot
mkdir -p bootfs
sudo mv $TARGET_ROOTFS/boot/* bootfs
# 4. 生成镜像
mke2fs -d bootfs -L bootfs -t ext4 -U $UUID_BOOTFS bootfs.ext4 "230M"
sudo mke2fs -d $TARGET_ROOTFS -L rootfs -t ext4 -N 2097152 -U $UUID_ROOTFS rootfs.ext4 16384M
最终得到 bootfs.ext4 和 rootfs.ext4,可通过 fastboot 烧录到 进迭K1 MUSE Pi。
|