Name

Setup — Preparing the AT91SAM9263-EK board for eCos Development

Overview

In a typical development environment, the AT91SAM9263-EK board boots from a 4MiB DataFlash card and run the RedBoot ROM monitor from SDRAM. eCos applications are configured for RAM startup and then downloaded and run on the board via the debugger arm-eabi-gdb. Preparing the board therefore usually involves programming a suitable RedBoot image into flash memory.

The following RedBoot configurations are supported:

ConfigurationDescriptionUseFile
ROMRedBoot loaded from 4MiB Dataflash to SDRAMredboot_ROM.ecmredboot_ROM.bin

For serial communications, all versions run with 8 bits, no parity, and 1 stop bit at 115200 baud. RedBoot also supports ethernet communication and flash management.

Note that the use of the term ROM for the initial RedBoot configuration is an historical accident. RedBoot actually runs from SDRAM after being loaded there from Dataflash by the second-level bootstrap. The use of ROM for this configuration is intended to indicate that it initializes the microprocessor and board peripherals, as opposed to the RAM configuration which assumes that this has already been done.

Initial Installation

The on-chip boot program on the AT91SAM9263 is only capable of loading programs from DataFlash, SD card or NAND flash into on-chip SRAM and is therefore quite restrictive. Consequently RedBoot cannot be booted directly and a second-level bootstrap must be used. Such a second-level bootstrap is supplied by Atmel in the form of AT91Bootstrap. This is therefore programmed into the start of Dataflash and is then responsible for initializing the SDRAM and loading RedBoot from Dataflash and executing it.

[Caution]Caution

There is a size limit on the size of applications which the AT91Bootstrap second level bootstrap will load. Images larger than 320Kbytes will require the AT91Bootstrap application to be rebuilt with a larger IMG_SIZE definition in AT91Bootstrap/board/at91sam9263ek/dataflash/at91sam9263ek.h within the sam9260ek HAL package in the eCos source repository (packages/hal/arm/arm9/sam9260ek/current/).

There are basically two ways to write the second-level bootstrap and RedBoot to the Dataflash. The first is to use the Atmel-supplied SAM-BA program that interacts with the on-chip boot program. The second is to use a JTAG debugger that understands the microcontroller and can write to the dataflash (for example the Ronetix PEEDI). Since the availability of the latter cannot be guaranteed, only the first method will be described here.

Programming RedBoot into DataFlash using SAM-BA

