Build Bianbu OS 1.0
The Bianbu 1.0 OS Image is based on Ubuntu 23.10.
Compilation environment
The recommended host machine is Ubuntu 20.04/22.04, with docker ce and qemu-user-static (8.0.4, customized version, Vector 1.0 support is enabled by default) installed.
docker
For docker ce installation, please refer to https://docs.docker.com/engine/install/.
qemu
-
Uninstall binfmt-support
The customized version of qemu-user-static conflicts with binfmt-support because the
/etc/init.d/binfmt-supportprovided by binfmt-support is a traditional SysVinit startup script, while the/lib/systemd/system/systemd-binfmt.serviceprovided by the customized version of qemu-user-static is a systemd service unit file./etc/init.d/binfmt-supportwill be executed later than/lib/systemd/system/systemd-binfmt.service, resulting in overwriting systemd settings.sudo apt-get purge binfmt-support -
Download the customized version of qemu
wget https://archive.spacemit.com/qemu/qemu-user-static_8.0.4%2Bdfsg-1ubuntu3.23.10.1_amd64.deb -
Install a customized version of qemu
sudo dpkg -i qemu-user-static_8.0.4+dfsg-1ubuntu3.23.10.1_amd64.deb -
Register qemu-user-static to the kernel so that the entire system (including containers) can directly execute riscv binaries
sudo systemctl start systemd-binfmt.service -
Verify that qemu-user-static is successfully registered
Download the test program:
wget https://archive.spacemit.com/qemu/rvvAdd executable permissions to the test program:
chmod a+x rvvExecute the test program:
./rvvThe following message appears, indicating that the registration is successful.
helloworld
spacemit
Prepare base rootfs
1. Create a working directory
mkdir ~/bianbu-workspace
2. Create and start the container
docker run --privileged -itd -v ~/bianbu-workspace:/mnt --name build-bianbu-rootfs ubuntu:24.04
3. Entering the container
docker exec -it -w /mnt build-bianbu-rootfs bash
4. Install basic tools
apt-get update
apt-get -y install wget uuid-runtime
5. Configure environment variables
export BASE_ROOTFS_URL=https://archive.spacemit.com/bianbu-base/bianbu-base-23.10-base-riscv64.tar.gz
export BASE_ROOTFS=$(basename "$BASE_ROOTFS_URL")
export TARGET_ROOTFS=rootfs
6. Download the base file system
wget $BASE_ROOTFS_URL
7. Extract to the specified directory
mkdir -p $TARGET_ROOTFS && tar -zxpf $BASE_ROOTFS -C $TARGET_ROOTFS
8. Mount some system resources into rootfs
mount -t proc /proc $TARGET_ROOTFS/proc
mount -t sysfs /sys $TARGET_ROOTFS/sys
mount -o bind /dev $TARGET_ROOTFS/dev
mount -o bind /dev/pts $TARGET_ROOTFS/dev/pts
Necessary Configuration
1. Configuring sources
1.1 First, configure the environment variables
export DIST=mantic
export REPO="archive.spacemit.com/bianbu-ports"
export VERSION="v1.0.15"
1.2 Install the public key of the repository
wget -O $TARGET_ROOTFS/usr/share/keyrings/bianbu-archive-keyring-mantic.gpg https://archive.spacemit.com/bianbu-ports/bianbu-archive-keyring.gpg
wget -O $TARGET_ROOTFS/etc/apt/trusted.gpg.d/bianbu-archive-keyring-mantic.gpg https://archive.spacemit.com/bianbu-ports/bianbu-archive-keyring.gpg
1.3 Configure sources.list
cat <<EOF | tee $TARGET_ROOTFS/etc/apt/sources.list
# $DIST
deb https://$REPO/ $DIST/snapshots/$VERSION main universe multiverse restricted
# deb-src https://$REPO/ $DIST/snapshots/$VERSION main universe multiverse restricted
# $DIST-security
deb https://$REPO/ $DIST-security/snapshots/$VERSION main universe multiverse restricted
# deb-src https://$REPO/ $DIST-security/snapshots/$VERSION main universe multiverse restricted
EOF
1.4 Configure sources.list.d/bianbu.list
cat <<EOF | tee $TARGET_ROOTFS/etc/apt/sources.list.d/bianbu.list
# $DIST-spacemit
deb https://$REPO/ $DIST-spacemit/snapshots/$VERSION main universe multiverse restricted
# deb-src https://$REPO/ $DIST-spacemit/snapshots/$VERSION main universe multiverse restricted
# $DIST-porting
deb https://$REPO/ $DIST-porting/snapshots/$VERSION main universe multiverse restricted
# deb-src https://$REPO/ $DIST-porting/snapshots/$VERSION main universe multiverse restricted
# $DIST-customization
deb https://$REPO/ $DIST-customization/snapshots/$VERSION main universe multiverse restricted
# deb-src https://$REPO/ $DIST-customization/snapshots/$VERSION main universe multiverse restricted
EOF
1.5 Configure source priorities
cat <<EOF | tee $TARGET_ROOTFS/etc/apt/preferences.d/bianbu
Package: *
Pin: release o=Spacemit, n=mantic-spacemit
Pin-Priority: 1200
Package: *
Pin: release o=Spacemit, n=mantic-porting
Pin-Priority: 1100
Package: *
Pin: release o=Spacemit, n=mantic-customization
Pin-Priority: 1100
EOF
2. Configure DNS
echo "nameserver 8.8.8.8" >$TARGET_ROOTFS/etc/resolv.conf
3. Install hardware related packages
chroot $TARGET_ROOTFS /bin/bash -c "apt-get -y install ca-certificates"
chroot $TARGET_ROOTFS /bin/bash -c "apt-get update"
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades upgrade"
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install initramfs-tools"
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-image-6.1.15"
4. Install the meta-package
Different variants have different meta-packages:
- Minimal
bianbu-minimal - Dekstop
bianbu-desktop bianbu-desktop-zh bianbu-desktop-en bianbu-desktop-minimal-en bianbu-standard bianbu-development - NAS
bianbu-nas
Here is an example of making a minimal variant:
chroot $TARGET_ROOTFS /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y --allow-downgrades install bianbu-minimal"
General configuration
1. Configure Region
chroot $TARGET_ROOTFS /bin/bash -c "apt-get -y install locales"
chroot $TARGET_ROOTFS /bin/bash -c "echo \"locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, zh_CN.UTF-8 UTF-8\" | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "echo \"locales locales/default_environment_locale select zh_CN.UTF-8\" | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "sed -i 's/^# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/' /etc/locale.gen"
chroot $TARGET_ROOTFS /bin/bash -c "dpkg-reconfigure --frontend=noninteractive locales"
2. Configure time zone
chroot $TARGET_ROOTFS /bin/bash -c "echo 'tzdata tzdata/Areas select Asia' | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "echo 'tzdata tzdata/Zones/Asia select Shanghai' | debconf-set-selections"
chroot $TARGET_ROOTFS /bin/bash -c "rm /etc/timezone"
chroot $TARGET_ROOTFS /bin/bash -c "rm /etc/localtime"
chroot $TARGET_ROOTFS /bin/bash -c "dpkg-reconfigure --frontend=noninteractive tzdata"
3. Configure Time Server
sed -i 's/^#NTP=.*/NTP=ntp.aliyun.com/' $TARGET_ROOTFS/etc/systemd/timesyncd.conf
4. Configure Password
chroot $TARGET_ROOTFS /bin/bash -c "echo root:bianbu | chpasswd"
5. Configure the network (optional)
If you only installed the minimal (bianbu-minimal) meta-package, you need to configure the network using netplan:
cat <<EOF | tee $TARGET_ROOTFS/etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
end0:
dhcp4: true
EOF
chroot $TARGET_ROOTFS /bin/bash -c "chmod 600 /etc/netplan/01-netcfg.yaml"
Generate partition image
Note that after the installation and configuration are complete, cancel the mount first:
mount | grep "$TARGET_ROOTFS/proc" > /dev/null && umount -l $TARGET_ROOTFS/proc
mount | grep "$TARGET_ROOTFS/sys" > /dev/null && umount -l $TARGET_ROOTFS/sys
mount | grep "$TARGET_ROOTFS/dev/pts" > /dev/null && umount -l $TARGET_ROOTFS/dev/pts
mount | grep "$TARGET_ROOTFS/dev" > /dev/null && umount -l $TARGET_ROOTFS/dev
Generate a UUID and write it to /etc/fstab:
UUID_BOOTFS=$(uuidgen)
UUID_ROOTFS=$(uuidgen)
cat >$TARGET_ROOTFS/etc/fstab <<EOF
# <file system> <dir> <type> <options> <dump> <pass>
UUID=$UUID_ROOTFS / ext4 defaults,noatime,errors=remount-ro 0 1
UUID=$UUID_BOOTFS /boot ext4 defaults 0 2
EOF
Move boot to another directory to create bootfs and rootfs partitions separately:
mkdir -p bootfs
mv $TARGET_ROOTFS/boot/* bootfs
Generate bootfs.ext4 and rootfs.ext4:
mke2fs -d bootfs -L bootfs -t ext4 -U $UUID_BOOTFS bootfs.ext4 "256M"
mke2fs -d $TARGET_ROOTFS -L rootfs -t ext4 -N 524288 -U $UUID_ROOTFS rootfs.ext4 "2048M"