Sie sind auf Seite 1von 16

Getting Started with the AT91SAM7X

A guide for using open source tools with the AT91SAM7X-EK development board.

V 1.0
Semester 2, 2009
Stephen Rothery
stevekr@gmail.com

Table of Contents
Introduction ................................................................................................................................................ 1
Hardware Requirements .............................................................................................................................. 1
Software Required ....................................................................................................................................... 1
Base Installation....................................................................................................................................... 1
FreeRTOS Tools ........................................................................................................................................ 2
General Tools........................................................................................................................................... 2
Installation................................................................................................................................................... 2
Compiling and running your first application ................................................................................................ 3
Copying image to device without SAM-ICE (Via USB) ............................................................................ 5
Copying image to device using the SAM-ICE JTAG programmer/debugger ........................................... 7
Using the Debugger ..................................................................................................................................... 9
Configuration ..........................................................................................................................................10
Switching to Debug View ........................................................................................................................11
Flash Based Debugging............................................................................................................................11
Ram Based Debugging.............................................................................................................................12
Basic Debugger Functionality ..................................................................................................................12
Configuring and running the FreeRTOS Demo .............................................................................................13
Configuring the Local Webserver ................................................................................................................14
Running the FreeRTOS demo ......................................................................................................................14

Introduction
The purpose of this guide is to help a user get started with development for AT91Sam7x256, while making
use of freely available open source software. Example applications and comprehensive documentation
have also been included in this package to assist with developing applications for this platform.
The software included in this package has been pre-assembled from various sources; James P. Lynch has
created an excellent (though slightly dated) guide for this which, along with documentation from the
YAGARTO web site forms formed the initial basis for much of this process.
This configuration has been tested to work on both Windows XP and Vista operating systems and should
also function correctly on Windows 2000, though this has not been tested.

Hardware Requirements
This guide was written for the following hardware.
Item
Processor
Development Board
JTAG Interface

Required
Atmel AT91SAM7X256
Atmel AT91SAM7X-EK
Atmel Sam-Ice (Atmel Branded J-Link device)

If you are using anything other than these devices you may be required to change certain elements of this
guide. Changes to the JTAG interface will require adjusting the process for programming and debugging the
board, while changes to the Processor and development board will require changes in the software based
on the different hardware and peripherals present.

Software Required
All of the software mentioned in this guide is included in this package, with several components being preinstalled and preconfigured. This is covered in the Installation guide, but below is a list of the software used,
as well as links to where they can be obtained.

Base Installation

Sun Java 2 Standard Edition 5.0 Update 11 for Microsoft Windows (or above)1
Eclipse IDE for C/C++ with the following Plugins2
o Zylin Embedded Toolkit for Eclipse3
YAGARTO (GNU ARM toolchain)4
YAGARTO Tools5
AT91 In-system Programmer (ISP)6
SEGGER - J-Link ARM7

http://www.java.com/en/download/index.jsp
http://www.eclipse.org/downloads/packages/release/europa/winter
3
http://opensource.zylin.com/embeddedcdt.html
4
http://www.yagarto.de/index.html#download
5
http://www.yagarto.de/index.html#download
6
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3883
7
http://www.segger.com/cms/jlink-software.html
2

FreeRTOS Tools

ActivePerl8
Abyss Web Server X19
GNU Wget10

General Tools

Wireshark11

Installation
1. Run the file AT91SAM7X-Dev.exe and select where you would like it to be extracted. This will be
the working folder for this development package and will require approximately 800MB of hard
drive space.

