Setup -- Preparing the AT91SAM9261-EK board for eCos Development
Overview
In a typical development environment, the AT91SAM9261-EK board boots from
the DataFlash 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:
Configuration
Description
Use
File
ROM
RedBoot loaded from Dataflash to SDRAM
redboot_ROM.ecm
redboot_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 AT91SAM9261 is only capable of loading
programs from Dataflash 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
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/at91sam9261ek/dataflash/at91sam9261ek.h
within the sam9260ek HAL package in the eCos source repository
(packages/hal/arm/arm9/sam9260ek/VERSION/).
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 using SAM-BA. The user
should refer to the SAM-BA documentation for full details of how to
run the program.
Download the AT91 In-system Programmer software
package from the Atmel website. Install it on a suitable PC running
Windows XP.
Copy dataflash_at91sam9261ek.bin and
redboot_ROM.bin to a suitable location on the
Windows PC.
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 AT91SAM9261-EK
board.
Power up or reset the board and Windows should recognize the USB
device. If it does not, then move J21 to the 2-3 position and reset
the board, it should be recognized now. Windows may ask you to
install a new driver, in which case follow the instructions.
Start SAM-BA. Select "\usb\ARM0" for the communication interface, and
"AT91SAM9261-EK" for the board. If the USB option does not appear,
check the cable and look in the Windows Device Manager for the active
device. If all is well, click on "Connect".
If you moved J21 to 2-3, move it back to the default 1-2 position.
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 on-board Dataflash device. Click Execute and SAM-BA should
emit the following in the message area:
Select "Send BootFile" from the
"Scripts" menu and "Execute" it. When the file open dialog appears,
select the dataflash_at91sam9261ek.bin file and
click "Open". The following output should be seen:
(AT91-ISP v1.13) 1 % GENERIC::SendBootFileGUI
GENERIC::SendFile dataflash_at91sam9261ek.bin at address 0x0
-I- File size : 0x10A2 byte(s)
-I- Writing: 0x10A2 bytes at 0x0 (buffer addr : 0x20002A40)
-I- 0x10A2 bytes written by applet
The second-level bootstrap has now been written to DataFlash, we must
now write RedBoot.
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.
In the Address field set the value to 0x8400.
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/sam9261ek/redboot_ROM.bin at address 0x8400
GENERIC::SendFile //bert/Shared/Releng/sam9261ek/redboot_ROM.bin at address 0x8400
-I- File size : 0x1F928 byte(s)
-I- Writing: 0x1F928 bytes at 0x8400 (buffer addr : 0x20002A40)
-I- 0x1F928 bytes written by applet
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
>Start AT91Bootstrap...
No network interfaces found
RedBoot(tm) bootstrap and debug environment [ROM]
eCosCentric certified release, version v3_0_3 - built 12:53: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: SAM9261-EK (ARM9)
RAM: 0x20000000-0x24000000 [0x20031230-0x23ffef80 available]
FLASH: 0x40000000-0x4083ffff, 8192 x 0x420 blocks
RedBoot>
RedBoot Flash configuration
The following steps describe how to initialize RedBoot's Flash configuration.
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> fis list
Name FLASH addr Mem addr Length Entry point
(reserved) 0x40000000 0x40000000 0x00008000 0x00000000
RedBoot 0x40008000 0x40008000 0x00028380 0x00000000
RedBoot config 0x4083F7C0 0x4083F7C0 0x00000420 0x00000000
FIS directory 0x4083FBE0 0x4083FBE0 0x00000420 0x00000000
RedBoot>
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
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 00:03:47:df:32:a8
IP: 192.168.7.85/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%gt;
RedBoot(tm) bootstrap and debug environment [ROM]
eCosCentric certified release, version v3_0_3 - built 12:53: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: SAM9261-EK (ARM9)
RAM: 0x20000000-0x24000000 [0x20031230-0x23ffef80 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 AT91SAM9261-EK are:
$ mkdir redboot_at91sam9261ek_rom
$ cd redboot_at91sam9261ek_rom
$ ecosconfig new at91sam9261ek redboot
$ ecosconfig import $ECOS_REPOSITORY/hal/arm/arm9/sam9261ek/VERSION/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 AT91SAM9261EK execute
the following commands:
$ cd $ECOS_REPOSITORY/hal/arm/arm9/sam9260ek/VERSION/AT91Bootstrap/board/at91sam9261ek/dataflash
$ make
This should result in the creation of a number of files, including
dataflash_at91sam9261ek.bin which can be copied out.