blob: d24936f5954b2e465796998951df7a78329e5bbc [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
Rob Landley5acc6f42016-04-09 11:04:16 -050013 wget http://landley.net/toybox/bin/toybox-x86_64
Rob Landley0b87b2e2013-05-07 22:50:33 -050014 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 Landley1cbc2832015-10-28 21:41:45 -050021Toybox uses the "make menuconfig; make; make install" idiom same as
22the Linux kernel. Usually you want something like:
Rob Landley09e8bde2012-02-04 12:20:39 -060023
Rob Landley0b87b2e2013-05-07 22:50:33 -050024 make defconfig
Rob Landley1cbc2832015-10-28 21:41:45 -050025 make
26 make install
Rob Landley09e8bde2012-02-04 12:20:39 -060027
Rob Landley1cbc2832015-10-28 21:41:45 -050028Or maybe:
29
30 LDFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox
31 PREFIX=/path/to/root/filesystem/bin make install_flat
32
Rob Landley0cf49f52020-05-29 04:12:53 -050033The file "configure" defines default values for many environment variables
34that control the toybox build; if export any these variables into your
35environment, your value is used instead of the default in that file.
Rob Landley1cbc2832015-10-28 21:41:45 -050036
37The CROSS_COMPILE argument above is optional, the default builds a version of
Rob Landley0b87b2e2013-05-07 22:50:33 -050038toybox to run on the current machine. Cross compiling requires an appropriately
Rob Landley0cf49f52020-05-29 04:12:53 -050039prefixed cross compiler toolchain, several example toolchains (built using
40the file "scripts/mcm-buildall.sh" in the toybox source) are available at:
Rob Landley0b87b2e2013-05-07 22:50:33 -050041
Rob Landley0cf49f52020-05-29 04:12:53 -050042 https://mkroot.musl.cc/latest/
Rob Landley0b87b2e2013-05-07 22:50:33 -050043
44For the "CROSS_COMPILE=armv5l-" example above, download
45cross-compiler-armv5l.tar.bz2, extract it, and add its "bin" subdirectory to
46your $PATH. (And yes, the trailing - is significant, because the prefix
47includes a dash.)
48
49For more about cross compiling, see:
50
Rob Landley0cf49f52020-05-29 04:12:53 -050051 https://landley.net/toybox/faq.html#cross
Rob Landley0b87b2e2013-05-07 22:50:33 -050052 http://landley.net/writing/docs/cross-compiling.html
53 http://landley.net/aboriginal/architectures.html
Rob Landley09e8bde2012-02-04 12:20:39 -060054
Rob Landley0cf49f52020-05-29 04:12:53 -050055For a more thorough description of the toybox build process, see:
56
57 http://landley.net/toybox/code.html#building
Rob Landley1cbc2832015-10-28 21:41:45 -050058
Rob Landley09e8bde2012-02-04 12:20:39 -060059--- Using toybox
60
Rob Landley0b87b2e2013-05-07 22:50:33 -050061The toybox build produces a multicall binary, a "swiss-army-knife" program
62that acts differently depending on the name it was called by (cp, mv, cat...).
63Installing toybox adds symlinks for each command name to the $PATH.
Rob Landley09e8bde2012-02-04 12:20:39 -060064
Rob Landley0b87b2e2013-05-07 22:50:33 -050065The special "toybox" command treats its first argument as the command to run.
66With no arguments, it lists available commands. This allows you to use toybox
Rob Landley0cf49f52020-05-29 04:12:53 -050067without installing it, and is the only command that can have an arbitrary
Rob Landley0b87b2e2013-05-07 22:50:33 -050068suffix (hence "toybox-armv5l").
Rob Landley09e8bde2012-02-04 12:20:39 -060069
Rob Landley0cf49f52020-05-29 04:12:53 -050070The "help" command provides information about each command (ala "help cat"),
71and "help toybox" provides general information about toybox.
Rob Landley09e8bde2012-02-04 12:20:39 -060072
Rob Landley0b87b2e2013-05-07 22:50:33 -050073--- Configuring toybox
Rob Landley09e8bde2012-02-04 12:20:39 -060074
Rob Landley0b87b2e2013-05-07 22:50:33 -050075It works like the Linux kernel: allnoconfig, defconfig, and menuconfig edit
76a ".config" file that selects which features to include in the resulting
Rob Landley0cf49f52020-05-29 04:12:53 -050077binary. You can save and re-use your .config file, but may want to
Rob Landleye8bd47b2016-05-02 18:59:57 -050078run "make oldconfig" to re-run the dependency resolver when migrating to
79new versions.
Rob Landley09e8bde2012-02-04 12:20:39 -060080
Rob Landley0b87b2e2013-05-07 22:50:33 -050081The maximum sane configuration is "make defconfig": allyesconfig isn't
Rob Landley0cf49f52020-05-29 04:12:53 -050082recommended as a starting point for toybox because it enables unfinished
83commands, debug code, and optional dependencies your build environment may
84not provide.
Rob Landley0b87b2e2013-05-07 22:50:33 -050085
86--- Creating a Toybox-based Linux system
87
Rob Landley0cf49f52020-05-29 04:12:53 -050088Toybox has a built-in simple system builder (scripts/mkroot.sh) with a
89Makefile target:
Rob Landley0b87b2e2013-05-07 22:50:33 -050090
Rob Landley0cf49f52020-05-29 04:12:53 -050091 make root
92 sudo chroot root/host/fs /init
Rob Landley0b87b2e2013-05-07 22:50:33 -050093
Rob Landley0cf49f52020-05-29 04:12:53 -050094Type "exit" to get back out. If you install appropriate cross compilers and
95point it at Linux source code, it can build simple three-package systems
96that boot to a shell prompt under qemu:
Rob Landley0b87b2e2013-05-07 22:50:33 -050097
Rob Landley0cf49f52020-05-29 04:12:53 -050098 make root CROSS_COMPILE=sh4-linux-musl- LINUX=~/linux
99 cd root/sh4
100 ./qemu-sh4.sh
Rob Landley0b87b2e2013-05-07 22:50:33 -0500101
Rob Landley0cf49f52020-05-29 04:12:53 -0500102By calling scripts/mkroot.sh directly you can add additional packages
103to the build, see scripts/root/dropbear as an example.
Rob Landleya6916cd2015-04-07 14:59:32 -0500104
Rob Landley0cf49f52020-05-29 04:12:53 -0500105The FAQ explains this in a lot more detail:
Rob Landleye8bd47b2016-05-02 18:59:57 -0500106
Rob Landley0cf49f52020-05-29 04:12:53 -0500107 https://landley.net/toybox/faq.html#system
108 https://landley.net/toybox/faq.html#mkroot
Rob Landleya6916cd2015-04-07 14:59:32 -0500109
110--- Presentations
111
Rob Landleye8bd47b2016-05-02 18:59:57 -05001121) "Why Toybox?" talk at the Embedded Linux Conference in 2013
Rob Landleya6916cd2015-04-07 14:59:32 -0500113
Rob Landleya6916cd2015-04-07 14:59:32 -0500114 outline: http://landley.net/talks/celf-2013.txt
Rob Landley0cf49f52020-05-29 04:12:53 -0500115 video: http://youtu.be/SGmtP5Lg_t0
116
117 The https://landley.net/toybox/about.html page has nav links breaking that
118 talk down into sections.
Rob Landleya6916cd2015-04-07 14:59:32 -0500119
1202) "Why Public Domain?" The rise and fall of copyleft, Ohio LinuxFest 2013
121
Rob Landleya6916cd2015-04-07 14:59:32 -0500122 outline: http://landley.net/talks/ohio-2013.txt
Rob Landley0cf49f52020-05-29 04:12:53 -0500123 audio: https://archive.org/download/OhioLinuxfest2013/24-Rob_Landley-The_Rise_and_Fall_of_Copyleft.mp3
Rob Landleya6916cd2015-04-07 14:59:32 -0500124
1253) Why did I do Aboriginal Linux (which led me here)
126
127 260 slide presentation:
Rob Landley0cf49f52020-05-29 04:12:53 -0500128 https://speakerdeck.com/landley/developing-for-non-x86-targets-using-qemu
Rob Landleya6916cd2015-04-07 14:59:32 -0500129
130 How and why to make android self-hosting:
131 http://landley.net/aboriginal/about.html#selfhost
132
Rob Landley0cf49f52020-05-29 04:12:53 -0500133 More backstory than strictly necessary:
134 https://landley.net/aboriginal/history.html
135
Rob Landleya6916cd2015-04-07 14:59:32 -05001364) What's new with toybox (ELC 2015 status update):
137
138 video: http://elinux.org/ELC_2015_Presentations
139 outline: http://landley.net/talks/celf-2015.txt
Rob Landleyb057bac2015-12-01 11:13:08 -0600140
Rob Landley0cf49f52020-05-29 04:12:53 -05001415) Toybox vs BusyBox (2019 ELC talk):
142
143 outline: http://landley.net/talks/elc-2019.txt
144 video: https://www.youtube.com/watch?v=MkJkyMuBm3g
145
Rob Landleye8bd47b2016-05-02 18:59:57 -0500146--- Contributing
147
148The three important URLs for communicating with the toybox project are:
149
150 web page: http://landley.net/toybox
151
152 mailing list: http://lists.landley.net/listinfo.cgi/toybox-landley.net
153
154 git repo: http://github.com/landley/toybox
155
156The maintainer prefers patches be sent to the mailing list. If you use git,
157the easy thing to do is:
158
159 git format-patch -1 $HASH
160
161Then send a file attachment. The list holds messages from non-subscribers
162for moderation, but I usually get to them in a day or two.
163
Rob Landley0cf49f52020-05-29 04:12:53 -0500164I download github pull requests as patches and apply them with "git am"
165(which avoids gratuitous merge commits). Sometimes I even remember to close
166the pull request.
Rob Landleye8bd47b2016-05-02 18:59:57 -0500167
168If I haven't responded to your patch after one week, feel free to remind
169me of it.
170
171Android's policy for toybox patches is that non-build patches should go
172upstream first (into vanilla toybox, with discussion on the toybox mailing
173list) and then be pulled into android's toybox repo from there. (They
174generally resync on fridays). The exception is patches to their build scripts
175(Android.mk and the checked-in generated/* files) which go directly to AOSP.
Rob Landley0cf49f52020-05-29 04:12:53 -0500176
177(As for the other meaning of "contributing", https://patreon.com/landley is
178always welcome but I warn you up front I'm terrible about updating it.)