2. Once done, a number of tools need to be installed. Open the folder that you extracted everything
into in the previous step and open Software folder within it. The essential software must first be
installed, this is found in the Base subfolder.
These tools can be installed in any order, but are all required.
a. Install Java
Run the Java installer (jre-6u13-windows-i586-p-s.exe), all options can be left as their
default.
b. Install YAGARTO and YAGARTO tools
Run the installers for the Yagarto Tools. (yagarto-bu-2.19.1_gcc-4.3.3-c-c++_nl-1.17.0_gi6.8.50_20090329.exe and yagarto-tools-20070303-setup.exe) The default options are
sufficient but ensure that the option Add YAGARTO to the PATH variable is checked for
the installation of YAGARTO, and that Add the make utils to the path variable is selected
for the installation of YAGARTO tools.
c. Install Atmel AT91 In-system Programmer tools (Install AT91-ISP v1.12.exe) with the default
options. (this requires a reboot to complete)
d. Install J-Link arm Driver (Setup_JLinkARM_V402e.exe) and install with default options.
Once this has been done, you can connect the SAM-ICE USB JTAG device and Windows
should recognise it correctly.

http://www.activestate.com/activeperl/
http://www.aprelium.com/abyssws/download.php
10
http://www.gnu.org/software/wget/
11
http://www.wireshark.org/
9

The following tools are required for working with the FreeRTOS example
e. ActivePerl (ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi) This can be installed with
default options. This tools allows the running of scripts which allow web pages to be
converted into a format usable by the FreeRTOS demo.
The following tools are helpful for additional network debugging and trouble shooting
f. Wireshark (wireshark-setup-1.0.6.exe) can be installed with default options. This installer
will also guide you through installing a tool called WinPcap which is required for
Wireshark to function.

Compiling and running your first application


1. To start Eclipse, run eclipse.exe, found in the eclipse subfolder of the package. The first time you
run this program, you will be prompted to select a workspace.

Select the Workspace subfolder which is part of the package and select to use this as the default. Click
Ok and Eclipse will restart.
Once Eclipse has restarted you will be presented with the following screen.

This workspace has been preconfigured to include a simple Getting Started demo as well as a
demonstration program which makes use of the FreeRTOS operating system.
2. Right click on the Getting Started Demo item and select Build Project

Progress will be seen in the console, with any errors being reported there. This application should however
build without errors and once this is completed, several new files will have appeared in the Bin folder of
the Getting Started Demo. These are the compiled applications, ready to be loaded onto the processor.
4

Compiling completed without errors

3. The next step differs depending on whether or not you are making use of the SAM-ICE JTAG
programmer/debugger.
Copying image to device without SAM-ICE (Via USB)
Firstly, the existing contents of the flash must be erased, setting the device to its default settings.
The default Atmel boot loader will load as the default program, allowing the device to be used with
the AT91 ISP software package. (Important note: this must be done every time when programming
through the USB interface)
This is done by linking the Erase pins, found on the J15 pin header on the SAM7X256-EK
development board while it is powered. A piece of wire is sufficient for this, as shown below.

Important Note: At this point you should start Sam-Prog either through Eclipse (as shown on the
next page) or from the start menu. Starting Sam-Prog while the board is already connected can
cause Sam-Prog to crash on certain system configurations. To avoid this, simply start Sam-Prog and
then connect the board via USB.

Once this has been done, the board can be connected to the computer. The first time it is
connected, windows should search for and install the appropriate driver to be used in programming
the device via USB.

Within Sam-Prog, click the browse and navigate


to the files earlier. Select getting-startedproject-at91sam7x-ek-at91sam7x256-flash.bin
(Found within the subfolder Workspace\Getting
Started Demo\bin)

If your SAM-ICE device is correctly connected to


the development board, the Write Flash button
should become available and Active Connection
will change to 1. Ensure that the Set Security
Bit box is cleared (as shown below) and then
click Write Flash, as well as leaving the automode checkbox clear.

Once the transfer has completed close Sam-Prog, as it needs


to be restarted each time it is used when programming via
USB.

This indicates that a


transfer is now taking place

Disconnect and then reconnect the power for the AT91SAM7X-EK and the application execute.

The LEDs connected to DS1 and DS2 should begin flashing, indicating that the Getting Started
Demo is now running correctly.

Copying image to device using the SAM-ICE JTAG programmer/debugger


