README 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. Toybox: all-in-one Linux command line.
  2. --- Getting started
  3. You can download static binaries for various targets from:
  4. http://landley.net/toybox/bin
  5. The special name "." indicates the current directory (just like ".." means
  6. the parent directory), and you can run a program that isn't in the $PATH by
  7. specifying a path to it, so this should work:
  8. wget http://landley.net/toybox/bin/toybox-x86_64
  9. chmod +x toybox-x86_64
  10. ./toybox-x86_64 echo hello world
  11. --- Building toybox
  12. Type "make help" for build instructions.
  13. Toybox uses the "make menuconfig; make; make install" idiom same as
  14. the Linux kernel. Usually you want something like:
  15. make defconfig
  16. make
  17. make install
  18. Or maybe:
  19. LDFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox
  20. PREFIX=/path/to/root/filesystem/bin make install_flat
  21. The file "configure" defines default values for many environment variables
  22. that control the toybox build; if you export any of these variables into your
  23. environment, your value is used instead of the default in that file.
  24. The CROSS_COMPILE argument above is optional, the default builds a version of
  25. toybox to run on the current machine. Cross compiling requires an appropriately
  26. prefixed cross compiler toolchain, several example toolchains (built using
  27. the file "scripts/mcm-buildall.sh" in the toybox source) are available at:
  28. https://mkroot.musl.cc/latest/
  29. For the "CROSS_COMPILE=armv5l-" example above, download
  30. cross-compiler-armv5l.tar.bz2, extract it, and add its "bin" subdirectory to
  31. your $PATH. (And yes, the trailing - is significant, because the prefix
  32. includes a dash.)
  33. For more about cross compiling, see:
  34. https://landley.net/toybox/faq.html#cross
  35. http://landley.net/writing/docs/cross-compiling.html
  36. http://landley.net/aboriginal/architectures.html
  37. For a more thorough description of the toybox build process, see:
  38. http://landley.net/toybox/code.html#building
  39. --- Using toybox
  40. The toybox build produces a multicall binary, a "swiss-army-knife" program
  41. that acts differently depending on the name it was called by (cp, mv, cat...).
  42. Installing toybox adds symlinks for each command name to the $PATH.
  43. The special "toybox" command treats its first argument as the command to run.
  44. With no arguments, it lists available commands. This allows you to use toybox
  45. without installing it, and is the only command that can have an arbitrary
  46. suffix (hence "toybox-armv5l").
  47. The "help" command provides information about each command (ala "help cat"),
  48. and "help toybox" provides general information about toybox.
  49. --- Configuring toybox
  50. It works like the Linux kernel: allnoconfig, defconfig, and menuconfig edit
  51. a ".config" file that selects which features to include in the resulting
  52. binary. You can save and re-use your .config file, but may want to
  53. run "make oldconfig" to re-run the dependency resolver when migrating to
  54. new versions.
  55. The maximum sane configuration is "make defconfig": allyesconfig isn't
  56. recommended as a starting point for toybox because it enables unfinished
  57. commands, debug code, and optional dependencies your build environment may
  58. not provide.
  59. --- Creating a Toybox-based Linux system
  60. Toybox has a built-in simple system builder (scripts/mkroot.sh) with a
  61. Makefile target:
  62. make root
  63. sudo chroot root/host/fs /init
  64. Type "exit" to get back out. If you install appropriate cross compilers and
  65. point it at Linux source code, it can build simple three-package systems
  66. that boot to a shell prompt under qemu:
  67. make root CROSS_COMPILE=sh4-linux-musl- LINUX=~/linux
  68. cd root/sh4
  69. ./qemu-sh4.sh
  70. By calling scripts/mkroot.sh directly you can add additional packages
  71. to the build, see scripts/root/dropbear as an example.
  72. The FAQ explains this in a lot more detail:
  73. https://landley.net/toybox/faq.html#system
  74. https://landley.net/toybox/faq.html#mkroot
  75. --- Presentations
  76. 1) "Why Toybox?" talk at the Embedded Linux Conference in 2013
  77. outline: http://landley.net/talks/celf-2013.txt
  78. video: http://youtu.be/SGmtP5Lg_t0
  79. The https://landley.net/toybox/about.html page has nav links breaking that
  80. talk down into sections.
  81. 2) "Why Public Domain?" The rise and fall of copyleft, Ohio LinuxFest 2013
  82. outline: http://landley.net/talks/ohio-2013.txt
  83. audio: https://archive.org/download/OhioLinuxfest2013/24-Rob_Landley-The_Rise_and_Fall_of_Copyleft.mp3
  84. 3) Why did I do Aboriginal Linux (which led me here)
  85. 260 slide presentation:
  86. https://speakerdeck.com/landley/developing-for-non-x86-targets-using-qemu
  87. How and why to make android self-hosting:
  88. http://landley.net/aboriginal/about.html#selfhost
  89. More backstory than strictly necessary:
  90. https://landley.net/aboriginal/history.html
  91. 4) What's new with toybox (ELC 2015 status update):
  92. video: http://elinux.org/ELC_2015_Presentations
  93. outline: http://landley.net/talks/celf-2015.txt
  94. 5) Toybox vs BusyBox (2019 ELC talk):
  95. outline: http://landley.net/talks/elc-2019.txt
  96. video: https://www.youtube.com/watch?v=MkJkyMuBm3g
  97. --- Contributing
  98. The three important URLs for communicating with the toybox project are:
  99. web page: http://landley.net/toybox
  100. mailing list: http://lists.landley.net/listinfo.cgi/toybox-landley.net
  101. git repo: http://github.com/landley/toybox
  102. The maintainer prefers patches be sent to the mailing list. If you use git,
  103. the easy thing to do is:
  104. git format-patch -1 $HASH
  105. Then send a file attachment. The list holds messages from non-subscribers
  106. for moderation, but I usually get to them in a day or two.
  107. I download github pull requests as patches and apply them with "git am"
  108. (which avoids gratuitous merge commits). Sometimes I even remember to close
  109. the pull request.
  110. If I haven't responded to your patch after one week, feel free to remind
  111. me of it.
  112. Android's policy for toybox patches is that non-build patches should go
  113. upstream first (into vanilla toybox, with discussion on the toybox mailing
  114. list) and then be pulled into android's toybox repo from there. (They
  115. generally resync on fridays). The exception is patches to their build scripts
  116. (Android.mk and the checked-in generated/* files) which go directly to AOSP.
  117. (As for the other meaning of "contributing", https://patreon.com/landley is
  118. always welcome but I warn you up front I'm terrible about updating it.)