[Toybox] "make root" boots to shell prompt.

Rob Landley rob at landley.net
Wed Apr 29 02:11:41 PDT 2020


1) Here is the build procedure building for the musl-cross-make cross compilers
I've been testing against.

    git clone https://github.com/landley/toybox
    git clone https://github.com/richfelker/musl-cross-make
    cd musl-cross-make
    # use known good version with known good package versions
    git checkout 5086175f2902
    sed 's/\(BINUTILS_VER =\).*/\1 2.32/' Makefile
    sed 's/\(LINUX_VER =\).*/\1 4.19.90/' Makefile
    ../toybox/scripts/mcm-buildall.sh i686:: sh2eb:fdpic:--with-cpu=mj2
    cd ..

The binutils thing is because newer binutils doesn't build arch/sh and the
kernel patch from a month ago
(https://www.spinics.net/lists/linux-sh/msg56844.html) still hasn't gone upstream.

The LINUX_VER is because Rich has reintroduced the "external kernel headers"
problem that I helped fix in 2006 (see https://lkml.org/lkml/2006/4/28/194 and
yes I rewrote the make headers_install perl script in shell as part of my perl
removal patches), and in _addition_ to being stupid the headers he's using don't
have m68k or s390x subdirectories, so gratuitously remove support for those
architectures.

2) Fetch kernel source and symlink the cross compilers where "make root" can
find them:

  git clone https://github.com/torvalds/linux -b v5.6
  cd toybox
  ln -s ../musl-cross-make/ccc ccc

3) Build all the targets

  make root CROSS=all ALL=1 LINUX=../linux

The ALL=1 just says continue if any of the architectures fails to build (the
default is to stop at the first error).

You can specify an individual arch target instead of "all". CROSS=help to get a
list of targets. If you don't specify CROSS= it'll use your host compiler to
build a host version (and try to guess which kernel to build), but it creates a
static linked toybox and static linking against glibc is NOT RELIABLE. But you

The LINUX= says where to find kernel source, if it's omitted it'll just build a
chroot and stop there.

3) Run it:

  (cd root/sh4; ./qemu-*.sh)

You need the relevant qemu-system-sh4 (or appropriate arch) for that to work.
Type "exit" when bored. You can "sudo chroot root/i686/fs /init" if you like,
the init script checks if you're PID 1 and only does the qemu setup for qemu,
for chroot it just does the proc/sys/dev mounts and runs a shell, then unmounts
them on exit). I should set up some sort of container invocation with unshare
and friends.)

Note: I haven't implemented terminal control in the shell yet, so ctrl-C will
kill the shell and log you out. Working on it...

Rob


More information about the Toybox mailing list