Start the Sam-Prog program to copy the binary file onto the flash memory of the processor.
This can be started by either selecting it from the External Tools button in Eclipse or by opening
the programs directly from the Windows Start Menu.
External Tools Dropdown Menu
(click the small black arrow, then click Sam-Prog)

Launching the program from within Eclipse will trigger a rebuild of all open projects; this may take a
moment but ensures that the latest revision of your code is available to be uploaded to the
processor.

Once Sam-Prog has started you can connect both the SAM-ICE and the AT91SAM7X-EK via USB,
then connecting the SAM-ICE to the JTAG interface on the development board.
7

Common Fault - Important Note: Certain system configurations may Cause SAM-PROG and SAMBA to crash on launch if the J-Link SAM-ICE device is already connected before the program is
launched.

This behaviour can be avoided by only connecting the SAM-ICE to the computer after Sam-Prog or
Sam-Ba are already running. Once started this way, the programs will function correctly until they
are closed.

Within Sam-Prog, click the browse and navigate to the files earlier. Select getting-started-projectat91sam7x-ek-at91sam7x256-flash.bin (Found within the subfolder Workspace\Getting Started
Demo\bin)
Once you have found the file, click the Target Connected button.

If your SAM-ICE device is correctly connected to


the development board, the Write Flash button
should become available. Ensure that the Set
Security Bit box is cleared (as shown below) and
then click Write Flash.
If nothing appears to happen when you click this
button, wait 5 seconds and click the Write Flash
button again. Repeat this process until the
status indicator changes to indicated that a
transfer is in progress.
This indicates that a
transfer is now taking place
Common Fault - Important Note:
If you are given an error similar to the one, followed by Sam-Prog crashing when clicking the Target
Connected button, this may indicated that the Security Bit has been set on your processor.

To rectify this, all of the settings must be erased from the processor. The process for this is the
same as outlined in the section Programming without SAM-Ice
Once this has been done, new programs can be loaded onto the board without issue.

Once the transfer has completed, disconnect and then reconnect the power for the AT91SAM7X-EK
and the application execute.
The LEDs connected to DS1 and DS2 should begin flashing, indicating that the Getting Started
Demo is now running correctly.

Using the Debugger


Now that you can compile and run applications, it is important to be able to make use of the on-chip
debugging tools.
There are two modes of debugging available, based on where the program code is stored during the
debugging, Flash or RAM. Flash has the advantage of allowing a larger code space, but is has a limitation of
only allowing a maximum of two breakpoints to be defined. Debugging from ram gives an increased
execution speed as well as allowing unlimited breakpoints, it does however create a limit on the size of
code to which can be loaded into the RAM. (64KB on the AT91SAM7X256)
Below the process for debugging the simple Getting Started Demo will be outlined.
9

Configuration
While a profile for both RAM and Flash debugging already exists within the workspace, some slight
configuration needs to be done to account for your installation location.
Debug Dialog
(click the small black arrow,
then click Open Debug Dialog)