The following gives the steps needed to program the second-level bootstrap and RedBoot into the DataFlash card using SAM-BA. The user should refer to the SAM-BA documentation for full details of how to run the program.

  1. Download the AT91 In-system Programmer software package from the Atmel website. SAM9 series CPU's require the 2.1.x series version of SAM-BA. Install it on a suitable PC running Windows.
  2. From the root directory of your eCosPro installation, copy the file dataflash_at91sam9263ek.bin from the sub-directory packages/hal/arm/arm9/sam9260ek/current/AT91Bootstrap/board/at91sam9263ek and redboot_ROM.bin from the sub-directory loaders/sam9263ek to a suitable location on the Windows PC.
  3. Connect a null-modem serial cable between the DEBUG serial port of the board and a serial port on a convenient host (which need not be the PC running SAM-BA). Run a terminal emulator (Hyperterm or minicom) at 115200 baud. Connect a USB cable between the PC and the AT91SAM9263-EK board. Windows may ask you to install a new driver, in which case follow the instructions.
  4. Power up the board without the DataFlash card inserted. This will force the bootstrap to enter ISP mode.
  5. Start SAM-BA. Select "\usb\ARM0" for the communication interface, and "AT91SAM9263-EK" for the board. If the USB option does not appear, check the cable and look in the Windows Device Manager for the new USB COM device. If all is well, click on "Connect".
  6. In the SAM-BA main window, select the "SDRAM" tab, select the "Enable SDRAM 100MHz" script from the dropdown menu and click Execute. SAM-BA should emit the following messages:

    (AT91-ISP v1.10) 34 % SDRAM::initSDRAM_100
    -I- Configure PIOD as peripheral (D16/D31)
    -I- Init MATRIX to support EBI0 CS1 for SDRAM
    -I- Init SDRAM
    -I- 1. A minimum pause of 200us is provided to precede any signal toggle
    -I- 2. A Precharge All command is issued to the SDRAM
    -I- *pSDRAM = 0;
    -I- 3. Eight Auto-refresh are provided
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- *pSDRAM = 0;
    -I- 4. A mode register cycle is issued to program the SDRAM parameters
    -I- *(pSDRAM+0x20) = 0;
    -I- 5. Write refresh rate into SDRAMC refresh timer COUNT register
    -I- 6. A Normal Mode Command is provided, 3 clocks after tMRD is set
    -I- *pSDRAM = 0;
    -I- End of Init_SDRAM_100
    (AT91-ISP v1.10) 34 %
  7. Now insert the DataFlash card into the socket at J9. In the SAM-BA main window, select the "DataFlash AT45DB/DBC" tab and in the "Scripts" dropdown menu select "Enable Dataflash (SPI0 CS0)", to program the Dataflash card. Click Execute and SAM-BA should emit the following in the message area:

    (AT91-ISP v1.13) 1 % DATAFLASH::Init 0
    -I- DATAFLASH::Init 0 (trace level : 4)
    -I- Loading applet isp-dataflash-at91sam9263.bin at address 0x20000000
    -I- Memory Size : 0x840000 bytes
    -I- Buffer address : 0x20002A40
    -I- Buffer size: 0x80E80 bytes
    -I- Applet initialization done

    The actual options and output of SAM-BA may vary according to the version you are using. The behaviour documented here is that of SAM-BA 2.9.

  8. Select "Send BootFile" from the "Scripts" menu and "Execute" it. When the file open dialog appears, select the dataflash_at91sam9263ek.bin file and click "Open". The following output should be seen:

    (AT91-ISP v1.13) 1 % GENERIC::SendBootFileGUI
    GENERIC::SendFile dataflash_at91sam9263ek.bin at address 0x0
    -I- File size : 0x106E byte(s)
    -I-     Writing: 0x106E bytes at 0x0 (buffer addr : 0x20002A40)
    -I-     0x106E bytes written by applet
  9. The second-level bootstrap has now been written to DataFlash, we must now write RedBoot.
  10. In the "Send File Name" box type in the path name to the redboot_ROM.bin file, or use the Open Folder button and browse to it.
  11. In the Address field set the value to 0x8400.
  12. Click the "Send File" button. SAM-BA will put up a dialog box while it is writing the file to the DataFlash, and will output something similar to the following in the message area:

    (AT91-ISP v1.13) 1 % send_file {DataFlash AT45DB/DCB} "redboot_ROM.bin" 0x8400 0
    -I- Send File //bert/Shared/Releng/sam9263ek/redboot_ROM.bin at address 0x8400
    GENERIC::SendFile //bert/Shared/Releng/sam9263ek/redboot_ROM.bin at address 0x8400
    -I- File size : 0x24290 byte(s)
    -I-     Writing: 0x24290 bytes at 0x8400 (buffer addr : 0x20002A40)
    -I-     0x24290 bytes written by applet
  13. Shut down SAM-BA and disconnect the USB cable. Press the reset button on the board and something similar to the following should be output on the DEBUG serial line.

    RomBOOT
    >Start AT91Bootstrap...
    +**Warning** FLASH configuration checksum error or invalid key
    Use 'fconfig -i' to [re]initialize database
    No space to add 'net_device'
    AT91_ETH: Waiting for PHY to reset.
    AT91_ETH: Waiting for link to come up..
    No network interfaces found
    
    RedBoot(tm) bootstrap and debug environment [ROM]
    eCosCentric certified release, version v3_0_3 - built 12:56:09, Sep 24 2009
    
    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 eCosCentric Limited
    RedBoot is free software, covered by the eCos license, derived from the
    GNU General Public License. You are welcome to change it and/or distribute
    copies of it under certain conditions. Under the license terms, RedBoot's
    source code and full license terms must have been made available to you.
    Redboot comes with ABSOLUTELY NO WARRANTY.
    
    Platform: AT91SAM9263-EK (ARM9)
    RAM: 0x20000000-0x24000000 [0x20035ba8-0x23fff5b0 available]
    FLASH: 0x40000000-0x4083ffff, 8192 x 0x420 blocks
    RedBoot>

RedBoot Flash configuration

