8000 GitHub - kolodziej/mkroot: Simple toybox-based embedded root filesystem builder
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kolodziej/mkroot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkroot - Build simple bootable Linux system.

This project uses a cross compiler toolchain (usually musl-cross-make) to
build a toybox-based root filesystem and kernel that boot under qemu
(or on real hardware if available).

Mailing list: http://lists.landley.net/listinfo.cgi/mkroot-landley.net

--- Quick start

You can go:

  $ CROSS_COMPILE=prefix- ./mkroot.sh dropbear kernel
  $ cd output/$ARCH
  $ ./qemu-$ARCH.sh

And it'll boot an emulated system under QEMU.

Running ./mkroot.sh with no arguments and no $CROSS_COMPILE environment
variable set builds a chroot for the host.

  $ ./mkroot.sh
  $ sudo chroot output/host/root /init
  $ ls -l
  $ exit

This downloads toybox into the "packages" directory, builds a minimal root
filesystem, and packages it up into a cpio file (ls output/*/*.cpio.gz)
suitable for use as an initramfs.

--- Adding build modules

You can build additional things from the "module" directory by listing
them on the command line, ala:

  $ ./mkroot.sh dropbear distcc

Use "-n" as the first argument if you're adding to an existing root filesystem
you don't want to delete and rebuild.

We provide a few modules to get you started, but aren't interested in
turning mkroot into a Linux distro. If you need more packages, fork the
repo and add your own modules. As long as you don't modify existing files
you should be able to cleanly pull updates into your fork (without even
a merge commit if you pull --ff).

The "Linux From Scratch" and "Beyond Linux From Scratch" projects are a good
source of additional package build instructions. Most of our long-term focus
long-term is on native compiling under emulation, like the earlier
http://landley.net/aboriginal/about.html project this replaced.

--- Cross compiling

To build for a different target, specify a cross compiler prefix using
the CROSS_COMPILE environent variable, ala:

  $ CROSS_COMPILE=sh4-linux-musl- ./mkroot.sh

The project is developed against musl-cross-make.
https://github.com/richfelker/musl-cross-make project. Running the included
mcm-buildall.sh script in that project's directory builds cross and native
compilers for all supported targets (which takes a while).

  $ cd ~
  $ git clone https://github.com/richfelker/musl-cross-make mcm
  $ cd mcm
  $ ~/mkroot/mcm-buildall.sh
  $ cd ~/mkroot
  $ CROSS_COMPILE=~/mcm/output/sh4-linux-musl-cross/bin/sh4-linux-musl- \
    ./mkroot.sh kernel

--- Building kernels for QEMU

The "kernel" module builds a bootable Linux kernel for the target (it
recognizes all the musl-cross-make prefixes, for others you may have to
set the environment variable $ARCH to the right type).

  $ CROSS_COMPILE=armv5l-linux-musl-
  $ PATH=~/mcm/output/${CROSS_COMPILE}cross/bin:"$PATH"
  $ ./mkroot.sh dropbear kernel
  $ cd output/armv5l
  $ ./qemu-armv5l.sh
  $ ls -l
  $ cat /proc/cpuinfo 
  $ exit

--- Hermetic build

Mkroot uses toybox's "make install_airlock" to implement a "hermetic build",
which means it tries to insulate itself from variations in the host build
environment by providing its own build prerequisites. This means the first
thing it does is build an "airlock" directory full of binaries it either
built or symlinked out of the host $PATH, and then restricts the $PATH for
the rest of the build to just that directory (plus the cross compiler).

If you need to add extra things to the airlock, delete the old one (if any)
and set HOST_EXTRA="list of commands" (space separated if there's more than
one). For example:

  ./clean.sh && HOST_EXTRA=mkimage CROSS_COMPILE=i686- ./mkroot.sh kernel

About

Simple toybox-based embedded root filesystem builder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%
0