A (personal) set of scripts to build bootable Debian images for various architectures and development boards (or "toys", that's how we call them).
-
- QEMU (riscv64)
- SiFive HiFive Unleashed
- StarFive VisionFive 2
-
AArch64
- QEMU (aarch64)
- ODROID-N2+
-
ARM (arm-linux-gnueabihf)
- QEMU (arm)
-
POWER
More toys will be added as I acquire them and get them up and running (or migrate older scripts to this repository).
Scripts below do use sudo quite a lot. IF THERE"S A BUG, IT MAY WIPE OUT YOUR SYSTEM. DO NOT RUN THESE SCRIPTS WITHOUT READING THEM CAREFULLY FIRST.
They're provided for convenience. Use at your own risk.
Disclaimer: following recipe is (semi-regularly) tested on Debian Testing (Trixie at the time of writing). Debian 12 (Bookworm) is known to work too. If you have Debian 11 (Bullseye) or some other Debian-based distro, e.g, Ubuntu, this recipe may or may not work!
-
Install required tools (QEMU, mmdebstrap and so on):
sudo apt-get install mmdebstrap qemu-user-static qemu-system-misc binfmt-support debian-ports-archive-keyring rsync device-tree-compiler genimage genext2fs dosfstools guestfish guestfs-tools -
Install build tools for each architecture you want to build image for:
crossbuild-essential-riscv64 crossbuild-essential-ppc64el
For each architecture and "board" you may find following scripts:
-
<arch>/<board>/mk-fs.sh <image>to build a root filesystem.<image>can be either:- an empty directory
- raw filesystem image containing ext4 file system
- raw or
.qcow2disk image containing a partition table and one exatly one ext4-formatted partition. Note, that when using.qcow2images, filesystem creation process is really slow.
-
<arch>/<board>/mk-os.shto build a linux kernel suitable for the board -
<arch>/<board>/mk-ub.shto build U-Boot bootloader suitable for the board -
<arch>/<board>/mk-im.shto build a complete disk / SD-card image to use with the board.mk-im.shcalls above scripts as needed to build bootloader, kernel and filesystem and package all that into a single file.
...mainly so I won't need to fish for them every single time :-)
-
Connecting to serial console over FTDI:
sudo screen /dev/ttyUSB0 115200 -
Write SD card image to the SD card:
pv images/sdcard.img | sudo dd of=/dev/mmcblk0 bs=32M oflag=sync -
Create
.tar.gzof root filesystem from disk image:guestfish -a sdcard.img \ run \ : mount /dev/sda4 / \ : tar-out / rootfs.tgz compress:gzip numericowner:true xattrs:true acls:trueReplace
/dev/sda4as needed. -
Extracting
.tar.gzof root filesystem (see above) to (NFS) volume:tar --xattrs --acls -xf rootfs.tgzNote
--xattrsand--aclsoptions, they are important! -
Uploading root filesystem in
build/rootto remote (NFS) server:sudo true; sudo tar -C build/root --xattrs --acls -zc . | pv -s 1G | ssh <server> sudo tar -C <export_dir> --xattrs --acls -zx -
Sometimes it happened to me that
/var/lib/dpkg/availabledisappeared. This preventsdpkg/aptfrom removing packages. Following command fixed this for me:sudo dpkg --clear-avail && sudo apt-get update
This code is licensed under MIT license. See LICENSE.txt.