Select the Getting Started Demo (flash) item and select the .elf file associated with it. (getting-startedproject-at91sam7x-ek-at91sam7x256-flash.elf, located in the same folder as the .bin file used earlier to
program the board. Click apply once this is done.

10

Select the Getting Started Demo (ram) item and select the .elf file associated with it. (getting-startedproject-at91sam7x-ek-at91sam7x256-sram.elf, located in the same folder as the .bin file used earlier to
program the board. Click apply once this is done.

Once these have both been set, you are ready to debug the Getting Started Demo.

Switching to Debug View


Debug view is where most of the tools and information relevant to debugging can be found.
Drop down Debug button
(click the two arrows)

If the Debug button is missing, you


will need to select it from a
dropdown menu.

Flash Based Debugging


Important Note: Due to J-Link licensing limitations for the SAM-ICE device, there are limitations as to what
functionality is available for flash debugging. To debug in flash, the application must first be loaded and
running using the steps above.
1. Start the J-Link GDB Server. (found in the start menu or on the External Applications dropdown
within Eclipse)
2. Switch to Debug view and select Getting Started Demo (flash)
11

Debug Dialog
(click the small black arrow)

3. The debugger should load and the program will begin executing. Execution will continue until a
breakpoint is reached or it is manually paused.

Ram Based Debugging


1. Start the J-Link GDB Server. (found in the start menu or on the External Applications dropdown
within Eclipse)
2. Switch to Debug view and select Getting Started Demo (ram)

Debug Dialog
(click the small black arrow)

3. The debugger should load and the program will begin executing. Execution will continue until a
breakpoint is reached or it is manually paused.

Basic Debugger Functionality


Here you will find a brief explanation functionality available in the debugger view.

Watched Expressions

Execution Controls

Breakpoint Marker

12

Execution Controls allow the user to control the flow of execution through the program, pausing or
stopping it at any point in execution or continuing it after a breakpoint. Functions can also be stepped over
or stepped into, allowing the debugger access to in-depth information about the flow of execution.
Breakpoint markers allow the user to place breakpoints in the code and are indicated by a blue dot. These
can be added at any point, including during run-time and are toggled by double clicking in the place
indicated by the arrow above.
Watched Expressions are useful in that they allow the user to select a number of variables which will be
monitored during execution, with their value being displayed in this area whenever execution is paused. To
add a watched expression, right click on a variable and select Add Watched Expression.
For more information a detailed guide on debugging can be found in the debugging section of the
document Using Open Source Tools for AT91SAM7 Cross. Development, which can be found in the
documentation subfolder of this package.

Configuring and running the FreeRTOS Demo


Compiling and running the FreeRTOS demo makes use of the same process as above. This demo however
contains networking components that need to be configured to suite your local network setup. The settings
for this project can be found in FreeRTOSConfig.h and will be outlined below.
Several pieces of information about your computers network configuration will be required for this step.
Start->Run and entering ipconfig /all. You need to identify the IP information for the network adapter that
you will be using to connect to the embedded device.
MAC Address
This is the MAC address of that will be assigned to the development board. It must be unique on the
network segment to which it is connected.
IP Address
This is the IP address of that will be assigned to the development board. It must be both valid and unique
on the subnet to which it is connected.
Subnet Mask
This should be set to the subnet mask of your network.
Gateway Address
This should be set to the gateway router on your network and will allow the device access to networks
beyond its own subnet.
Web Client Host IP
This is the IP address that the device will query using its built in web client. (For this demo, set this to be the
IP address of your PC)

13

Web Client Port


The port that the web server will be running on. (Typically 80)
Web Client File
The path to and file that the built in web client will be retrieving. (in the examples the page is a script that
will execute a task on the remote server)
Web Client Interval
How often the device is to query the specified file (set this to zero to disable periodic retrieval)

Configuring the Local Webserver


An installation of the Abyss Web Server is installed in /Util/Webserver/ folder of your installation directory.
To configure them for your installation directory, double click and run the file Config_Utils.bat. (Note: Any
time that you change your installation directory, you will need to re-run this file)
The Webserver itself can be started by running abyssws.exe, found in the /Util/Webserver/ folder of your
installation directory and monitored and configured through the blue icon which will appear in your system
tray once it is running. The details to access the configuration page for the server are: Username: admin,
password: password, with full documentation found on the Aprelium web site.

Running the FreeRTOS demo


Once the configuration has been completed, right click on the FreeRTOS project file and select Clean
Project. Once this has completed, select Build Project (as in the earlier examples) and upload the resulting
RTOSDemo.bin file on to the development board.
Once the power has been disconnected, then reconnected to the board, connect the Ethernet port on the
board to the Ethernet port on your PC (or switch, depending on your configuration), open your web
browser and enter the IP address of the board (as defined in the FreeRTOSConfig.h) into the address bar.
You can also access the development board through use of the telnet command.
Periodically, the board should also initiate a data download on the client, through use of its web client
executing a local script on the server (your PC), resulting in a file being created based on the boards debug
page. This file is saved as latest_debug.html and can be found in the /Util/Webserver/www/ folder.

14

Das könnte Ihnen auch gefallen