blob: 9ff7368110bda0078d45c6db843b4e24bca7c3cd [file] [log] [blame]
Rob Landley09e8bde2012-02-04 12:20:39 -06001Toybox: all-in-one Linux command line.
2
Rob Landley0b87b2e2013-05-07 22:50:33 -05003--- Getting started
4
5You can download static binaries for various targets from:
6
7 http://landley.net/toybox/bin
8
9The special name "." indicates the current directory (just like ".." means
10the parent directory), and you can run a program that isn't in the $PATH by
11specifying a path to it, so this should work:
12
13 wget http://landley.net/bin/toybox-x86_64
14 chmod +x toybox-x86_64
15 ./toybox-x86_64 echo hello world
16
17--- Building toybox
Rob Landley09e8bde2012-02-04 12:20:39 -060018
19Type "make help" for build instructions.
20
Rob Landley0b87b2e2013-05-07 22:50:33 -050021Usually you want something like:
Rob Landley09e8bde2012-02-04 12:20:39 -060022
Rob Landley0b87b2e2013-05-07 22:50:33 -050023 make defconfig
Rob Landleya6916cd2015-04-07 14:59:32 -050024 LDFLAGS="--static" CROSS_COMPILE=armv5l- make toybox
Rob Landley0b87b2e2013-05-07 22:50:33 -050025 PREFIX=/path/to/root/filesystem make install
Rob Landley09e8bde2012-02-04 12:20:39 -060026
Rob Landley0b87b2e2013-05-07 22:50:33 -050027The CROSS_COMPILE argument is optional, and without it builds a version of
28toybox to run on the current machine. Cross compiling requires an appropriately
29prefixed cross compiler toolchain, several example toolchains are available at:
30
31 http;//landley.net/aboriginal/bin
32
33For the "CROSS_COMPILE=armv5l-" example above, download
34cross-compiler-armv5l.tar.bz2, extract it, and add its "bin" subdirectory to
35your $PATH. (And yes, the trailing - is significant, because the prefix
36includes a dash.)
37
38For more about cross compiling, see:
39
40 http://landley.net/writing/docs/cross-compiling.html
41 http://landley.net/aboriginal/architectures.html
Rob Landley09e8bde2012-02-04 12:20:39 -060042
43--- Using toybox
44
Rob Landley0b87b2e2013-05-07 22:50:33 -050045The toybox build produces a multicall binary, a "swiss-army-knife" program
46that acts differently depending on the name it was called by (cp, mv, cat...).
47Installing toybox adds symlinks for each command name to the $PATH.
Rob Landley09e8bde2012-02-04 12:20:39 -060048
Rob Landley0b87b2e2013-05-07 22:50:33 -050049The special "toybox" command treats its first argument as the command to run.
50With no arguments, it lists available commands. This allows you to use toybox
51without installing it. This is the only command that can have an arbitrary
52suffix (hence "toybox-armv5l").
Rob Landley09e8bde2012-02-04 12:20:39 -060053
54The "help" command provides information about each command (ala "help cat").
55
Rob Landley0b87b2e2013-05-07 22:50:33 -050056--- Configuring toybox
Rob Landley09e8bde2012-02-04 12:20:39 -060057
Rob Landley0b87b2e2013-05-07 22:50:33 -050058It works like the Linux kernel: allnoconfig, defconfig, and menuconfig edit
59a ".config" file that selects which features to include in the resulting
60binary.
Rob Landley09e8bde2012-02-04 12:20:39 -060061
Rob Landley0b87b2e2013-05-07 22:50:33 -050062The maximum sane configuration is "make defconfig": allyesconfig isn't
63recommended for toybox because it enables unfinished commands and debug code.
64
65--- Creating a Toybox-based Linux system
66
67Toybox is not a complete operating system, it's a program that runs under
68an operating system. Booting a simple system to a shell prompt requires
69three packages: an operating system kernel (Linux) to drive the hardware,
70a program for the system to run (toybox), and a C library to tie them
Rob Landleya6916cd2015-04-07 14:59:32 -050071together (toybox has been tested with musl, uClibc, glibc, and bionic).
Rob Landley0b87b2e2013-05-07 22:50:33 -050072
Rob Landleya7c3e292014-01-01 13:24:03 -060073The C library is part of a "toolchain", which is an integrated suite
Rob Landley0b87b2e2013-05-07 22:50:33 -050074of compiler, assembler, and linker, plus the standard headers and libraries
Rob Landleya7c3e292014-01-01 13:24:03 -060075necessary to build C programs.
Rob Landley0b87b2e2013-05-07 22:50:33 -050076
Rob Landleya7c3e292014-01-01 13:24:03 -060077Static linking (with the --static option) copies the shared library contents
78into the program, resulting in larger but more portable programs, which
Rob Landleya6916cd2015-04-07 14:59:32 -050079can run even if they're the only file in the filesystem. Otherwise,
Rob Landleya7c3e292014-01-01 13:24:03 -060080the "dynamically" linked programs require the library files to be present on
81the target system ("man ldd" and "man ld.so" for details).
Rob Landley0b87b2e2013-05-07 22:50:33 -050082
Rob Landley0b87b2e2013-05-07 22:50:33 -050083An example toybox-based system is Aboriginal Linux:
84
Rob Landleya6916cd2015-04-07 14:59:32 -050085 http://landley.net/aboriginal/about.html
86
87That's designed to run under qemu, emulating several different hardware
88architectures (x86, x86-64, arm, mips, sparc, powerpc, sh4). Each toybox
89release is regression tested by building Linux From Scratch under this
90toybox-based system on each supported architecture, using QEMU to emulate
91big and little endian systems with different word size and alignment
92requirements.
93
94--- Presentations
95
961) "Why Toybox?" 2013 talk here at CELF
97
98 video: http://youtu.be/SGmtP5Lg_t0
99 outline: http://landley.net/talks/celf-2013.txt
100 linked from http://landley.net/toybox/ in nav bar on left as "Why is it?"
101 - march 21, 2013 entry has section links.
102
1032) "Why Public Domain?" The rise and fall of copyleft, Ohio LinuxFest 2013
104
105 audio: https://archive.org/download/OhioLinuxfest2013/24-Rob_Landley-The_Rise_and_Fall_of_Copyleft.mp3
106 outline: http://landley.net/talks/ohio-2013.txt
107
1083) Why did I do Aboriginal Linux (which led me here)
109
110 260 slide presentation:
111 https://speakerdeck.com/landley/developing-for-non-x86-targets-using-qemu
112
113 How and why to make android self-hosting:
114 http://landley.net/aboriginal/about.html#selfhost
115
1164) What's new with toybox (ELC 2015 status update):
117
118 video: http://elinux.org/ELC_2015_Presentations
119 outline: http://landley.net/talks/celf-2015.txt