Image Creation Guide
This guide describes how to package prepared bootfs.ext4 / rootfs.ext4 partition images together with the boot firmware into flashable artifacts, for both Bianbu 2.x (K1) and Bianbu 4.0 (K3), in two forms:
- Titan firmware package: used with the Titan flashing tool;
- SD card image: written directly to an SD card (created with genimage).
Both share the same preparation steps; the version differences (firmware files, partition table branch, package format) are marked in each step. The creation of the ROOTFS and the partition images is covered by the per-version ROOTFS guides (e.g. Bianbu 3.0 ROOTFS Creation, Bianbu 4.0 ROOTFS Creation).
Prepare the Packaging Directory
-
Install the dependencies
apt-get -y install zip wget python3 genimage pigz -
Copy the files required by the firmware
Based on the
$TARGET_ROOTFS(the rootfs directory) exported in the ROOTFS creation guide and thebootfs.ext4,rootfs.ext4next to it.-
2.x (K1):
export TMP=pack_dirmkdir -p $TMP/factory/cp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/bootinfo_emmc.bin $TMP/factorycp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/bootinfo_sd.bin $TMP/factorycp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/bootinfo_spinand.bin $TMP/factorycp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/bootinfo_spinor.bin $TMP/factorycp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/FSBL.bin $TMP/factorycp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/u-boot.itb $TMPcp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/env.bin $TMPcp $TARGET_ROOTFS/usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.itb $TMPcp bootfs.ext4 rootfs.ext4 $TMP -
4.0 (K3): the bootinfo files are copied with a glob (the 4.0 debs provide
bootinfo_block/spinand/spinor.bin, no longerbootinfo_emmc/sd.bin), andesos.itbplus theec.binof K3 boards are added:export TMP=pack_dirmkdir -p $TMP/factory/cp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/bootinfo_*.bin $TMP/factory/cp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/FSBL.bin $TMP/factory/cp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/u-boot.itb $TMPcp $TARGET_ROOTFS/usr/lib/u-boot/spacemit/env.bin $TMPcp $TARGET_ROOTFS/usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.itb $TMPcp $TARGET_ROOTFS/usr/lib/riscv64-linux-gnu/esos/esos.itb $TMPcp $TARGET_ROOTFS/usr/lib/firmware/k3-pico-itx/ec.bin $TMPcp bootfs.ext4 rootfs.ext4 $TMP
-
-
Download the reference partition tables and the fastboot config (choose the branch per version)
-
2.x (K1,
mainbranch):wget -P $TMP https://gitee.com/bianbu/image-config/raw/main/fastboot.yamlwget -P $TMP https://gitee.com/bianbu/image-config/raw/main/partition_2M.jsonwget -P $TMP https://gitee.com/bianbu/image-config/raw/main/partition_flash.jsonwget -P $TMP https://gitee.com/bianbu/image-config/raw/main/partition_universal.json -
4.0 (K3,
k3-br-v1.0.ybranch; the tables include anesospartition, andbootinforeferencesbootinfo_block.bin):wget -P $TMP https://gitee.com/bianbu/image-config/raw/k3-br-v1.0.y/fastboot.yamlwget -P $TMP https://gitee.com/bianbu/image-config/raw/k3-br-v1.0.y/partition_universal.jsonwget -P $TMP https://gitee.com/bianbu/image-config/raw/k3-br-v1.0.y/partition_flash.jsonwget -P $TMP https://gitee.com/bianbu/image-config/raw/k3-br-v1.0.y/partition_4M.jsonpartition_4M.jsontargets SPI NOR flashes of 4M and above (the actual NOR on the boards is usually 8M — the flashing tool matches the partition table downward by capacity).
-
Titan Firmware Package
-
2.x (K1): packaged as zip
cd $TMPzip -r ../bianbu-custom.zip * -
4.0 (K3): packaged as tar.gz (with
md5sums.txt; the Titan tool flashes using thefastboot.yaml/partition_flash.jsoninside the package)cd $TMPfind . -type f ! -name md5sums.txt -exec md5sum {} + | sort -k2 > md5sums.txttar -cf - . | pigz > ../Bianbu-LXQt-K3-$(date +%Y%m%d%H%M%S).tar.gz
SDCARD Image
The following describes how to create an SDCARD image with genimage, reusing the packaging directory prepared above.
-
Install the dependencies
echo 'tzdata tzdata/Areas select Asia' | debconf-set-selectionsecho 'tzdata tzdata/Zones/Asia select Shanghai' | debconf-set-selectionsDEBIAN_FRONTEND=noninteractive apt-get -y install wget python3 genimage -
Download the script that generates
genimage.cfg(choose the branch per version) and creategenimage.cfg-
2.x (K1,
bl-v1.0.ybranch):wget -P $TMP https://gitee.com/spacemit-buildroot/scripts/raw/bl-v1.0.y/gen_imgcfg.pypython3 $TMP/gen_imgcfg.py -i $TMP/partition_universal.json -n bianbu-custom.sdcard -o $TMP/genimage.cfg -
4.0 (K3,
k3-br-v1.0.ybranch):wget -P $TMP https://gitee.com/spacemit-buildroot/scripts/raw/k3-br-v1.0.y/gen_imgcfg.pypython3 $TMP/gen_imgcfg.py -i $TMP/partition_universal.json -n sdcard.img -o $TMP/genimage.cfg
-
-
Generate the SDCARD image
ROOTPATH_TMP="$(mktemp -d)"GENIMAGE_TMP="$(mktemp -d)"genimage \--config "$TMP/genimage.cfg" \--rootpath "$ROOTPATH_TMP" \--tmppath "$GENIMAGE_TMP" \--inputpath "$TMP" \--outputpath "."If you see the following messages, the packaging was successful:
INFO: hdimage(bianbu-custom): adding partition 'bootinfo' from 'factory/bootinfo_sd.bin' ...INFO: hdimage(bianbu-custom): adding partition 'fsbl' (in MBR) from 'factory/FSBL.bin' ...INFO: hdimage(bianbu-custom): adding partition 'env' (in MBR) from 'env.bin' ...INFO: hdimage(bianbu-custom): adding partition 'opensbi' (in MBR) from 'fw_dynamic.itb' ...INFO: hdimage(bianbu-custom): adding partition 'uboot' (in MBR) from 'u-boot.itb' ...INFO: hdimage(bianbu-custom): adding partition 'bootfs' (in MBR) from 'bootfs.ext4' ...INFO: hdimage(bianbu-custom): adding partition 'rootfs' (in MBR) from 'rootfs.ext4' ...INFO: hdimage(bianbu-custom): adding partition '[MBR]' ...INFO: hdimage(bianbu-custom): adding partition '[GPT header]' ...INFO: hdimage(bianbu-custom): adding partition '[GPT array]' ...INFO: hdimage(bianbu-custom): adding partition '[GPT backup]' ...INFO: hdimage(bianbu-custom): writing GPTINFO: hdimage(bianbu-custom): writing protective MBRINFO: hdimage(bianbu-custom): writing MBRINFO: cmd: "rm -rf "/tmp/tmp.rX4fZ39DKG"/*" (stderr):