eCosPro® Reference Manual
Prev |  | Next

# Setup

## Name

Setup -- Preparing the AT91RM9200-EK and AT91RM9200-DK boards for eCos Development

## Overview

In a typical development environment, the AT91RM9200-EK/DK boards boot from the parallel NOR Flash and run the RedBoot ROM monitor directly. eCos applications are configured for RAM startup and then downloaded and run on the board via the debugger arm-elf-gdb. Preparing the board therefore usually involves programming a suitable RedBoot image into flash memory.

The following RedBoot configurations are supported:

Configuration | Description | Use | File
--- | --- | --- | ---
ROM | RedBoot running from ROM | redboot_ROM.ecm | redboot_ROM.bin
RAM | RedBoot running from RAM | redboot_RAM.ecm | redboot_RAM.bin
ROMRAM | RedBoot running from RAM, but contained in the board's flash boot sector | redboot_ROMRAM.ecm | redboot_ROMRAM.bin
JTAG | RedBoot running from RAM, loaded via JTAG | redboot_JTAG.ecm | redboot_JTAG.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.

The ample provision of RAM memory on the board allows the ROMRAM version of RedBoot to be preferential to the standard ROM version which executes directly from Flash. Alternatively, if the ROM version is to be chosen, then the RAM version is provided to allow for updating the resident RedBoot image in Flash. The JTAG version is only used if loading RedBoot into RAM via a JTAG debugger or ICE. It is similar to the RAM version, but loads at a lower address within RAM, and so can be used to in turn load eCos applications, as if it is the normal resident boot monitor. The ELF format image of this JTAG version of RedBoot can also be loaded and executed from GDB using the Abatron BDI2000 bdiGDB support, to allow it to be debugged.

## Initial Installation

The on-chip boot program on the AT91RM9200 is only capable of loading programs into 12Kbytes of on-chip SRAM and is therefore quite restrictive. Consequently two mechanisms are described below to program RedBoot into Flash. Both of them require a JTAG device. In the following documentation it is assumed that the Abatron BDI2000 is being used. For a different JTAG device, equivalent operations will need to be performed.

### Preparing the Abatron BDI2000 JTAG debugger

The BDI2000 must first be configured to allow communication with your local network, and configured with the parameters for interfacing with the target board. The following steps should be followed:

1. Prepare a PC to act as a host PC and start a TFTP server on it.

2. Connect the Abatron BDI2000 JTAG debugger via both serial and ethernet to the host PC and power it on. Use the serial cable supplied with the BDI2000.

3. Install the Abatron BDI2000 bdiGDB support software on the host PC.

4. Locate the file `bdi2000.at91rm9200ek.cfg` within the eCos platform HAL package in the source repository. This will be in the directory `packages/hal/arm/arm9/atmel-at91rm9200-kits/VERSION/misc` relative to the root of your eCos installation.

5. Locate the file `reg920t.def` within the installation of the BDI2000 bdiGDB support software.

6. Place the bdi2000.at91rm9200ek.cfg in a location on the PC accessible to the TFTP server. Later you will configure the BDI2000 to load this file via TFTP as its configuration file.

7. Similarly place the file `reg920t.def` in a location accessible to the TFTP server.

8. Open `bdi2000.at91rm9200ek.cfg` in an editor such as emacs or notepad and if necessary adjust the path of the `reg920t.def` file in the [REGS] section to match its location relative to the TFTP server root.

9. Install and configure the Abatron BDI2000 in line with the bdiGDB instruction manual. Configure the BDI2000 to use the `bdi2000.at91rm9200ek.cfg` configuration file at the appropriate point of this process.

### Preparing the AT91RM9200-EK/DK board for programming

Follow the steps in this section in order to allow communication between the board and the host PC, and between the board and the JTAG device.

1. First you must connect a null modem DB9 serial cable between the Serial Debug Port on the board and a serial port on the host computer.

2. Start a suitable terminal emulator on the host computer such as minicom or HyperTerminal. Set the communication parameters to 115200 baud, 8 data bits, no parity bit and 1 stop bit with no flow control.

3. Connect the board to your host PC's LAN with an Ethernet cable.

4. You should designate the board with a new Ethernet MAC address. The RedBoot binary image contains a default address, but each board requires its own unique address. It is advisable to mark each board with its programmed MAC address for future identification.

5. Connect the board to the BDI2000 using a 20-pin ARM/Xscale cable from the ICE interface connector to the Target A port on the BDI2000.

6. Locate jumper J15 on the board, which is by default set to INT. It should be reset to EXT. In due course this will ensure that the board boots RedBoot from the external parallel Flash device.

7. Power up the AT91RM9200-EK board. You should see the three ethernet LEDs illuminate.

8. Connect to the BDI2000's CLI interface via TCP/IP on the standard telnet port 23. The telnet application is suitable for this. You should see usage information followed by the prompt:

       Core#0>

