U-Boot: Introduction to U-Boot development

From Compulab Mediawiki
Jump to: navigation, search

Overview

This article describes the basics of U-Boot development, and is written to address the general case. Instructions that are specific to CompuLab U-Boot releases will be discussed in dedicated articles. This article is just an overview of typical steps in Linux development.

Getting the source code

While it is possible to download the source code manually as a tar ball, the proper way to obtain Linux source code is by using git, the source control system of choice for the Linux kernel. Working with git is essential to Linux development, so take the time to familiarize yourself with its interface.

  • Install git:
workstation-pc # sudo apt-get install git
  • cd into the development directory and invoke the git clone command on the Linux repository link:
workstation-pc # git clone git://git.denx.de/u-boot.git

You will now have a u-boot folder with the U-Boot source code on your workstation.

Getting to know the build system

The Linux kernel uses "make" for build automation and KConfig for build configuration. The make build automation program is invoked using:

workstation-pc # make <build target>

A list of the build targets can be obtained by invoking:

workstation-pc # make help

Below is a highlight of some of the common make targets:

Cleaning targets:
  clean           - Remove most generated files but keep the config
  mrproper	  - Remove all generated files + config + various backup files

Configuration targets:
  menuconfig	  - Update current config utilising a menu based program
  xconfig         - Update current config utilising a QT based front-end
  gconfig         - Update current config utilising a GTK based front-end
  oldconfig       - Update current config utilising a provided .config as base
  defconfig	  - New config with default from ARCH supplied defconfig
  savedefconfig   - Save current config as ./defconfig (minimal config)

Other generic targets:
  all             - Build all necessary images depending on configuration
* u-boot          - Build the bare u-boot

Execute "make" or "make all" to build all targets marked with [*] 
For further info see the ./README file

Configuring a build

U-Boot can support a vast variety of configurations, including multiple architectures, file systems, device drivers, networking features, security features, and more. The first step is to select which features are necessary for your use case. A set of prepared configurations can be found in configs folder. When working with CompuLab releases, a <product_name>_defconfig file will be found in this folder.

  • Configure the U-Boot:
workstation-pc # make xyz_defconfig

After applying a U-Boot configuration, invoke menuconfig to fine-tune the configuration. menuconfig is a menu based U-Boot configuration program which provides a menu navigation across all the available U-Boot features. menuconfig can turn features and device drivers on or off. Information about the various configuration options can be obtained using the help option (selected with the arrow keys, or the '?' key), and search for configuration options can be performed by pressing the '/' key.

  • Invoke menuconfig
workstation-pc # make menuconfig
 .config - U-Boot 2016.09-cl-som-imx7-0.91 Configuration
 ──────────────────────────────────────────────────────────────────────────────
  ┌───────────── U-Boot 2016.09-cl-som-imx7-0.91 Configuration ─────────────┐
  │  Arrow keys navigate the menu.  <Enter> selects submenus ---> (or empty │  
  │  submenus ----).  Highlighted letters are hotkeys.  Pressing <Y>        │  
  │  includes, <N> excludes, <M> modularizes features.  Press <Esc><Esc> to │  
  │  exit, <?> for Help, </> for Search.  Legend: [*] built-in  [ ]         │  
  │ ┌─────────────────────────────────────────────────────────────────────┐ │  
  │ │        Architecture select (ARM architecture)  --->                 │ │  
  │ │        ARM architecture  --->                                       │ │  
  │ │        General setup  --->                                          │ │  
  │ │        Boot images  --->                                            │ │  
  │ │        Boot timing  --->                                            │ │  
  │ │        Boot media  --->                                             │ │  
  │ │    (3) delay in seconds before automatically booting                │ │  
  │ │    [ ] Console recording                                            │ │  
  │ │    [ ] Disable support for parallel NOR flash                       │ │  
  │ │    [ ] add U-Boot environment variable vers                         │ │  
  │ │        Command line interface  --->                                 │ │  
  │ │        Device Tree Control  --->                                    │ │  
  │ │    -*- Networking support  --->                                     │ │  
  │ │        Device Drivers  --->                                         │ │  
  │ │        File systems  ----                                           │ │  
  │ │        Library routines  --->                                       │ │  
  │ │    [ ] Unit tests  ----                                             │ │  
  │ └─────────────────────────────────────────────────────────────────────┘ │  
  ├─────────────────────────────────────────────────────────────────────────┤  
  │        <Select>    < Exit >    < Help >    < Save >    < Load >         │  
  └─────────────────────────────────────────────────────────────────────────┘  

Building the U-Boot

  • Once the U-Boot is configured, type "make" to initiate a build.
workstation-pc # make
  • The resulting U-Boot images will appear in the working direktory