[U-Boot] [PATCH 0/6] Adjust command macros to allow smaller U-Boot size
Simon Glass
sjg at chromium.org
Mon Mar 24 16:51:05 CET 2014
A large chunk of U-Boot's executable size is the code to process and
execute commands. This is reasonable, since commands and scripts are
an important part of U-Boot's feature set and provide much of its
flexibility.
However, for some applications only a very limited set of commands is
required. Where image size is important, it is desirable to be able to
easily remove unwanted code.
This series introduces a new board_run_command() function which can
be used to run a small subset of commands as required by the board
(typically load and bootm), thus allowing the rest of the commands
to be automatically and reliably dropped from the image using toolchain
dead code elimination.
Tests on snow (ARMv7) show this reduces image size dramatically, more
than just undefining all the commands:
text data bss dec hex filename
before:
356359 12550 300056 668965 a3525 b/snow/u-boot
with all commands undefined:
155336 5402 8624 169362 29592 b/snow/u-boot
with this series:
123177 2958 1544 127679 1f2bf b/snow/u-boot
The difference is more pronounced the more effort is put into reducing
the image size. For example, removing additional subsystem options yields:
text data bss dec hex filename
with all commands undefined and most subsystems:
86479 4186 7480 98145 17f61 b/snow/u-boot
with this series:
52395 1818 228 54441 d4a9 b/snow/u-boot
Further, it is possible to enable some of the split-use options like
CONFIG_CMD_USB, and get USB support without the unwanted command
overhead (it would be better if USB had a separate option for the command
and the USB stack, but that is not the case, and a few other features have
a similar problem).
U-Boot can then become a really minimal boot loader, with only the required
functions available. Simply undefining various unwanted commands in the
board config is not as effective, and is much more time-consuming to
figure out. Apart from the cost of the parsing code, the commands
necessarily provide a lot options and features which are not required
by many boards.
In particular, with this series, it is possible to run a minimal U-Boot
within the SRAM of a modern SoC, providing the benefits of the full U-Boot
environment with the small size of SPL. This helps to bridge the gap
somewhat. A key difference between U-Boot and SPL is the inclusion of the
command parser, and this small size of SPL is a key reason why some boards
currently use 'falcon mode', where only SPL is used to boot a kernel.
This series has a fairly small impact on the source code, changing
command.h and a fairly small change to each list of subcommands (there
are about 19 such sites in U-Boot).
Note: some effort was expended in trying to obtain the same result with
just linker code elimination. However this did not work, since the linker
would not eliminate some transitively-called functions like do_fdt() even
when callers are removed.
Simon Glass (6):
Add an info word to commands
Refactor command macros so they can compile to nothing
Add CONFIG_CMDLINE to allow removal of all commands
main: Exclude getline code when CONFIG_CMDLINE is not defined
main: Process FDT options even without CONFIG_BOOTDELAY
sandbox: Add board_run_command() function
README | 8 +++
arch/x86/cpu/u-boot.lds | 4 ++
board/inka4x0/inkadiag.c | 12 ++--
board/intercontrol/digsy_mtc/cmd_mtc.c | 20 +++----
board/sandbox/sandbox/sandbox.c | 10 ++++
common/cmd_bmp.c | 8 +--
common/cmd_bootm.c | 39 ++++++++-----
common/cmd_bootstage.c | 10 ++--
common/cmd_cbfs.c | 3 +-
common/cmd_clk.c | 6 +-
common/cmd_demo.c | 10 ++--
common/cmd_help.c | 4 ++
common/cmd_i2c.c | 34 +++++------
common/cmd_nvedit.c | 42 +++++++-------
common/cmd_onenand.c | 23 ++++----
common/cmd_pxe.c | 6 +-
common/cmd_sandbox.c | 14 ++---
common/cmd_sound.c | 8 +--
common/cmd_spl.c | 14 ++---
common/cmd_tpm.c | 52 ++++++++---------
common/command.c | 12 +++-
common/main.c | 101 ++++++++++++++++++++++----------
drivers/gpio/pca953x.c | 14 ++---
drivers/gpio/tca642x.c | 14 ++---
drivers/misc/ds4510.c | 24 ++++----
include/command.h | 102 ++++++++++++++++++++++++++++-----
include/config_defaults.h | 2 +
include/config_fallbacks.h | 7 +++
test/dm/cmd_dm.c | 10 ++--
29 files changed, 392 insertions(+), 221 deletions(-)
--
1.9.1.423.g4596e3a
More information about the U-Boot
mailing list