2
1

embedded-basics.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // -*- mode:doc; -*-
  2. Embedded system basics
  3. ----------------------
  4. When developing an embedded system, there are a number of choices to
  5. address:
  6. * the cross-toolchain: target architecture/C library/...
  7. * the bootloader
  8. * kernel options
  9. * the device management
  10. * the init system
  11. * the package selection (busybox vs. "real" programs, ...)
  12. * ...
  13. Some of these may be influenced by the target hardware.
  14. Some of the choices may also add some constraints when you develop the
  15. final application for which your target is designed (e.g. some
  16. functions may be provided by some C libraries and missing in some
  17. others, ...). So, these choices should be carefully made.
  18. Buildroot allows you to set most of these options to fit your needs.
  19. Moreover, Buildroot provides an infrastructure for reproducing the
  20. build process of your kernel, cross-toolchain, and embedded root
  21. filesystem. Being able to reproduce the build process will be useful
  22. when a component needs to be patched or updated or when another person
  23. is supposed to take over the project.
  24. [[cross-compilation-and-cross-toolchain]]
  25. Cross-compilation & cross-toolchain
  26. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. A compilation toolchain is the set of tools that allows you to compile
  28. code for your system. It consists of a compiler (in our case, +gcc+),
  29. binary utils like assembler and linker (in our case, +binutils+) and a
  30. C standard library (for example
  31. http://www.gnu.org/software/libc/libc.html[GNU Libc],
  32. http://www.uclibc.org/[uClibc] or
  33. http://www.fefe.de/dietlibc/[dietlibc]).
  34. The system installed on your development station certainly already has
  35. a compilation toolchain that you can use to compile an application
  36. that runs on your system. If you're using a PC, your compilation
  37. toolchain runs on an x86 processor and generates code for an x86
  38. processor. Under most Linux systems, the compilation toolchain uses
  39. the GNU libc (glibc) as the C standard library. This compilation
  40. toolchain is called the "host compilation toolchain". The machine on
  41. which it is running, and on which you're working, is called the "host
  42. system" footnote:[This terminology differs from what is used by GNU
  43. configure, where the host is the machine on which the application will
  44. run (which is usually the same as target)].
  45. The compilation toolchain is provided by your distribution, and
  46. Buildroot has nothing to do with it (other than using it to build a
  47. cross-compilation toolchain and other tools that are run on the
  48. development host).
  49. As said above, the compilation toolchain that comes with your system
  50. runs on and generates code for the processor in your host system. As
  51. your embedded system has a different processor, you need a
  52. cross-compilation toolchain - a compilation toolchain that runs on
  53. your _host system_ but generates code for your _target system_ (and
  54. target processor). For example, if your host system uses x86 and your
  55. target system uses ARM, the regular compilation toolchain on your host
  56. runs on x86 and generates code for x86, while the cross-compilation
  57. toolchain runs on x86 and generates code for ARM.
  58. Even if your embedded system uses an x86 processor, you might be
  59. interested in Buildroot for two reasons:
  60. * The compilation toolchain on your host certainly uses the GNU Libc
  61. which is a complete but huge C standard library. Instead of using
  62. GNU Libc on your target system, you can use uClibc which is a tiny C
  63. standard library. If you want to use this C library, then you need a
  64. compilation toolchain to generate binaries linked with it. Buildroot
  65. can do that for you.
  66. * Buildroot automates the building of a root filesystem with all
  67. needed tools like busybox. That makes it much easier than doing it
  68. by hand.
  69. You might wonder why such a tool is needed when you can compile +gcc+,
  70. +binutils+, +uClibc+ and all the other tools by hand. Of course doing
  71. so is possible, but dealing with all of the configure options and
  72. problems of every +gcc+ or +binutils+ version is very time-consuming
  73. and uninteresting. Buildroot automates this process through the use
  74. of Makefiles and has a collection of patches for each +gcc+ and
  75. +binutils+ version to make them work on most architectures.
  76. Buildroot offers a number of options and settings that can be tuned
  77. when defining the cross-toolchain (refer to xref:toolchain-custom[]).
  78. [[bootloader]]
  79. Bootloader
  80. ~~~~~~~~~~
  81. TODO
  82. [[device-management]]
  83. Device management
  84. ~~~~~~~~~~~~~~~~~
  85. TODO
  86. [[init-system]]
  87. Init system
  88. ~~~~~~~~~~~
  89. TODO