Customizing U-Boot on i.MX

Published on October 22, 2010

Archived Notice

This article has been archived and may contain broken links, photos and out-of-date information. If you have any questions, please Contact Us.

Many of our customers have needs at the boot loader level that differ slightly from our standard releases. Some choose to track these changes in their own version control systems and periodically pull in updates from our git repository. If the custom changes are large, this makes perfect sense. If the changes are really small, we've introduced a new way of doing things that allows overrides of the board configuration file 'include/configs/nitrogen.h', which accounts for the vast majority of our customers' needs. This patch in our git repository shows the details, and the comment describes the limitations:

The purpose of this is to not pollute the git history of the board in order to override one or two settings. If things get complicated, use a branch instead.
Let's walk through an example. One of our customers wants to gracefully and automatically handle the situation where either there's an intermittent SD card failure at boot time or an SD card has been removed from the Nitrogen. They want to show a message on the screen, but attempt to recover by re-booting. This can be done by overriding the bootcmd environment variable, which shows up in the C code as CONFIG_BOOTCMD. They also don't want to pause to wait for a user to break the boot on the serial console. This change involves the U-Boot environment variable bootdelay and shows up as CONFIG_BOOTDELAY in the U-Boot sources.
#ifndef __CUSTOM_H__
#define __CUSTOM_H__
#define CONFIG_BOOTCOMMAND "fatload mmc 0 90008000 nitrogen_bootscript && source 90008000 ; echo failed ; lecho SD card error ; sleep 2 ; reset ; reset"
To compile this, you specify the name of the custom header file during configuration and then build as normal: user@host:~/u-boot$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- CUSTOM_CONFIG=~/u-boot-custom.h nitrogen_config user@host:~/u-boot$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- all Note that this particular setup will make it difficult to use U-Boot, and is suggested only for production use. During development, you'll want to have a version that does allow you to get to a prompt.