Skip to content

Repository files navigation

crossdev-stages

Rootless cross-compilation of Gentoo stages using crossdev and hakoniwa

Status

  • Build and assemble packages to a stage1 catalyst can leverage
  • Update a compatible stage3 image
  • Build opensbi + u-boot images and linux kernel + modules
  • Assemble bootable images
  • Per-CFLAGS target stage isolation (glibc-only rebuild)
  • Rust CLI using hakoniwa for sandboxing
  • Modular bootloader (opensbi, u-boot, grub, syslinux, tfa, rkbin)
  • File-convention hooks (pre/post/override scripts per build step)
  • Git source cache (bare repo references)

Boards

BoardArchKernelBoot chainCFLAGSStatus
k1riscv64spacemit 6.6OpenSBI + U-Boot-O3 -march=rv64gcv_zvl256bstable
k1-upstreamriscv64spacemit k3OpenSBI + U-Boot-O3 -march=rv64gcv_zvl256btesting
k3riscv64spacemit 6.18OpenSBI + U-Boot-O3 -march=rva23u64stable
k230riscv64canaan (hdmi)OpenSBI (payload) + U-Boot-O3 -march=rv64gcv_zvl128bstable
ky-x1riscv64spacemit 6.6OpenSBI + U-Boot-O3 -march=rv64gcv_zvl256bstable
blackholeriscv64tenstorrentOpenSBI (jump, PCIe BAR)-O3 -march=rv64gcv_zvl512bstable
odroid-m1aarch64mainline v7.0TFA + U-Boot + rkbin-O3 -mcpu=cortex-a55testing
odroid-m1saarch64mainline v7.0TFA + U-Boot + rkbin-O3 -mcpu=cortex-a55testing
odroid-m2aarch64mainline v7.0TFA + U-Boot + rkbin-O3 -mcpu=cortex-a76.cortex-a55testing
pentium-mmxi586mainline v6.12BIOS (no firmware)-O2 -march=pentium-mmxtesting

CLI

crossdev-stages [OPTIONS] <COMMAND>
Commands:
sandbox Manage host build sandboxes
target Manage cross-compiled target stages
image Build board images
stages List or download Gentoo stage3 tarballs
board Manage and inspect boards
maint Maintenance: clean, logs, diagnostics
status Show overview of sandboxes, targets, builds, and boards
Options:
--project-dir <DIR> Project root (where boards/ lives) [default: .]
--mirror <URL> Gentoo mirror URL
--binhost <URL> Binary package host URL
--dry-run Show what would be done

Quick start

# List available boards
crossdev-stages board list
# Inspect a board configuration
crossdev-stages board info --board <BOARD># Set up host sandbox
crossdev-stages sandbox setup
crossdev-stages sandbox prepare
crossdev-stages sandbox crossdev --arch <ARCH> --board <BOARD># Create target stage from a stage3 seed
crossdev-stages target setup --arch <ARCH>
crossdev-stages target stage1
crossdev-stages target update
# Build an image
crossdev-stages image build --board <BOARD># Check status
crossdev-stages status
# Export the image
crossdev-stages image export --board <BOARD> -o /tmp/
# Export a full flash bundle (all boot blobs + images), optionally as .tar.xz
crossdev-stages image export --board <BOARD> --all --tar -o /tmp/
# Clean up stale builds and old stage3 tarballs
crossdev-stages maint clean
# Wipe whole categories (replaces sudo rm -rf ~/.cache/crossdev-stages)
crossdev-stages maint clean --sandboxes --targets
crossdev-stages maint clean --all

--all copies every build artifact into a <BOARD>-flash-bundle/ directory. If boards/<BOARD>/bundle.list exists it acts as a whitelist: one build-dir relative path per line, # comments ignored. A missing entry fails the export unless prefixed with optional:, and the token @image resolves to the packed image filename (which carries a UTC timestamp) from the build's .image marker. Without a bundle.list the whole build dir is copied, skipping the gen/, linux/, tmp/, and firmware/ source trees.

Source cache

