How To Write Bootloaders to Flash on Atmel SAM9 Boards

Overview

The Atmel AT91SAM9 boards are typically free of any software when first powered on. Timesys provides bootloader files for booting a Linux kernel, which are loaded into persistent memory on the boards using the SAM-BA tool, provided by Atmel. The AT91SAM9 boards have a three-stage boot process:

  1. BootROM - Finds a valid bootstrap image and loads it into SRAM.
  2. AT91 Bootstrap Loader - Initializes hardware and loads an image into SDRAM.
  3. U-Boot - Boots Linux kernel.

This document describes the method for setting up an AT91SAM9 board so that it can boot a Linux kernel.

NOTE: The AT91SAM9G45-EK does not support booting from dataflash at this time.

Prerequisites

  • SAM-BA Tool

Getting Bootloader Binaries

Bootloader binaries are provided by Timesys for some boards. These can typically be downloaded alongside the platform installer on LinuxLink. They are also provided for some boards by the Factory. They can be found in the locations:

AT91 Bootstrap Loader <Factory root>/build_<arch>-timesys-linux-<libc>/images/bootloader/<boot location>_<board>.bin
U-Boot <Factory root>/build_<arch>-timesys-linux-<libc>/images/bootloader/u-boot.bin

If you have a custom board, or if Timesys does not support AT91 Bootstrap Loader or U-Boot for your board, you may need to build them from source. For generic instructions on building bootloaders, see the following documents:

HOWTO Build AT91 Bootstrap Loader
HOWTO Build U-Boot

Determining your Boot Process

There are a number of ways to store AT91 Bootstrap Loader and U-Boot in flash.

The default method is to have both AT91 Bootstrap Loader and U-Boot in Dataflash.

However, you can also choose to boot from NAND flash on many of the boards. The method for configuring the bootloaders to boot from NAND flash can be found in this document.

Important Notes

Dataflash Partition Incompatibilities

Dataflash chips have a block size of 0x4200 bytes. However, many of the older ports of U-Boot used a block size of 0x4000. This is fixed in the mainline port (as of version 2008.10), and has always been correct for the AT91CAP9A-DK board. Unfortunately, the official AT91 bootstrap loader (version 1.10 or older) still uses the old, incorrect block size. The Timesys version of AT91 Bootstrap v1.10 has been patched to fix the dataflash problem, and is fully compatible with the mainline version of U-Boot. The official version of the AT91Bootstrap has been fixed as of version 1.11.

For the best compatibility, please use the same revision of both AT91 Bootstrap and U-Boot in the Timesys repository. For command-line Factory users, try to use the default AT91 Bootstrap and U-Boot configurations, which are guaranteed to be compatible.

NAND Flash Errata

On the at91sam9260, at91sam9261, and at91sam9263 revision A processors, there is an issue with NAND timings in the boot ROM silicon. This means that you cannot load AT91 Bootstrap from the NAND flash chip — you must load AT91 Bootstrap from Dataflash. It is still possible to run U-Boot from NAND, however. If you wish to use this configuration, put the bootloaders in the following locations:

  1. nandflash_<board name>.bin at Dataflash address 0x0
  2. u-boot.bin at NAND flash address 0x20000

Writing AT91Bootstrap Loader to Flash

Dataflash

  1. Start up SAM-BA.
  2. Enable the DataFlash chip
    1. Click the DataFlash AT45 tab.
    2. Determine which chip select to use. Most of the EK boards use CS0, except for the AT91SAM9260-EK and AT91SAM9G20-EK, which use CS1 for the on-board dataflash.
    3. Select Enable Dataflash on CSx under the Scripts dropdown and click Execute.
  3. Burn the AT91 Bootstrap Loader file to DataFlash:
    1. Select Send Boot File under the Scripts dropdown and click Execute.
    2. Navigate to the .bin file and click Open.
  4. You may leave SAM-BA open until you write U-Boot to the board.

NAND flash

  1. Start up SAM-BA.
  2. Enable the NAND Flash.
    1. Click on the NandFlash tab, select Enable NandFlash under the scripts dropdown.
    2. Select Enable NandFlash under the Scripts dropdown and click Execute.
  3. Burn the AT91 Bootstrap Loader file to NAND flash.
    1. Select Send Boot File under the Scripts dropdown and click Execute.
    2. Navigate to the .bin file and click Open.
  4. You may leave SAM-BA open until you write U-Boot to the board.

Writing U-Boot to Flash

Dataflash

  1. Start up SAM-BA, if it is not already open.
  2. Burn U-Boot to DataFlash.
    1. Click the DataFlash AT45 tab.
    2. Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to the u-boot.bin file and click Open.
    3. Set the Address box to 0x8400 for U-Boot 2008.10 or newer, or the AT91CAP9A-DK. If you are using an older version of U-Boot, use the address 0x8000.
    4. Click Send File.
  3. Close SAM-BA and reset the board.

NAND flash

  1. Start up SAM-BA, if it is not already open.
  2. Burn U-Boot to NAND Flash.
    1. Click the NandFlash tab.
    2. Select Enable NandFlash under the Scripts dropdown and click Execute.
    3. Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to the u-boot.bin file and click Open.
    4. Set the Address box to 0x20000.
    5. Click Send File.
  3. Close SAM-BA and reset the board.

Additional Information

Board Names for Configuration

AT91 Bootstrap Loader and U-Boot SAM-BA
at91sam9260ek AT91SAM9260-EK
at91sam9261ek AT91SAM9261-EK
at91sam9263ek AT91SAM9263-EK
at91sam9g10ek AT91SAM9G10-EK
at91sam9g20ek AT91SAM9G20-EK
at91sam9g45ek AT91SAM9G45-EK
at91sam9rlek AT91SAM9RL64-EK
at91cap9adk AT91CAP9-DK-MEM33

Available DataFlash on Atmel Reference Boards

Board Location (PCB Designation) Chip Select
AT91SAM9260-EK External Card (J13) CS0
On board (MN9) CS1
AT91SAM9261-EK On board (MN7) 1 CS0
External Card (J22) 1 CS0
AT91SAM9263-EK External Card (J9) CS0
AT91SAM9G10-EK On board (MN7) 1 CS0
External Card (J22) 1 CS0
External Card (J22) CS3
AT91SAM9G20-EK External Card (J13) CS0
On board (MN9) CS1
AT91SAM9RL64-EK On board (MN8) CS0
AT91CAP9-DK-MEM33 External Card (J28) CS0

1 Both the on-board and external dataflash cards are connected to the same chip select. Only one can be used at a time. Set jumper J21 to 1-2 for chip, and 2-3 for card.

DataFlash Memory Map

The memory map is different depending on the version of U-Boot used.

For U-Boot version 2008.10 and newer, and the AT91CAP9A-DK:

Start Address Size Function
0x0 0x4200 AT91 Bootstrap Loader
0x4200 0x4200 U-Boot Environment
0x8400 0x35a00 U-Boot

For U-Boot versions older than 2008.10, except for the AT91CAP9A-DK:

Start Address Size Function
0x0 0x4000 AT91 Bootstrap Loader
0x4000 0x4000 U-Boot Environment
0x8000 0x30000 U-Boot

NAND Flash Memory Map

For all boards:

Start Address Size Function
0x0 0x4000 AT91 Bootstrap Loader
0x20000 0x40000 U-Boot
0x60000 0x20000 U-Boot Environment
0x80000 0x20000 U-Boot Redundant Environment