The following steps describe how to initialize RedBoot's Flash configuration.

  1. Use the following command to initialize RedBoot's Flash Information System (FIS):

    RedBoot> fis init
    About to initialize [format] FLASH image system - continue (y/n)? y
    *** Initialize FLASH Image System
    ... Erase from 0x4083fbe0-0x4083ffff: .
    ... Program from 0x23fffbe0-0x24000000 to 0x4083fbe0: .
    RedBoot>
  2. Now configure RedBoot's Flash configuration with the command:

    RedBoot> fconfig -i

    Remember to substitute the appropriate MAC address for this board at the appropriate step. If a BOOTP/DHCP server is not available, then IP configuration may be set manually. The default server IP address can be set to a PC that will act as a TFTP host for future RedBoot load operations, or may be left unset. The following gives an example configuration:

    RedBoot> fconfig -i
    Initialize non-volatile configuration - continue (y/n)? y
    Run script at boot: false
    Use BOOTP for network configuration: false
    Gateway IP address: 192.168.7.11
    Local IP address: 192.168.7.222
    Local IP address mask: 255.255.255.0
    Default server IP address: 192.168.7.9
    Console baud rate: 115200
    DNS domain name: ecoscentric.com
    DNS server IP address: 192.168.7.11
    Network hardware address [MAC]: 0x00:0x23:0x31:0x37:0x00:0x4e
    Update RedBoot non-volatile configuration - continue (y/n)? y
    ... Erase from 0x4083f7c0-0x4083fbdf: .
    ... Program from 0x23fff7c0-0x23fffbe0 to 0x4083f7c0: .
    RedBoot>

The RedBoot installation is now complete. This can be tested by powering off the board, and then powering on the board again. Output similar to the following should be seen on the DEBUG serial port. Verify the IP settings are as expected.

RomBOOT
>Start AT91Bootstrap...
Ethernet eth0: MAC address 0e:00:00:ea:18:f0
IP: 192.168.7.222/255.255.255.0, Gateway: 192.168.7.11
Default server: 192.168.7.11
DNS server IP: 192.168.7.11, DNS domain name: <null>

RedBoot(tm) bootstrap and debug environment [ROM]
eCosCentric certified release, version v3_0_3 - built 12:56:09, Sep 24 2009

Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 eCosCentric Limited
RedBoot is free software, covered by the eCos license, derived from the
GNU General Public License. You are welcome to change it and/or distribute
copies of it under certain conditions. Under the license terms, RedBoot's
source code and full license terms must have been made available to you.
Redboot comes with ABSOLUTELY NO WARRANTY.

Platform: AT91SAM9263-EK (ARM9)
RAM: 0x20000000-0x24000000 [0x20035ba8-0x23fff5b0 available]
FLASH: 0x40000000-0x4083ffff, 8192 x 0x420 blocks
RedBoot>

If it proves necessary to re-install RedBoot, this may be achieved by repeating the above process. Alternatively, a new image may be downloaded and programmed into flash more directly using RedBoot's own commands. See the RedBoot documentation for details.

Rebuilding RedBoot

Should it prove necessary to rebuild a RedBoot binary, this is done most conveniently at the command line. The steps needed to rebuild the ROM version of RedBoot for the AT91SAM9263-EK are:

$ mkdir redboot_at91sam9263ek_rom
$ cd redboot_at91sam9263ek_rom
$ ecosconfig new at91sam9263ek redboot
$ ecosconfig import $ECOS_REPOSITORY/hal/arm/arm9/sam9263ek/current/misc/redboot_ROM.ecm
$ ecosconfig resolve
$ ecosconfig tree
$ make

At the end of the build the install/bin subdirectory should contain the file redboot.bin.

Rebuilding AT91Bootstrap

The sources of AT91Bootstrap are found in the AT91Bootstrap directory of the sam9260ek package. This is a copy of the software as supplied by Atmel with some slight modifications to permit it to be built with the same tools as eCos.

To rebuild the second-level bootstrap for the AT91SAM9263EK execute the following commands:

$ cd $ECOS_REPOSITORY/hal/arm/arm9/sam9260ek/current/AT91Bootstrap/board/at91sam9263ek/dataflash
$ make

This should result in the creation of a number of files, including dataflash_at91sam9263ek.bin which can be copied out.