AT91RM9200-EK Boot.bin and U-Boot

At this time, I am unable to reproduce the steps necessary to boot from Dataflash. I have created a recovery image for a Dataflash Card that can be used to boot from the card in an emergency situation, however, which can be found on the following page: U-Boot from Dataflash.

This document focuses purely on booting from Parallel flash.

The AT91RM9200-EK has a three-stage boot process:

  1. BootROM — Finds a valid bootstrap image and loads it into SRAM.
  2. Boot.bin — Initializes hardware and loads an image into SDRAM from Flash.
  3. U-Boot — Boots Linux kernel.

BootROM

The at91rm9200 comes with a barebones bootloader in ROM.

The BootROM code resides on the actual AT91RM9200 silicon, and is executed at power-on. It looks for a valid set of bootstrap vectors in three different locations, in the following order:

  • The first block of the External DataFlash Card inserted at J200.
  • The first block an I2C EEPROM (Not populated on board).
  • The first block of the On-board Parallel flash chip located at U201.

If no valid ARM vector sequence is found, the boot uploader is started. It initializes the Debug Unit serial port (DBGU) and the USB device port. It then waits for any transaction and downloads a piece of code into the internal SRAM via a Device Firmware Upgrade (DFU) protocol for USB and XMODEM protocol for the DBGU. After the end of the download, it branches to the application entry point at the first address of the SRAM.

boot.bin

Boot.bin is a file that simply decompresses a gzipped file from flash and loads it into SDRAM for execution. It emits the following message on the console:

Low Level Init performed                                                       

boot 1.0 (Nov 25 2003 - 23:08:05)                                              

Uncompressing image... 

Boot.bin is not available from Atmel anymore. Instead, just use the file attached to this page: boot.bin.

Sources

The sources for U-Boot are available in Subversion.

The AT91RM9200-DK is in the mainline U-Boot. It is extremely simple to modify this to work on the EK board. Simply copy the board directory and change all references of "DK" to "EK", and copy the config file (include/configs/at91rm9200dk.h) and do the same find and replace.

Building U-Boot

  1. Download the sources and decompress the archive into a working directory.
  2. Enter the U-Boot directory.
  3. Configure U-Boot with the following command:
    make at91rm9200ek_config
  4. U-Boot uses a basic make command, with CROSS_COMPILE variable. Assuming that the toolchain is in your path,
    make CROSS_COMPILE=armv4l-linux-

    will compile U-Boot. The resulting file will be in the U-Boot root directory as u-boot.bin.
  5. Compress the binary file using gzip
    gzip u-boot.bin

    will produce the gzipped file u-boot.bin.gz.

Flashing to the Board

If this is the first time flashing the board, you must use a JTAG debugger to put the bootloaders on the board in the following locations:

Flash Memory Map

Start Address Size Function
0x0 0x6000 boot.bin
0xE000 0x2000 U-Boot Environment
0x10000 0x10000 U-Boot

