Setup -- Preparing the AT91SAM9G45-EKES board for eCos Development
Overview
In a typical development environment, the AT91SAM9G45-EKES board
boots from the NAND flash and runs 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 NAND 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 a historical accident. RedBoot actually runs from
SDRAM after being loaded there from NAND 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 AT91SAM9G45 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 NAND
and is then responsible for initializing the SDRAM and loading
RedBoot from NAND 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/at91sam9g45ek/nandflash/at91sam9g45ek.h
within the sam9g45ek 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 NAND. 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. SAM-BA can communicate with the boot program
via either USB or serial. The steps are essentially similar for
both since USB operates through a driver that simulates a serial
port.
Download the AT91 SAM-BA software package from the Atmel
website and install it. Atmel provide both Linux and Windows
versions of SAM-BA so ensure you select the version appropriate
to your host operating system. The remainder of this document
describes the process according to a Windows installation.
The steps for the Linux version of SAM-BA are similar and can
easily be determined from the Windows process.
Copy nandflash_at91sam9g45ekes.bin and
redboot_ROM.bin to a suitable location on
the PC.
Connect a null-modem serial cable between the J10 DEBUG serial
port of the board and a serial port on the host running
SAM-BA. If using USB download also connect a USB cable between
the host and the J14 HOST/DEV socket.
Unplug the power supply from the board and remove JP10(NANDCS)
and JP12(NPCS0). Reapply power to the board. If USB is being
used follow the instructions in the SAM-BA documentation to set
up the Windows device driver for the first time if you are running
a Microsoft Windows-based operating system.
Start SAM-BA. Select the appropriate COM port for the
communication interface (on Windows hosts this will be of
the form "COMx" and on Linux hosts this will be of the form
"/dev/ttyUSBx"), and "at91sam9g45-ekes" for the board.
Click on "Connect".
Re-insert JP10 and JP12.
In the SAM-BA main window, select the "NandFlash" tab and in
the "Scripts" dropdown menu select "Enable NandFlash", to
program the on-board NandFlash device. Click Execute and SAM-BA
should emit the following in the message area:
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.10.
Now select "Send BootFile" from the "Scripts" menu and
"Execute" it. When the file open dialog appears, select the
nandflash_at91sam9g45ekes.bin file and click
"Open". The following output should be seen:
(SAM-BA v2.10) 1 % GENERIC::SendBootFileGUI
GENERIC::SendFile Z:/eCos/SAM-BA/nandflash_at91sam9g45ekes.bin at address 0x0
-I- File size : 0x1334 byte(s)
-I- Writing: 0x1334 bytes at 0x0 (buffer addr : 0x70003E34)
-I- 0x1334 bytes written by applet
(SAM-BA v2.10) 1 %
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 0x020000.
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:
(SAM-BA v2.10) 1 % send_file {NandFlash} "Z:/eCos/SAM-BA/redboot_ROM.bin" 0x020000 0
-I- Send File Z:/eCos/SAM-BA/redboot_ROM.bin at address 0x020000
GENERIC::SendFile Z:/eCos/SAM-BA/redboot_ROM.bin at address 0x20000
-I- File size : 0x24658 byte(s)
-I- Writing: 0x20000 bytes at 0x20000 (buffer addr : 0x70003E34)
-I- 0x20000 bytes written by applet
-I- Writing: 0x4658 bytes at 0x40000 (buffer addr : 0x70003E34)
-I- 0x4658 bytes written by applet
(SAM-BA v2.10) 1 %
Shut down SAM-BA and start up Hyperterm or similar on the real
COM port, not the USB port, configured for 115200 baud 8-N-1
with no flow control. Attach an ethernet cable between the
board and a switch on your network. Press the reset button on
the board and something similar to the following should be
output on the DEBUG serial line.
Start AT91Bootstrap...
+**Warning** FLASH configuration checksum error or invalid key
Use 'fconfig -i' to [re]initialize database
Ethernet eth0: MAC address 0e:00:00:ea:18:f0
IP: 10.0.2.1/255.0.0.0, Gateway: 10.0.0.3
Default server: 0.0.0.0
DNS server IP: 10.0.0.1, DNS domain name: <null>
RedBoot(tm) bootstrap and debug environment [ROM]
Non-certified release, version UNKNOWN - built 14:54:15, Aug 20 2010
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: AT91SAM9G45-EK (ARM9)
RAM: 0x20000000-0x28000000 [0x20035f78-0x27ffe530 available]
FLASH: 0x50000000-0x5041ffff, 8192 x 0x210 blocks
RedBoot>
The board is now running and the flash can be configured.
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 0x5041fdf0-0x5041ffff: .
... Program from 0x27fffdf0-0x28000000 to 0x5041fdf0: .
RedBoot>
Now configure RedBoot's Flash configuration with the
fconfig command. 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.83
Local IP address mask: 255.255.255.0
Default server IP address: 192.168.7.11
Console baud rate: 115200
DNS domain name: farm.ecoscentric.com
DNS server IP address: 192.168.7.11
Network hardware address [MAC]: 0x0E:0x00:0x00:0xEA:0x18:0xF0
GDB connection port: 9000
Force console for special debug messages: false
Update RedBoot non-volatile configuration - continue (y/n)? y
... Erase from 0x5041ef80-0x5041f7bf: ....
... Program from 0x27fff5b0-0x27fffdf0 to 0x5041ef80: ....
RedBoot>
The RedBoot installation is now complete. This can be tested by
power cycling the board. Output similar to the following should
be seen on the DEBUG serial port. Verify the IP settings are as
expected.
Ethernet eth0: MAC address 0e:00:00:ea:18:f0
IP: 192.168.7.83/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]
Non-certified release, version UNKNOWN - built 14:54:15, Aug 20 2010
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: AT91SAM9G45-EK (ARM9)
RAM: 0x20000000-0x28000000 [0x20035f78-0x27ffe530 available]
FLASH: 0x50000000-0x5041ffff, 8192 x 0x210 blocks
RedBoot>
If it proves necessary to re-install RedBoot, this may be
achieved by repeating the above process.
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 AT91SAM9G45-EKES are:
$ mkdir redboot_at91sam9g45ek_rom
$ cd redboot_at91sam9g45ek_rom
$ ecosconfig new at91sam9g45ek redboot
$ ecosconfig import $ECOS_REPOSITORY/hal/arm/arm9/sam9g45ek/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 AT91SAM9G45-EKES execute
the following commands:
$ cd $ECOS_REPOSITORY/hal/arm/arm9/sam9260ek/VERSION/AT91Bootstrap/board/at91sam9g45ekes/nandflash
$ make
This should result in the creation of a number of files, including
dataflash_at91sam9g45ekes.bin which can be
copied out.