How to Boot from DataFlash on the Atmel SAM9 Boards

Building the Bootloader Images

If you do not have binary versions of the bootloaders, you must build them from source. See the following documents for more information:

Building AT91 Bootstrap and U-Boot for CS0 on SAM9260/9G20

By default, the AT91SAM9260 and AT91SAM9G20 bootloaders are configured to boot from the Dataflash Chip connected to CS1. It is possible to boot from the Dataflash Card connected to CS0 with a few minor modifications. If you have built either bootloader before, you must run make clean before rebuilding, or these changes will not take effect.

  1. Before building AT91 Bootstrap, modify the AT91C_SPI_PCS_DATAFLASH definition in the file at91bootstrap-<version>/board/<board name>/dataflash/<board name>.h to:
    #define AT91C_SPI_PCS_DATAFLASH         AT91C_SPI_PCS0_DATAFLASH 
    
  2. If using version 2008.10 or newer, before building U-Boot, modify the file include/configs/<board name>.h as follows:
    #define CFG_USE_DATAFLASH_CS0           1
    #undef CFG_USE_DATAFLASH_CS1
    #undef CFG_USE_NANDFLASH
    
  3. In older versions of U-Boot, modify the CFG_ENV_ADDR definition in the file include/configs/<board name>.h as follows:
    #define CFG_ENV_ADDR                    (CFG_DATAFLASH_LOGIC_ADDR_CS0 + CFG_ENV_OFFSET)
    

Writing Bootloaders to DataFlash

Writing Kernel to DataFlash

  1. Start up SAM-BA, if it is not already open.
  2. Burn U-Boot to NAND Flash
    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.
    4. Click the Browse button next to Send File Name under the Download/Upload File section. Navigate to your uImage file and click Open.
    5. Set the Address box to the address that you wish to store the kernel. It should not overlap U-Boot, and also lie on a block boundary (a multiple of 0x4200). 0x42000 is typically a good value to use.
    6. Click Send File
  3. If you are not writing an RFS to flash, close SAM-BA and reset the board. Otherwise, you may leave it open.

Writing RFS to DataFlash

Since the maximum size of a DataFlash chip is only 8 MB, you will typically need to store your RFS on a different chip or disk. See the document HOWTO Boot from NAND Flash on the Atmel SAM9 Boards for information about burning an RFS to NAND flash.

Boot Procedure

In order to boot from NAND, you must load the kernel from NAND into memory, and then tell the kernel where to look for the RFS, and how to load it.

  1. Copy the kernel into RAM using the nand read command:
    U-Boot> cp.b <src> <dest> <size>

    This command will read <size> bytes from address <src> and move it to <dest> in RAM. <size> should be greater than or equal to the size of the kernel. <src> should be the start of the kernel partition in DataFlash, the same value used in the section Writing Kernel to DataFlash above. <dest> should be some location in RAM. The values 0x22000000 or 0x21400000 have been tested and work.
  2. Set the kernel command line to boot from the desired area:
    To boot over NFS with a DHCP server running:
    U-Boot> setenv bootargs console=ttyS0,115200 ip=dhcp root=/dev/nfs rw

    To boot with JFFS2 RFS in flash:
    U-Boot> setenv bootargs console=ttyS0,115200 rootfstype=jffs2 root=/dev/mtdblockN rw

    You should substitute the proper MTD device number for N in the root parameter above. See the UBIFS doc for information about how to use UBI.
  3. Boot the kernel using the bootm command.
    U-Boot> bootm <address>

    <address> is the same address that was used in the cp command above.