9. Confirm correct connection with the BDI2000 with the reset halt command as follows:

       Core#0> reset halt
       - TARGET: processing reset request
       - TARGET: BDI asserts TRST and RESET
       - TARGET: BDI removes TRST
       - TARGET: Bypass check 0x000000001 => 0x00000001
       - TARGET: JTAG exists check passed
       - Core#0: ID code is 0x05B0203F
       - TARGET: All ICEBreaker access checks passed
       - TARGET: BDI removes RESET
       - TARGET: BDI waits for RESET inactive
       - TARGET: resetting target passed
       - TARGET: processing target startup ....
       - TARGET: processing target startup passed
       Core#0>

10. Locate the `redboot_ROMRAM.bin` image within the `loaders` subdirectory of the base of the eCos installation.

11. Copy the `redboot_ROMRAM.bin` file into a location on the host computer accessible to its TFTP server.

### Method 1 - Using the BDI2000 to directly program RedBoot into Flash

As previously mentioned, there are two methods of programming a RedBoot image into the parallel NOR Flash. This method uses the built-in capabilities of the BDI2000.

This is a three stage process. The relevant Flash blocks must first be unlocked, then erased, and finally programmed. This can be accomplished with the following steps:

1. Connect to the BDI2000 telnet port as before.

2. Cut and paste the following commands into the BDI2000 telnet session. They are used to unlock the relevant Flash blocks that will contain RedBoot. The BDI2000 does have an unlock command, however this only works with Intel StrataFLASH and is therefore not suitable.

       mmh 0x1000aaaa 0x00aa
       mmh 0x10000000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x10002000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x10004000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x10006000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x10008000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x1000a000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x1000c000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x1000e000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x10010000 0x0070
       mmh 0x1000aaaa 0x00aa
       mmh 0x10020000 0x0070

3. Erase the 8 initial 8Kbyte sized Flash blocks, and the following 2 64Kbyte Flash blocks with the following commands:

       Core#0>erase 0x10000000 0x2000 8
       Erasing flash at 0x10000000
       Erasing flash at 0x10002000
       Erasing flash at 0x10004000
       Erasing flash at 0x10006000
       Erasing flash at 0x10008000
       Erasing flash at 0x1000a000
       Erasing flash at 0x1000c000
       Erasing flash at 0x1000e000
       Erasing flash passed
       Core#0>erase 0x10010000 0x10000 2
       Erasing flash at 0x10010000
       Erasing flash at 0x10020000
       Erasing flash passed
       Core#0>

4. Program the RedBoot image into Flash with the following command, replacing /RBPATH with the location of the redboot_ROMRAM.bin file relative to the TFTP server root directory:

       Core#0>prog 0x10000000 /RBPATH/redboot_ROMRAM.bin bin
       Programming /RBPATH/redboot_ROMRAM.bin , please wait ....
       Programming flash passed
       Core#0>

   This operation can take some time.

The RedBoot installation is now complete. This can be tested by powering off the board, disconnecting the JTAG, and then powering on the board again. The RedBoot banner should be visible on the serial port. RedBoot's Flash configuration can be initialized using the same procedure as required in Method 2 below.

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.

### Method 2 - Program RedBoot into Flash with RAM RedBoot

With this approach, the BDI2000 is used to load a RAM RedBoot image, which can then in turn be used to load and program a ROMRAM RedBoot image into Flash.

There are three stages, firstly loading the RAM RedBoot image, then initializing RedBoot's Flash configuration, and finally loading and programming the ROMRAM RedBoot.

#### Loading a RAM RedBoot

1. Locate the `redboot_JTAG.bin` image within the `loaders` subdirectory of the base of the eCos installation.

2. Copy the `redboot_JTAG.bin` file into a location on the host computer accessible to its TFTP server.

3. With the BDI2000 telnet interface, execute the following command, replacing /RBPATH with the location of the redboot_JTAG.bin file relative to the TFTP server root directory:

       Core#0>load 0x20008000 /RBPATH/redboot_JTAG.bin bin
       Loading /RBPATH/redboot_JTAG.bin , please wait ....
       Loading program file passed
       Core#0>

4. Run the loaded RAM RedBoot:

       Core#0>go 0x20008000
       Core#0>

The terminal emulator connected to the serial debug port should now have displayed the RedBoot banner and prompt similar to the following:

    +**Warning** FLASH configuration checksum error or invalid key
    Use 'fconfig -i' to [re]initialize database
    PHY: Davicom DM9161A
    AT91RM9200 ETH: Waiting for link to come up.
    AT91RM9200 ETH: 100Mb/Full Duplex
    ... waiting for BOOTP information
    Ethernet eth0: MAC address 00:23:31:37:00:1c
    IP: 192.168.7.190/255.255.255.0, Gateway: 192.168.7.1
    Default server: 192.168.7.11, DNS server IP: 192.168.7.11

    RedBoot(tm) bootstrap and debug environment [RAM]
    eCosCentric certified release, version v2_XX - built 18:51:18, Aug 25 2005

    Platform: Atmel AT91RM9200-EK (ARM9)
    Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Copyright (C) 2003, 2004, 2005 eCosCentric Limited

    RAM: 0x20000000-0x20800000, [0x2002f4e0-0x207ed000] available
    FLASH: 0x60000000 - 0x607fffff 8 x 0x2000 blocks 127 x 0x10000 blocks
    RedBoot>