Git repos are cached as bare repositories at ~/.cache/crossdev-stages/sources/. First clone fetches from upstream; subsequent builds use --reference for near-instant checkout.

Dependencies

emerge crossdev merge-usr git
emerge u-boot-tools dtc dracut busybox
emerge genimage xz-utils

crossdev requires a minimum amount of setup:

emerge app-eselect/eselect-repository
eselect repository create crossdev

Board configuration

Each board lives in boards/<name>/ with:

  • board.conf -- variables read by Rust and bash scripts
  • genimage.cfg -- disk image layout
  • pre-{step}.sh -- runs before Rust default (optional)
  • post-{step}.sh -- runs after Rust default (optional)
  • override-{step}.sh -- replaces Rust default entirely (optional)

Steps: deps, checkout, bootloader, kernel, assemble, pack

Build step execution

1. override-{step}.sh exists? -> run it, done
2. pre-{step}.sh exists? -> run it
3. Rust module default
4. post-{step}.sh exists? -> run it

Bootloader pipeline

The bootloader step runs an ordered list of stages declared in the BOOT_PIPELINE array. Valid stage names: opensbi, uboot, grub, syslinux, tfa, rkbin, amlogic-fip (validated when board.conf is loaded). If the key is omitted the default ("opensbi" "uboot" "syslinux" "grub") applies; each stage is a no-op unless its board.conf keys are set, so the default covers both the RISC-V vendor SDK pattern and the x86 BIOS pattern. An explicitly empty array () runs no stages (all-prebuilt firmware). Stages pass data forward via env exports prepended to later stages' build commands, e.g. tfa exports BL31= and rkbin exports ROCKCHIP_TPL=, both consumed by uboot.

board.conf variables

VariableRequiredDescription
BOARD_NAMEyesBoard identifier (matches directory name)
BOARD_ARCHyesTarget architecture (riscv64, aarch64, i586, i686)
CROSS_COMPILEyesToolchain prefix (e.g. riscv64-unknown-linux-gnu-)
KERNEL_REPOyesKernel source repository URL
KERNEL_DEFCONFIGyesKernel defconfig name
CHOSTnoOverride derived CHOST triple (default: auto from arch)
BOARD_CFLAGSnoBoard-specific CFLAGS (default: arch default)
KERNEL_TAGnoKernel git ref (default: top-level TAG)
KERNEL_ARCHnoLinux ARCH= value (default: auto from BOARD_ARCH)
BUILD_STEPSnoBuild pipeline steps (default: deps checkout bootloader kernel assemble pack)
BOOT_PIPELINEnoOrdered bootloader stages (default: ("opensbi" "uboot" "syslinux" "grub"); () = none)
OPENSBI_FW_TYPEnoOpenSBI firmware type: dynamic (default), jump, payload
OPENSBI_MAKE_FLAGSnoExtra opensbi make arguments
U_BOOT_MAKE_FLAGSnoExtra u-boot make arguments
GRUB_PLATFORMSnoGRUB platform (e.g. pc); enables the grub stage (grub-mkimage)
GRUB_MODULESnoGRUB modules embedded in core.img (default: BIOS boot set)
SYSLINUX_REPO / SYSLINUX_TAGnoSYSLINUX source repo + tag; enables the syslinux stage
TFA_REPO / TFA_TAG / TFA_PLATnoARM Trusted Firmware-A (BL31) repo, tag (default master), platform
RKBIN_REPO / RKBIN_TAG / RKBIN_DDRnoRockchip blob repo, tag (default master), DDR-init blob glob
FIP_REPO / FIP_TAGnoAmlogic boot-FIP packaging repo, tag (default master)
FIRMWARE_TAGnoTag for the firmware overlay repo (default: TAG)
COMPRESSIONnoImage compression: xz (default), gz, none
TESTINGnoMark board as testing (true/false)

Limitations

  • Some packages are cross-compilation unfriendly and rely on runtime checks (e.g. git iconv checks)

About

Build Gentoo stages leveraging crossdev

Resources

Stars

10 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages