From b2bd9a6570270646a80afdccf957cb9e856ec92d Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 13 May 2020 04:46:49 -0500 Subject: New FAQ, "how do I build a working Linux system with toybox". --- www/faq.html | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) (limited to 'www') diff --git a/www/faq.html b/www/faq.html index 37ab9157..ec62dd57 100755 --- a/www/faq.html +++ b/www/faq.html @@ -1,6 +1,10 @@ -toybox news +toybox FAQ +

Frequently Asked Questions

+ +

General Questions

+ +

Using toybox

+ + +

Q: Do you capitalize toybox?

@@ -217,4 +227,76 @@ level you can "make tests" to test everything, or "make test_sed" test a single command's standalone version (which should behave identically) but that's why we test.

+
+

Q: How do you build a working Linux system with toybox?

+ +

A: To build a native chroot, "make root" then "sudo chroot +root/host/fs /init". Type "exit" to get back out.

+ +

You can also cross compile simple two package (toybox+linux) systems that +boot to a shell prompt under qemu, by specifying +a target type with CROSS= +(or setting CROSS_COMPILE= to a cross compiler prefix with optional absolute +path), and pointing the build at a Linux kernel source directory, ala:

+ +

make root CROSS=sh4 LINUX=~/linux

+ +

Then you can cd root/sh4; ./qemu-sh4.sh to launch the emulator +(you need the appropriate qemu-system-* binary installed). Type "exit" +when done and it should shut down the emulator on the way out.

+ +

The cross compilers I test this with are built from the musl-libc +maintainer's +musl-cross-make +project, built by running toybox's scripts/mcm-buildall.sh in that directory, +and then symlink the resulting "ccc" subdirectory into toybox where CROSS= +can find them, ala:

+ +
+cd ~
+git clone https://github.com/landley/toybox
+git clone https://github.com/richfelker/musl-cross-make
+cd musl-cross-make
+../toybox/scripts/mcm-buildall.sh # this takes a while
+ln -s $(realpath ccc) ../toybox/ccc
+
+ +

An unknown CROSS= should list all the available cross compilers under +ccc. After the above musl-cross-make build and install, +"make root CROSS=help" should say something like: +aarch64 armv4l armv5l armv7l armv7m armv7r i486 i686 m68k microblaze mips mips64 mipsel powerpc powerpc64 powerpc64le s390x sh2eb sh4 x32 x86_64. +(A long time ago I +tried to explain +what some of these architectures were.)

+ +

You can build all the targets at once, and can add additonal packages +to the build, by calling the script directly and listing packages on +the command line:

+ +
+

scripts/mkroot.sh CROSS=all LINUX=~/linux dropbear

+
+ +

An example package build script (building the dropbear ssh server, adding a +port forward from 127.0.0.1:2222 to the qemu command line, and providing a +ssh2dropbear.sh convenience script to the output directory) is provided +in the scripts/root directory. If you add your own scripts elsewhere, just +give a path to them on the command line. (No, I'm not merging more package build +scripts, I learned that lesson long ago. But if you +want to write your own, feel free.)

+ +

(Note: if you don't have a .config it'll make defconfig and +add CONFIG_SH and CONFIG_ROUTE to it. If you already have a .config that +_doesn't_ have CONFIG_SH in it, you won't get a shell prompt or be able to run +the init script without a shell. This is currently a problem because sh +and route are still in pending and thus not in defconfig, and "make root" +cheats when it adds them. I'm working on it. tl;dr if make root doesn't work +"rm .config" and run it again, and all this should be fixed up in future when +those two commands are promoted out of pending so "make defconfig" would have +what you need anyway. It's designed to let yout tweak your config, which is +why it uses the .config that's there when there is one, but the default is +currently wrong because it's not quite finished yet.)

+ + + -- cgit v1.2.3