In the above output, a local BOOTP/DHCP server was able to serve an address to the device.

> Note: It is also possible to use the RAM startup version of RedBoot and the redboot_RAM.bin file instead of redboot_JTAG.bin above. If so, then the address to the load command must be 0x20040000, as must be the address to the go command.

#### RedBoot Flash configuration

The following steps describe how to initialize RedBoot's Flash configuration. This must be performed when using a RAM RedBoot to program Flash, but is also applicable to initial configuration of a ROMRAM RedBoot loaded using Method 1.

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

       RedBoot> fis init -f
       About to initialize [format] FLASH image system - continue (y/n)? y
       *** Initialize FLASH Image System
       ... Erase from 0x60030000-0x607effff: ......................................................................................
       ... Unlocking from 0x607f0000-0x607fffff: .
       ... Erase from 0x607f0000-0x607fffff: .
       ... Program from 0x207f0000-0x20800000 to 0x607f0000: .
       ... Locking from 0x607f0000-0x607fffff: .
       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 server IP address: 192.168.7.11
       Network hardware address [MAC]: 0x00:0x23:0x31:0x37:0x00:0x4e
       GDB connection port: 9000
       Force console for special debug messages: false
       Network debug at boot time: false
       Default network device: at91rm9200_eth
       Update RedBoot non-volatile configuration - continue (y/n)? y
       ... Unlocking from 0x607f0000-0x607fffff: .
       ... Erase from 0x607f0000-0x607fffff: .
       ... Program from 0x207f0000-0x20800000 to 0x607f0000: .
       ... Locking from 0x607f0000-0x607fffff: .
       RedBoot>

#### Loading and programming the ROMRAM RedBoot

This section describes the steps required to load the ROMRAM RedBoot from the TFTP server and program it into Flash.

1. Load the RedBoot ROMRAM binary image from the TFTP server. Use the following command, replacing 111.222.333.444 with the TFTP server IP address (or domain name if a DNS server has been configured), and /RBPATH with the location of the `redboot_ROMRAM.bin` file relative to the TFTP server root directory:

       RedBoot> load -r -b %{freememlo} -h 111.222.333.444 /RBPATH/redboot_ROMRAM.bin
       Using default protocol (TFTP)
       Raw file loaded 0x2002f800-0x2004e367, assumed entry at 0x2002f800
       RedBoot>

2. Finally install the loaded image into Flash:

       RedBoot> fis create RedBoot
       An image named 'RedBoot' exists - continue (y/n)? y
       ... Unlocking from 0x60000000-0x6002ffff: ..........
       ... Erase from 0x60000000-0x6002ffff: ..........
       ... Program from 0x0002f800-0x0004e368 to 0x60000000: .........
       ... Locking from 0x60000000-0x6002ffff: ..........
       ... Unlocking from 0x607f0000-0x607fffff: .
       ... Erase from 0x607f0000-0x607fffff: .
       ... Program from 0x007f0000-0x00800000 to 0x607f0000: .
       ... Locking from 0x607f0000-0x607fffff: .
       RedBoot>

   It is also possible to use the fis write command to write the image into Flash, but if so, the relevant Flash blocks must also be explicitly unlocked with the command:

       RedBoot> fis unlock -f 0x60000000 -l 0x30000

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

    +PHY: Davicom DM9161A
    AT91RM9200 ETH: Waiting for link to come up.
    AT91RM9200 ETH: 100Mb/Full Duplex
    Ethernet eth0: MAC address 00:23:31:37:00:3d
    IP: 192.168.7.222/255.255.255.0, Gateway: 192.168.7.1
    Default server: 192.168.7.9, DNS server IP: 192.168.7.11

    RedBoot(tm) bootstrap and debug environment [ROMRAM]
    eCosCentric certified release, version v2_XX - built 18:55:20, Aug 25 2005

    Platform: Atmel AT91RM9200-EK (ARM9)
    Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Copyright (C) 2003, 2004, 2005 eCosCentric Limited

    RAM: 0x20000000-0x20800000, [0x20030470-0x207ed000] available
    FLASH: 0x60000000 - 0x607fffff 8 x 0x2000 blocks 127 x 0x10000 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 ROMRAM version of RedBoot for the AT91RM9200-EK are:

    $ mkdir redboot_at91rm9200ek_romram
    $ cd redboot_at91rm9200ek_romram
    $ ecosconfig new at91rm9200ek redboot
    $ ecosconfig import $ECOS_REPOSITORY/hal/arm/arm9/atmel-at91rm9200-kits/VERSION/misc/redboot_ROMRAM.ecm
    $ ecosconfig resolve
    $ ecosconfig tree
    $ make

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

The other versions of RedBoot - ROM, RAM or JTAG - may be similarly built by choosing the appropriate alternative .ecm file.

Prev | Home | Next
Overview | Up | Configuration