Hardware Reference
In-Depth Information
necessarily requires some loss of control over the low-level implementation details. You
generally trade ease of use for certain low-level optimizations in the code and drivers.
This tradeoff makes sense in many situations, but obviously there is no one-size-fits-all
approach with embedded development.
In the product design world, performance and control often trump ease of use, and
many engineers still prefer to handle all of the implementation details themselves, writ‐
ing their own low-level drivers and setting up their own build environment. Writing
your own low-level drivers clearly requires more development effort, but it also ensures
you have maximum control over the code running your products. It also forces you to
understand the processor more intimately and allows you to optimize for performance
and cost to a far greater extent.
Being able to fully optimize the code for size and performance is extremely important
with embedded products. Optimizing for code size, for example, might allow you to use
a smaller and cheaper processor, shaving $2 or $3 off the bill of materials, which can
easily translate into $5 to $10 or more on the retail price. That savings can make all the
difference between a product that succeeds or something that fails because it ends up
in the wrong price bracket. The best way to control the final code size and performance
is to have full control over your compiler and your build environment, allowing you to
make the most out of every clock cycle on your embedded processor or SoC.
Compiling code for small embedded processors requires something called a toolchain .
As the name implies, a toolchain is a collection of tools used to build executable code,
and one of the most important parts of this toolchain is the cross-compiler . The cross-
compiler compiles code while running on one architecture (for example, using an x86
instruction set) but produces code for a different architecture (for example, some variant
of ARM). You have a number of commercial and open source options for cross compilers
and low-level embedded toolchains, both commercial and open source, but we'll focus
on an open source solution in this section.
In recent years, GCC (the free, open source compiler collection that's part of the GNU
project) has made significant leaps and bounds in its support for ARM. Most of these
advances are related to the dominance of ARM in the mobile phone and tablet arena
(typically using ARM Cortex-A processors), but small, deeply embedded processors
(ARM Cortex-M, etc.) have also benefited from the huge investments made here, due
to overlapping instruction sets.
Widely used in a variety of industries, GCC is also conveniently available on any modern
operating system and architecture. Code targetting GCC is generally highly portable,
and you can build the same output on Linux, OS X, Windows, or almost any other
environment you can imagine with no meaningful variation in the compiler output.
The latter point is extremely important and one of the main factors that makes GCC an
excellent choice for embedded development. GCC does an excellent job with ARM
Search WWH ::




Custom Search