RPi U-Boot
Back to the Hub.
Software & Distributions:
Software - an overview.
Distributions - operating systems and development environments for the Raspberry Pi.
Kernel Compilation - advice on compiling a kernel.
Performance - measures of the Raspberry Pi's performance.
Programming - programming languages that might be used on the Raspberry Pi.
Overview
Das U-Boot, often abbreviated to just U-Boot, is a bootloader commonly used on embedded systems. U-Boot can be used on the RPi to add flexibility by allowing other boot configurations to be used on top of the single specified file on the SD card.
This page explains how to get U-Boot working on the RPi, and explains how to boot images off both the SD card and over TFTP from the network.
Get the source
Various forks of U-Boot contain (different levels of) support for the Raspberry Pi.
If you don't need USB networking support in U-Boot, the mainline repository is recommended. If you do need USB networking support in U-Boot, Stephen Warren's repository is recommended.
Mainline
The primary repository for U-Boot is git://git.denx.de/u-boot.git master branch. This supports the UART (serial port), SD card, and HDMI display. As of 20140110, the primary missing feature is USB support, and hence networking support.
To download this repository into a new local repository (this is what you want if you don't know better):
git clone git://git.denx.de/u-boot.git
To add this repository to an existing local repository:
git remote add u-boot git://git.denx.de/u-boot.git git fetch u-boot
Stephen Warren's work-in-progress branch
Stephen Warren is working on getting BCM2835 USB support into the mainline repository described above. His work-in-progress repository is git://github.com/swarren/u-boot.git rpi_dev branch. Note that this branch is often rebased, and may contain work other than mainline-quality RPi-related patches.
To download this repository into a new local repository (this is what you want if you don't know better):
git clone git://github.com/swarren/u-boot.git git checkout -b rpi_dev origin/rpi_dev
To add this repository to an existing local repository:
git remote add github_swarren_u-boot git://github.com/swarren/u-boot.git git fetch github_swarren_u-boot git checkout -b rpi_dev github_swarren_u-boot/rpi_dev
Oleksandr Tymoshenko's branch
Oleksandr's branch is based on an old U-Boot release, but does contain working USB support. It is available at git://github.com/gonzoua/u-boot-pi.git branch master.
To download this repository into a new local repository (this is what you want if you don't know better):
git clone git://github.com/gonzoua/u-boot-pi.git
To add this repository to an existing local repository:
git remote add github_gonzoua_u-boot-pi git://github.com/gonzoua/u-boot-pi.git git fetch github_gonzoua_u-boot-pi
You can download a source tarball from this link.
Compile the source
Firstly, you will need to export the cross-compiler prefix in order to target the RPI. Assuming your gcc binary is arm-none-linux-gnueabi-gcc, the command is:
CROSS_COMPILE=arm-none-linux-gnueabi- export CROSS_COMPILE
Then, in the U-Boot source directory, run the following to start the build:
make rpi_b
The build process should take no more than a few minutes. u-boot.bin should have been created.
Prepare the image file
Follow kernel compilation instructions to obtain kernel.img from u-boot.bin.
Once complete, transfer your kernel.img file to the SD card. You may want to rename it to something like uboot.img to distinguish it from an actual kernel image. Ensure that you have the following line in your config.txt file:
kernel=uboot.img
Test the image
Boot up the RPi with your new U-Boot image. You should see U-Boot load on the screen, and also on the serial port output (if you have it connected up).
Preparing a kernel image for use with U-Boot
This assumes you have the kernel source and are familiar with the kernel compilation process. As the kernel source already has the ability to build U-Boot image files, preparing a kernel image is relatively easy. First, you will need to put the U-Boot tool mkimage where it can be found by the kernel make process. This is done by copying it to the cross-compiler bin directory. From the U-Boot source directory, run the following, substituting the location and prefix of your cross compiler accordingly:
cp tools/mkimage <your_cross_compiler_path>/bin/arm-none-linux-gnueabi-mkimage
In the kernel source directory, you can now build the U-Boot image:
make uImage
The generated boot image file can be found at arch/arm/boot/uImage.
U-Boot boot options
Boot from SD card
Booting from the SD card allows multiple kernel images to be used without having to edit the config.txt file. Place your uImage file(s) on the SD card, then boot up. Press a key to drop to the command line, then enter the following:
mmc rescan fatload mmc 0:1 ${loadaddr} <your_uImage_file> bootm
Network boot via TFTP
You will need to have a TFTP server configured. Place your uImage file(s) in the TFTP root directory, and ensure that the file permissions are set accordingly (everyone should have read access - use chmod a+r uImage if unsure).
To boot using DHCP, ensure that the next-server and filename options are set in your DHCP server. Then, boot up the RPi, press a key to drop to the command line, then enter the following:
usb start dhcp bootm
To boot using static IP:
usb start setenv serverip <tftp_server_ip> setenv ipaddr <a_spare_ip_address> tftpboot uImage bootm
U-Boot script files
The above instructions can be written into a text file and compiled into a U-Boot script file so that it automatically executes on boot. First, generate the script as follows (substituting your mkimage with that created earlier:
arm-none-linux-gnueabi-mkimage -A arm -O linux -T script -C none -d <your_script_text_file> boot.scr
Place the boot.scr file on the SD card and it will automatically be used when you power up the RPi.
|