News:
Petitboot built with our scripts now runs on both on ARM64/AARCH64 and
RISCV64, e.g. on VisionFive 2 (on UART/serial console, and on HDMI if the
kernel supports it). For both architectures the ability to boot compressed
kernels (e.g. recent Fedora) has also been added as well as an option for
remote mode (Petitboot UI over telnet).
TL;DR:
On an single board computer (SBC) or TV-box with working u-boot you can get
a versatile menu driven bootloader by replacing the default Linux initramfs
with an initramfs containing the Petitboot or u-root bootloader (provided
your default Linux kernel has kexec). (Downloads of Petitboot initramfs
for AARCH64 and RISCV64 are provided at the
GitLab release page and
more download options are given below.)
Bootloaders with menu driven UI: This repo contains, mostly, information about some bootloaders and bootdisks for SBCs and TV-boxes. With a bootdisk using one of these bootloaders you can e.g. boot many ("generic") ARM64 or RISCV64 Linux images from major distributions that have grub boot configurations, such as Fedora, Ubuntu, Debian and openSuse. Booting can be done without any EFI capabilities (e.g. using old u-boot) and the bootloader offers a menu of bootable configurations found on attached media. An example of a use case for SBCs/TV-boxes is to have a bootdisk installed on SD and have several Linux distros installed on USBs or to choose from. Another example of use case is to set up a bootdisk on non-removable media such as eMMC to boot e.g. several different distros installed on different partitions on an nvme or SATA SSD. The term bootdisk should thus here be interpreted in a generalized sense to mean either a bootdisk in the traditional sense or simply a dedicated boot partition (used early in the boot chain) that holds one of these bootloaders to act as a new intermediate stage in the boot process.
Setting up a bootdisk:
A bootdisk can be set up using one of the two bootloaders
Petitboot
and u-root, both of which employ a
chainloading mechanism
utilizing the Linux kexec
system call.
(The repo contains two main scripts for building Petitboot as well as
helper scripts and documentation, see below.)
The two bootloaders provide the same basic functionality and both are
implemented in the form of an initramfs.
Petitboot provides a somewhat nicer UI (cf. screenshots below) and can boot
grub configurations defined in
grub.cfg, and works for both ARM64 and RISCV64 (including bzImage).
On the other hand, u-root (which recently got support for RISCV64) can boot
(simple) grub configurations as well as a subset of
syslinux
configurations,
including
the extlinux.conf configurations used by
u-boot.
(The bootloader components of u-root are known by other names, one of them
being Linuxboot; we use the collective name u-root.)
History:
The bootdisk concept discussed here was originally utilized as an aid for
booting on ARM64 SBCs/TV-boxes where an older resident/vendor u-boot was
installed that typically did not support booting using extlinux.conf and
therefore needed various scripts/tricks (such as u-boot chainloading) for
booting.
In case a modern u-boot is used which is capable of using extlinux.conf
it is straightforward to set up a bootdisk since this essentially amounts to
installing an appropriate kernel and dtb to work with the initramfs that
holds either Petitboot or u-root.
(This is typically all that is needed on a RISCV64 box.)
Other contents in the repo:
General info about the bootdisk concept in the older (u-boot) boot script
setting for ARM64 can be found in the files
README_petit-bootdisk.md
and README_u-root-bootdisk.md, respectively.
In the attic area there is some more older information, such as
instructions in README_diy-bootdisk.md for
(manually) recreating or adapting bootdisks.
An initramfs for Petitboot can be built from source, either manually using
the C source at Github (see also
README_diy-bootdisk.md) or using the build
scripts petitboot_mkinird_riscv64.bash
and petitboot_mkinird_aarch64.bash.
(Initramfs built with the scripts provide additional functionality over that
which is present in the Petitboot code at Github.)
The build scripts can be executed natively on an RISCV64/ARM64 host or an
RISCV64/ARM64 build host run in a QEMU emulator, see below.
An alternative is to run the scripts in a docker environment, most conveniently
using the the wrapper script
petitboot_build_wrapper.bash, but manually is
also straightforward, see
README_docker_petitboot_mkinitrd.md.
Initramfs with Petitboot built using a CI/CD pipeline with the native build
scripts are released here at Gitlab; more downloads can be found at
here (where also some
setup notes can be found).
An initramfs for u-root can be built from the Go source using a recent
version of (the toolchain) Go, see
u-root at Github.
Initramfs with u-root built like this can be found
here.
Linux kernels for RISCV64 can be created with the script
riscv64_kbuild.bash on an x86_64 or RISCV64 build
host.
The script produces simple gzipped tarballs with boot files (kernel image,
initramfs etc.), the module tree, header files and dtbs, for the board
manufacturers selected.
It can be used to produce the vf2-3pole line of kernels (for VisionFive 2)
which have kexec() enabled and can be used to run Petitboot.
Downloads of tarballs of vf2-3pole kernels can be found
here.
Kernels for ARM64/AARCH64 can be created with the script
arm64_kbuild.bash on an x86_64 or ARM64 build host.
The script produces gzipped tarballs with boot files (kernel image, initramfs
etc.), the module tree, header files and dtbs, for the board manufacturers
selected.
For instance, it can be used to produce the 3pole line of ARM64 kernels
(which have kexec() enabled and can be used to run Petitboot/u-root).
These kernels are adapted for Amlogic TV-boxes but has support also for
Rockchip and Allwinner.
Downloads of the 3pole series of kernels can be found
here.
Linux, e.g. Ubuntu, Debian or Devuan, can generally be installed to SBCs using
the standard installer to produce an EFI/Grub setup that can be booted with
on-board u-boot, at least if u-boot is a recent upstream/mainline version.
However, there are situations where such a version of u-boot is not available
(or not desirable) to install (e.g. many TV-boxes).
For these situations it is useful to have premade Linux images that can be
booted with existing u-boot and run-as is, only relying on u-boot's ability
to do do sysboot via extlinux.conf (either directly or via chainloading of
another stage of u-boot).
Linux images with Debian, Devuan or Ubuntu for RISCV64 and ARM64/AARCH64 can
be created with the scripts
debuntu_dbstrap_aarch64.bash
and debuntu_dbstrap_riscv64.bash.
Images built with these script can be downloaded from
here (aarch64) and
here (riscv64).
A convenient way to create an RISCV64/ARM64 Linux image is to run a native
ARM64/RISCV64 installer (e.g. in iso file format) in QEMU on e.g. an x86_64
host and install directly onto an SD/USB attached to the host.
These images will typically be EFI images and can be booted on a
SBC/TV-box using e.g. Petitboot/u-root.
A short description of how use QEMU for image creation like this
is given in README_QEMU_inst.md.
Some examples of the boot screen in Petitboot and u-root.
Petitboot running on VisionFive 2 with serial console display (80x24 window).
The
boot menu screen in Petitboot running on VisionFive 2 with bootable Linux images
on SD, USB and nvme.
An older (low resolution) screenshot of Petitboot running on Ugoos AM6 plus
with display on HDMI screen (1366x768 resolution).
The
boot menu screen encountered after boot with a Petitboot bootdisk.
An older (low resolution) screenshot of u-root running on Ugoos AM6 plus
with display on HDMI screen (1366x768 resolution).
The menu
of bootable images displayed after u-root has scanned the attached devices
(here three USB sticks attached via a USB hub).
In some later versions of the build scripts here I have used a local instance
of a Qwen LLM to update/produce code. Qwen's contributions are indicated in the
CHANGELOG.md and in the headers of the individual files.
All information here is to the best of my knowledge. I take no responsibility for any consequences of its use, so use at your own risk.