Skip to main content.

U-Boot Design Principles

Here are the 10 Golden Rules of U-Boot design:

1. Keep it Small

U-Boot is a Boot Loader, i.e. its primary purpose in the shipping system is to load some operating system. That means that U-Boot is necessary to perform a certain task, but it's nothing you want to throw any significant resources at. Typically U-Boot is stored in relatively small NOR flash memory, which is expensive compared to the much larger NAND devices often used to store the operating system and the application.

At the moment, U-Boot supports boards with just 128 KiB ROM or with 256 KiB NOR flash. We should not easily ignore such configurations - they may be the exception in among all the other supported boards, but if a design uses such a resource-constrained hardware setup it is usually because costs are critical, i. e. because the number of manufactured boards might be tens or hundreds of thousands or even millions...

A usable and useful configuration of U-Boot, including a basic interactive command interpreter, support for download over Ethernet and the capability to program the flash shall fit in no more than 128 KiB.

2. Keep it Fast

The end user is not interested in running U-Boot. In most embedded systems he is not even aware that U-Boot exists. The user wants to run some application code, and that as soon as possible after switching on his device.

It is therefore essential that U-Boot is as fast as possible, especially that it loads and boots the operating system as fast as possible.

To achieve this, the following design principles shall be followed:

Also, building of U-Boot shall be as fast as possible. This makes it easier to run a build for all supported configurations or at least for all configurations of a specific architecture, which is essential for quality insurance. If building is cumbersome and slow most people will omit this important step.

3. Keep it Simple

U-Boot is a boot loader, but it is also a tool used for board bring-up, for production testing, and for other activities

4. Keep it Portable

U-Boot is a boot loader, but it is also a tool used for board bring-up, for production testing, and for other activities that are very closely related to hardware development. So far, it has been ported to several hundreds of different boards on about 30 different processor families - please make sure that any code you add can be used on as many different platforms as possible.

Avoid assembly language whenever possible - only the reset code with basic CPU initialization, maybe a static DRAM initialization and the C stack setup should be in assembly. All further initializations should be done in C using assembly/C subroutines or inline macros. These functions represent some kind of HAL functionality and should be defined consistently on all architectures. E.g. Basic MMU and cache control, stack pointer manipulation. Non-existing functions should expend into empty macros or error codes.

Don't make assumptions over the environment where U-Bot is runnign. It may be communicating with a human operator on directly attached serial console, but it may be through a GSM modem as well, or driven by soime automatic test or control system. So don't output any fancy control character sequences or similar.

5. Keep it Configurable

Section "Keep it Small" already explains about the size restrictions for U-Boot on one side. On the other side, U-Boot is a powerful tool with many, many extremely useful features. The maintainer or user of each board will have to decide which features are important to him and what shall be included with his specific board configuration to meet his current requirements and restrictions.

Please make sure that it is easy to add or remove features from a board configuration, so everybody can make the best use of U-Boot on his system.

If a feature is not included, it should not have any residual code bloating the build.

6. Keep it Debuggable

Of course debuggable code is a big benefit for all of us contributing in one way or another to the development of the U-Boot project. But as already mentioned in section "Keep it Portable" above, U-Boot is not only a tool in itself, it is often also used for hardware bring-up, so debugging U-Boot often means that we don't know if we are tracking down a problem in the U-Boot software or in the hardware we are running on. Code that is clean and easy to understand and to debug is all the more important to many of us.

7. Keep it Usable

Please always keep in mind that there are at least three different groups of users for U-Boot, with completely different expectations and requirements:

Please always keep in mind that U-Boot tries to meet all these different requirements.

8. Keep it Maintainable

9. Keep it Beautiful

10. Keep it Open

Contribute your work back to the whole community. Submit your changes and extensions as patches to the U-Boot mailing list.