If you are using the Recovery Image, you can use the U-Boot commands to write to flash.

  1. Make sure jumper J15 1-2 (EXT) is installed. This will cause the board to boot from the Dataflash card.
  2. Plug the null modem cable into the serial debug port, J10, and connect it to the host machine.
  3. Connect the Ethernet cable to J2. Make sure that the cable is plugged into a port that can be accessed by the TFTP service.
  4. Ensure that the new U-Boot file (u-boot.bin.gz) is included in the /tftpboot directory.
  5. Turn on the board. If U-Boot has been configured to autoboot, stop the process and get a command-prompt.
  6. Download boot.bin into RAM:
    Uboot> tftp 0x21400000 boot.bin
    TFTP from server 10.10.0.4; our IP address is 10.10.0.12
    Filename 'boot.bin'.
    Load address: 0x21400000
    Loading: ###
    done
    Bytes transferred = 10460 (28dc hex)
  7. Unprotect the U-Boot sectors:
    Uboot> protect off 10000000 10005fff                                    
    Un-Protected 3 sectors
  8. Erase the data from the sectors:
    Uboot> erase 10000000 10005fff
    Erase Flash from 0x10000000 to 0x10005fff...
    Erasing sector 0 ... ok.
    Erasing sector 1 ... ok.
    Erasing sector 2 ... ok.
    done.
    Erased 3 sectors.
  9. Copy boot.bin from RAM to Flash:
    Uboot> cp.b 21400000 10000000 2fff                                             
    Copy to Flash... done
  10. Download U-Boot into RAM:
    Uboot> tftp 0x20000000 u-boot.bin.gz
    TFTP from server 10.10.0.2; our IP address is 10.10.0.10
    Filename 'u-boot-9200EK.gz'.
    Load address: 0x20000000
    Loading: ###########
    done
    Bytes transferred = 52054 (cb56 hex)
  11. Unprotect the U-Boot sector:
    Uboot> protect off 10010000 1001ffff
    Unprotect 1 sectors
  12. Clear the existing bootloader from the board:
    Uboot> erase 10010000 1001ffff
    Erase Flash from 0x10010000 to 0x1001ffff...
    Erasing sector 8 ... ok.
    done.
    Erased 1 sectors.
  13. Copy the U-Boot image from RAM to the on-board DataFlash:
    Uboot> cp.b 20000000 10010000 FFFF
    Copy to flash ... done.
  14. Move the jumper J15 to pins 2-3.

MAC Address

The at91rm9200 pulls it's MAC address from the U-Boot environment. This means it can be written on the fly. U-Boot will only allow you to write this variable once, although you can erase the environment and write it again if you like.

To set the MAC Address, use the setenv and saveenv commands.

Example:

U-Boot> setenv ethaddr 12:34:56:78:9a:bc
U-Boot> saveenv

The MAC Address can be found using the printenv command.

Example:

U-Boot> printenv
baudrate=115200
bootfile="uImage" 
stdin=serial
stdout=serial
stderr=serial
ethaddr=12:34:56:78:9a:bc

Boot Process

Preparing the Host

You need to have a TFTP server running on the host. You may also need a DHCP server, unless you are using the tftp command to load files.

The kernel file should be in your tftpboot directory.

Preparing the Target

You must set a few environment variables in order to boot the board over TFTP and DHCP. This is done with the setenv and saveenv commands in U-Boot.

On the target, set the following environment variables:

Variable Value
loadaddr 0x21400000
bootfile <Name of kernel file on Host Machine>
bootargs console=ttyS0,115200 console=tty0 ip=dhcp root=/dev/nfs rw
bootcmd bootp\;bootm
ethaddr <MAC address of the board>

Example:

U-Boot> setenv loadaddr 0x21400000
U-Boot> setenv bootfile <Name of kernel file on Host Machine>
U-Boot> setenv bootargs console=ttyS0,115200 console=tty0 ip=dhcp root=/dev/nfs rw
U-Boot> setenv bootcmd bootp\;bootm
U-Boot> setenv ethaddr 12:34:56:78:9a:bc
U-Boot> saveenv

Loading the Kernel

You can use bootp, dhcp, or tftp to load the kernel. Note that the DHCP server needs to be set up for the first two, and tftp is necessary for all three.

Example:

U-Boot> bootp
BOOTP broadcast 1                                                               
TFTP from server 10.10.0.4; our IP address is 10.10.0.15                        
Filename 'kernel-at91rm9200-1'.                                                
Load address: 0x21400000                                                        
Loading: #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         #################################################################      
         ######                                                                 
done                                                                            
Bytes transferred = 1692464 (19d330 hex)

Booting the Kernel

The bootm command is used to boot the kernel. It loads the file that was previously uploaded using the bootp, dhcp, or tftp commands.

Example:

U-Boot> bootm
## Booting image at 21400000 ...                                                
   Image Name:   Linux-2.6.27                                                   
   Image Type:   ARM Linux Kernel Image (uncompressed)                          
   Data Size:    1692400 Bytes =  1.6 MB                                        
   Load Address: 20008000                                                       
   Entry Point:  20008000                                                       
   Verifying Checksum ... OK                                                    
OK                                                                              

Starting kernel ... 

Generic Bootloader Information

For more information about U-Boot, please see the generic bootloader information: