This documentation explains how the eCos HAL specification has been
mapped onto the AT91SAM9261-EK hardware, and should be read in conjunction
with that specification. The AT91SAM9261-EK platform HAL package complements
the ARM architectural HAL, the ARM9 variant HAL and the SAM9 processor
HAL. It provides functionality which is specific to the target board.
Startup
Following a hard or soft reset, the HAL will initialize or
reinitialize most of the on-chip peripherals. There is an exception
for RAM startup applications which depend on a ROM monitor for certain
services.
For ROM startup, the HAL will perform additional
initialization. This is all done in the
PLATFORM_SETUP1 macro in the assembler
header file hal_platform_setup.h.
Linker Scripts and Memory Maps
The platform HAL package provides the memory layout information needed
to generate the linker script. The key memory locations are as follows:
SDRAM
This is located at address 0x20000000 of the physical memory
space. The HAL configures the MMU to retain the SDRAM at virtual
address 0x20000000, but in order to assign hardware exception vectors
at address 0x00000000, the HAL also uses the MMU to create a clone
of this memory at virtual address 0x00000000. The same memory is also
accessible uncached and unbuffered at virtual location 0x30000000 for use by
devices. The first 32 bytes are used for hardware exception vectors. The next
32 bytes are used for the VSR table and the next 256 bytes are normally
used for the eCos virtual vectors, allowing RAM-based applications to
use services provided by the ROM monitor. Memory is required for the
MMU tables, and must be aligned on a 16Kbyte boundary. These therefore
occupy memory from 0x4000 to 0x8000. For ROM startup, all
remaining SDRAM is available. For RAM startup, available RAM starts at
virtual location 0x20040000, with the bottom 256kB reserved for use by
RedBoot.
On-chip SRAM
This is located at address 0x00200000 of the physical memory
space. However the HAL uses the MMU to relocate this to virtual
address 0x70000000. The same memory is also accessible uncached and
unbuffered at virtual location 0x70100000 for use by devices. At
present this memory is unused by eCos and is available for application
use.
On-chip ROM
This is located at address 0x00100000 of the physical memory
space. However the HAL uses the MMU to relocate this to virtual
address 0x71000000. The same memory is also accessible uncached and
unbuffered at virtual location 0x71800000.
USB host port
The USB host port (UHP) registers are located at address 0x00300000 of
the physical memory space. However the HAL uses the MMU to relocate this
to virtual address 0x72800000. Memory accessed at this address is
uncached and unbuffered. There is no cached variant.
SPI dataflash
SPI Dataflash media can only be accessed with the Flash API. For the
purposes of this API a placeholder address range has been allocated
as if the Flash is present at this address. The base of this address
range is 0x40000000 for the on-board flash and 0x50000000 for the
dataflash slot, the extent will clearly depend on the
Dataflash capacity. This reserved range is not real memory and
any attempt to access it directly by the processor other than via
the Flash API will result in a memory address exception.
On-chip Peripheral Registers
These are located at address 0xFF000000 in the physical memory
space. When the MMU is enabled, it sets up a direct, uncached,
unbuffered mapping so that these registers remain accessible
at their physical locations.
DM9000 Ethernet Device
This is located on chip select 2 of the static memory controller and
is visible at physical address 0x30000000. The HAL uses the
MMU to relocate this to 0x80000000 in the virtual memory
space.
Off-chip Peripherals
eCos uses the SDRAM,
MCI, and SPI dataflash facilities on the AT91SAM9261-EK board. eCos does
not currently make any use of any other off-chip peripherals present
on this board.
Advanced Interrupt Controller
This port has been designed to exploit benefits of the Advanced Interrupt Controller
of the AT91SAM9261, using the facilities of the SAM9 processor HAL. Consult
the documentation in that package for details.
SPI Dataflash
eCos supports SPI access to Dataflash on the AT91SAM9261. An on-board
device and an external card slot are provided on the board. The
on-chip device is typically used to contain RedBoot and flash configuration
data. The external slot is available for application use.
Accesses to Dataflash are performed via the Flash API, using
0x40000000 or 0x50000000 as the nominal address of the device,
although it does not truly exist in the processor address space. For
the external card slot, on driver initialisation, eCos and RedBoot can
detect the presence of a card in the socket. In particular, on reset
RedBoot will indicate the presence of Flash at the 0x40000000 address
range in its startup banner if it has been successfully detected. Hot
swapping is not possible.
Since Dataflash is not directly addressable, access from RedBoot is only possible
using fis command operations.
RedBoot or applications can also be booted from the Dataflash card socket,
as well as from the on-board Dataflash device.
Booting from the Dataflash card socket can be performed by switching jumper
J21 from pins 1-2 closed, to pins 2-3 closed. When booting RedBoot or
applications in this way, you must enable the SAM9261-EK
platform HAL configuration option "SPI chip select #0 is socket"
(CYGHWR_HAL_ARM_ARM9_SAM9261EK_DATAFLASH_NPCS0_SOCKET)
found within the "External Atmel AT49xxxx DataFlash memory support" component.
Failure to do so will not just render the Dataflash card inaccessible
after booting, but is likely to cause permanent damage to the AT91SAM9261.
Once an appropriately configured "ROM" startup image has been built, it can
be converted to raw binary format using arm-eabi-objcopy.
You must then copy an AT91Bootstrap second stage boot loader binary image to
the beginning (offset 0) of the card, and then the RedBoot/application image
at offset 0x8000 on the card.
Programming on the card can be performed with SAM-BA, an external programmer,
or with a standard build of RedBoot booted from the on-board Dataflash. An
example of using an installed RedBoot loaded from on-board Dataflash to
program the card would be as follows. Note the two Flash memories detected
by RedBoot, as shown in the version output. The first
is the on-board Dataflash part, the second is the Dataflash located in the
card socket.
RedBoot> version
RedBoot(tm) bootstrap and debug environment [ROM]
Non-certified release, version UNKNOWN - built 15:10:18, Nov 2 2007
Platform: SAM9261-EK (ARM9)
Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Copyright (C) 2003, 2004, 2005, 2006, 2007 eCosCentric Limited
RAM: 0x20000000-0x24000000, [0x200305d0-0x23ffef80] available
FLASH: 0x40000000-0x4083ffff, 8192 x 0x420 blocks
FLASH: 0x50000000-0x5083ffff, 8192 x 0x420 blocks
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
(reserved) 0x40000000 0x40000000 0x00008000 0x00000000
RedBoot 0x40008000 0x20030800 0x00028380 0x20030800
RedBoot config 0x4083F7C0 0x4083F7C0 0x00000420 0x00000000
FIS directory 0x4083FBE0 0x4083FBE0 0x00000420 0x00000000
RedBoot> fis load -b %{freememlo} (reserved)
RedBoot> fis write -b %{freememlo} -f 0x50000000 -l 0x8000
* CAUTION * about to program FLASH
at 0x50000000..0x500083ff from 0x20030800 - continue (y/n)? y
... Erase from 0x50000000-0x500083ff: ................................
... Program from 0x20030800-0x20038c00 to 0x50000000: ................................
RedBoot> load -r -m tftp -b %{freememlo} /sam9261ek/redboot.bin
Raw file loaded 0x20030800-0x2004f3a3, assumed entry at 0x20030800
RedBoot> fis write -b %{freememlo} -f 0x50008000 -l 0x28380
* CAUTION * about to program FLASH
at 0x50008000..0x5003037f from 0x20030800 - continue (y/n)? y
... Erase from 0x50007fe0-0x5003037f: ......................................................................................................
... Program from 0x20030800-0x20058b80 to 0x50008000: ......................................................................................
RedBoot>
After this, the board can be powered off, jumper J21 switched to pins 2-3, and
the board powered up again. The application or RedBoot will then boot from the
Dataflash card.
The MCI driver cannot be enabled simultaneously with the SPI driver, as the drivers
need differing pin configurations for the same pins on this board due to the shared
socket.
Real-time characterization
The tm_basic kernel test gives statistics gathered about the real-time
characterization and performance of the kernel. The sample output is shown here
for information. The test was built in ARM mode, which provided better performance
than Thumb mode.
The AT91SAM9261-EK platform HAL does not affect the implementation of other
parts of the eCos HAL specification. The SAM9 processor HAL, ARM9
variant HAL, and the ARM architectural HAL documentation should be consulted
for further details.