Re: mkroot quickstart (was RE: Testing on lots of architecture targets with mkroot.)

Rob Landley <[email protected]> Tue, 2 Jun 2026 09:44:16 -0500
Newsgroups org.kernel.vger.linux-embedded
Message-ID <[email protected]>
On 6/1/26 15:54, Bird, Tim wrote:
> Next up is testing it with grab-boot-data.sh.

I _think_ I fixed the bug you sent me that was screwing up that script 
(sequencing issue using variable expansion results as a shell function 
to call), but my todo list runneth over and started composting some 
years ago. Lemme know if you hit a bug. (I'm redoing the \ line 
appending in HERE documents right now.

I have a busybox package in mkroot/packages which in theory lets you do

$ mkroot/mkroot.sh busybox CROSS=i686 LINUX=~/linux

And the result should have busybox instead of toybox providing the $PATH.

In practice, I never finished implementing bzip2 compression in toybox 
(because it was obsoleted by xz, so at the design level I went "I'll 
provide gzip as a compressor, and just provide extractors for everything 
else") but busybox decided that if you have bzip2 decompression enabled 
(which is in defconfig) the build will compress its help text with bzip2 
and there's NO WAY TO TELL IT NOT TO. You cannot have the extractor 
enabled WITHOUT the build calling the "bzip2" compressor on the host.

So building busybox with the toybox airlock enabled required a hack to 
the busybox source/build which disabled the help text entirely, and I 
went "there has to be a less terrible way to do this" but Denys has been 
a bit distracted recently and I haven't come up with a less ugly busybox 
config patch myself yet...

> I'll need to turn on PRINTK_TIME,
> and set initcall_debug on the kernel command line, and I'll likely want to add
> my latest early-times patch.  I'll poke around the scripts and see if I can figure
> out how best to do each of these.

The kernel is an external repo so you just patch it yourself. The patch 
stack I applied to 7.0 is at:

https://landley.net/bin/mkroot/0.8.14/linux-patches/

$ for i in ../patches; do echo $i; patch -p1 -i $i || break; done

To enable extra kernel config symbols from the command line, set KEXTRA 
in CSV format. (The plumbing circa line 361 literally sources 
docs/linux-microconfig and that gets written in there on line 348.) 
Something like:

$ mkroot/mkroot.sh CROSS=allnonstop LINUX=~/linux \
   KEXTRA=PRINTK_TIME,COREDUMP,JFS_FS

(There's also a MODULES= if you want to go there, and yes it enables 
module support when it has any modules to build. Eventually 
modules/plumbing/tests is intended to run the toybox test suite under 
mkroot, including a bunch of "requires root and a known kernel 
environment" tests I've only partially written so far. Really hard to 
test "mount" or "ps" outside a virtual environment like that, let alone 
modprobe. But I need to get the shell finished first...)

Rob

(Did you know the kernel's initrd loader will accept appended cpio.gz 
archives? Just cat them together, you don't even have to decompress and 
recompress. That makes module support in initramfs MUCH easier. Last I 
checked mkroot.sh was doing that right, but I haven't regression tested 
it in forever...)