<<

TTI9XE USER GUIDE

SS11001-1

Jan 2011

Testtron Technologies Inc

TTI9XE Software User Guide SS11001-1

Copyright 2008-2011 Testtron Technoligies Inc. All rights reserved.

Testtron makes no warranty for the use of its products and assumes no responsibility for any errors may appear in this document. Nor does it make a commitment to update the information contained herein. Testtron retains the right to make changes to these specifications at any time, without notice. Testtron products are not intended for use in medical, life saving or life sustaining applications. All product names referenced herein are trademarks of their respective companies.

Revision History Version Date Description 1.0 Jan 2011 Initial Release

Testtron Technologies Inc. 2 Jan 2011 TTI9XE Software User Guide SS11001-1 Table of Contents 1. Overview ...... 4 1.1 Scope ...... 4 1.2 References ...... 4 1.3 Acronyms ...... 4 2. Toolchain Components ...... 5 2.1 SAM-ICE ...... 5 2.2 GDB Server ...... 5 2.3 SAM-BA ...... 5 2.4 YAGARTO ...... 5 2.5 GNU Utilities ...... 5 2.5.1 Make ...... 6 2.5.2 CoreUtils ...... 6 2.6 Eclipse ...... 6 2.7 Terminal Emulator ...... 6 3. Toolchain Installation ...... 7 3.1 SAM-ICE ...... 7 3.1.1 Getting SAM-ICE Software ...... 7 3.1.2 Installing SAM-ICE Software ...... 7 3.1.3 GDB Server ...... 7 3.2 SAM-BA ...... 8 3.2.1 Getting SAM-BA ...... 8 3.2.2 Installing SAM-BA ...... 8 3.2.3 Using SAM-BA ...... 8 3.3 YAGARTO ...... 9 3.3.1 Getting YAGARTO ...... 9 3.3.2 Installing YAGARTO ...... 9 3.4 GNU Utilities ...... 10 3.4.1 Getting GNU Utilities ...... 10 3.4.2 Installing GNU utilities ...... 10 3.5 Eclipse and JRE ...... 10 3.5.1 Installing JRE ...... 10 3.5.2 Getting Eclipse Tools ...... 10 3.5.3 Installing Eclipse Tools ...... 10 3.6 Terminal Emulator ...... 12 4. Configuring the Toolchain ...... 13 4.1 Creating a New Project ...... 14 4.1.1 Workspace Launcher ...... 14 4.1.2 Setting Perspective ...... 15 4.1.3 Creating Eclipse Project ...... 16 4.1.4 Setting Project Properties ...... 17 4.1.5 Project Source Files ...... 19 4.1.6 Building the Project ...... 21 4.1.7 Configuring the Debugger ...... 22 5. The TTI9XE Board ...... 26 5.1 Boot sequence ...... 27 5.2 Bootstrap Application ...... 27 6. Debugging the TTI9XE Board ...... 28 6.1 Starting a Debug Session ...... 28 6.1.1 Starting DBGU ...... 28 6.1.2 Starting the Debug server ...... 29 6.1.3 Starting Eclipse CDT ...... 29 6.1.4 Using the Eclipse Debugger ...... 30 7. Software Applications ...... 32 8. Design Notes ...... 33

Testtron Technologies Inc. 3 Jan 2011 TTI9XE Software User Guide SS11001-1

1. Overview Most development solutions used today in the ARM® world are commercial packages. This document shows a toolchain based on a GNU open-source solution. It is an adaptation of the YAGARTO GNU-Based Software Development for the TTI9XE board. 1.1 Scope The goal of the present document is to provide a step-by-step guide for setting up a GNU software design environment targeted at the TTI9XE board using the Atmel AT91SAM9XE microcontroller. The EABI design environment includes the following features: o Compilation and building of projects using the GNU compiler toolchain o Debugging using the Atmel SAM-ICE™ emulator and SEGGER GDB-server o Memory programming using SAM-BA™, Atmel In-Situ Programming (ISP) tool o Integration of those tasks in an Eclipse™-based development environment 1.2 References [01],Atmel. AT91SAM9XE-512 Full Specification - 6254. [02],Atmel. AT91 ISP/SAM-BA User Guide - 6421B. [03],Atmel. Getting Started with AT91SAM9 Microcontrollers - 6297. [04],Atmel. AT91SAM-ICE User Guide - 6206. [05],Atmel. SAM Boot Assistant (SAM-BA) User Guide - 6132. [06],Atmel. GNU Based Software Development on AT91SAM - 6310. [11],Testtron. TTI9XE Board User Guide. [12],Testtron. TTI9XE schematics. [13],Testtron. Software samples and utilities DVDROM. [21],Xilinx. XC95144XL High Performance CPLD - DS056. [22],ARM. ARM9EJ-S Technical Reference Manual - DDI 0222A. [23],TI. TLV320AIC1110 Datasheet. [24],Microchip. MCP2515 Datasheet.

1.3 Acronyms This document uses the following abbreviations: CDT /C++ Development Toolkit EABI Embedded Application Binary Interface ELF Executable and Linkable Format GDB GNU Debugger GNU Cyclic Redundancy Check ISP In System Programming LED Light Emitting Diode OEM Original Equipment Manufacturer RGB Red, Green, Blue SRAM Static Random Access Memory SDRAM Synchronous Dynamic Random Access Memory

Testtron Technologies Inc. 4 Jan 2011 TTI9XE Software User Guide SS11001-1 2. Toolchain Components Several different packages have to be combined in order to obtain a fully-featured system which can be compared with commercial offers. This section describes each component of the GNU environment about to be setup. 2.1 SAM-ICE The Atmel SAM-ICE In-Circuit-Emulator is an OEM version of Segger J-Link designed to be used only with Atmel AT91 microcontrollers. This is the ICE tool used is this user guide. o Support for all Atmel AT91 ARM7/ARM9 based microcontrollers o Powered through USB o Auto speed recognition o Standard 20-pin JTAG connector o Support for adaptable clocking 2.2 GDB Server The GDB Server utility developed by SEGGER enables the GNU GDB debugger to connect remotely to an ARM microcontroller through a JLink-compatible device. In addition, since it creates a TCP/IP server on the local network, any connected computer can debug the target. GDB Server is a commercial package; however, Atmel has acquired the license for its SAM-ICE emulator. Thus, it can be used without restriction when using a SAM-ICE probe and an AT91 microcontroller. More information about GDB Server can be found by visiting the following website: http://www.segger.com/jlink_gdb.html. 2.3 SAM-BA The SAM-BA (SAM Boot Assistant) is one of the tools provided in Atmel AT91 In-System Programming (ISP) solution. It provides an easy way for programming AT91 family microcontrollers using a graphical or command-line interface. It is also possible to create powerful scripts which can then be run via the command line, enabling the automation of many tasks. Those scripts can be hand written by the programmer or recorded through the graphical interface. 2.4 YAGARTO YAGARTO (Yet Another GNU ARM Toolchain) is an implementation of the GNU ARM toolchain. Among other utilities, it includes a C/C++ compiler (gcc/g++), an assembler (as), a linker (ld) and a debugger (gdb). Compared to other GNU ARM-based toolchains, YAGARTO has the advantage of being compiled natively for Windows. Most other implementations use a porting of several ® layers (like or MinGW), which is convenient than having a binary dedicated to Windows®. Finally, special care has been taken to ensure that all the tools provided by YAGARTO are fully compatible with Eclipse. This makes up another reason for choosing this particular toolchain over others. For more information about YAGARTO and GNU tools, please refer to http://www.yagarto.de and http://www.gnu.org. 2.5 GNU Utilities The GnuWin32 project provides Win32-versions of GNU tools, or tools with a similar open source license The ports are native ports, that is, they rely only on libraries provided with any standard 32-bits MS-Windows .

Testtron Technologies Inc. 5 Jan 2011 TTI9XE Software User Guide SS11001-1

2.5.1 Make Most GNU-based projects use the make utility to manage their building process. It tells the compiler(s) and linker(s) which files must be compiled or linked and how they should be, according to a set of rules written by the programmer in a makefile. The advantage is that any tool chain can be used with make, thus rendering projects built using makefiles more portable.

2.5.2 CoreUtils The GNU Core Utilities are the basic , shell and text manipulation utilities of the GNU operating system. These are the core utilities which are expected to exist on every operating system. 2.6 Eclipse Eclipse is an open-source Integrated Development Environment (IDE) originally targeted at Java programming. However, thanks to its modularity, multiple plug-ins have been developed to enable C/C++ programming & debugging, or to integrate version control systems. More details about Eclipse can be found on the project web site at http://www.eclipse.org. 2.7 Terminal Emulator The TTI9XE board includes a RS-232 interface “DBGU” that is used as a console to report debug messages and runtime errors and warnings. In order to use this interface a serial Terminal Emulator has to be installed on the workstation. HyperTerminal or TeraTerm are to free applications that may be used for that purpose. This guide uses TeraTerm.

Testtron Technologies Inc. 6 Jan 2011 TTI9XE Software User Guide SS11001-1 3. Toolchain Installation This section describes how to obtain and install the various software applications required for the GNU toolchain. 3.1 SAM-ICE The SAM-ICE is an Atmel version of the Segger J-Link development tool. The JTAG side of the SAM-ICE connects to the microcontroller through the TTI9XE JTAG port and the USB port provides the connection to a PC. There are many others ICE tools that may be used with this environment. For instance, Segger sells an inexpensive version of their J-Link tool: the J-Link for educational purpose, with the restriction that it may not be used for the development of a product. o SAM-ICE is an OEM version of Segger J-Link device.

o Limitations: SAM-ICE works with Atmel microcontrollers only.

o Licenses: RDI and GDB Server are included. Other licenses can be added.

3.1.1 Getting SAM-ICE Software Segger J-Link software provides the drivers required by the SAM-ICE. This software includes: USB driver, J-Link, J-Mem, jlink.exe and jlinkarm.dll, RDI and GDB server. 3.1.2 Installing SAM-ICE Software The JLink package “Setup_JLinkARM_Vxxx.exe“ is provided as a self-installing executable. Double-clicking on this file starts the installation. Go to Windows Start Menu and open the SEGGER/JLinkARM menu to access all available software and reference manuals. To validate the installation, connect the SAM-ICE to an USB port: it should be detected. Then, run the J-Link Commander tool to display the hardware version of the SAM-ICE box. 3.1.3 GDB Server The GDB server is part of the Segger J-Link software for the SAM-ICE device. The GDB Server translates the GDB commands into the J-Link commands. If you connect the SAM-ICE JTAG port to a powered TTI9XE board and run J-Link GDB Server, a window as shown in Figure 1 will be displayed. The server is then ready to accept connection with a remote host and execute commands.

Figure 1: GDB Server Window

Testtron Technologies Inc. 7 Jan 2011 TTI9XE Software User Guide SS11001-1

3.2 SAM-BA SAM-BA software in conjunction with SAM-ICE tool allows to: read/write microcontroller memory, upload and download files and create and run TCL scripts. SAM-BA may only be used when the TTI9XE board is booting from ROM because the USB enumeration is only possible in this mode as shown in Figure 35: Power-up boot sequence.

3.2.1 Getting SAM-BA Since SAM-BA is part of the Atmel ISP solution, the whole package must be downloaded and installed. The latest version of ISP is available on the Atmel web site, at the following address: http://www.Atmel.com/dyn/products/tools_card.asp?tool_id=3883.

3.2.2 Installing SAM-BA The Atmel ISP package is provided as a self-installing executable file named “Install AT91- ISP vX.Y.exe“ (X.Y is the version number). Double-clicking on this file starts the installation. The installation steps are very straightforward. Note that if there already is a version of ISP on the system, it will have to be uninstalled (this case is automatically detected by the setup program). Once the wizard is finished, SAM-BA will be available in the startup menu under: Start Menu > Atmel > AT91 ISP vX.Y > SAM-BA vX‟.Y‟.exe 3.2.3 Using SAM-BA The SAM-BA user interface is shown in Figure 2. This tool allows to read/write all the on-board memories and the microcontroller flash. The GPNVM may also be changed. The send/receive file commands allow to transfer data between the board and the remote host.

Figure 2: SAM-BA User Interface

Testtron Technologies Inc. 8 Jan 2011 TTI9XE Software User Guide SS11001-1

3.3 YAGARTO YAGARTO (Yet Another GNU ARM Toolchain) is a project supported by the community under the this license http://creativecommons.org/licenses/by/2.5/. In addition to YAGARTO package, the following four packages are required in order to create a complete development system: o Open On-Chip Debugger J-Link/SAM-ICE GDB Server (Section: 2.1) o GNU Utilities: make, fileutils (Section: 3.4) o Eclipse Platform Runtime Binary (Section: 3.5) o Eclipse CDT (Section: 3.5) 3.3.1 Getting YAGARTO The YAGARTO home page, http://www.yagarto.de offers three binary packages for download: the package to download and install is the second one (“YAGARTO GNU ARM toolchain”), this package integrates four software tools. For example release 23.12.2010 contains: o Binutil 2.21 o Newlib-1.19.0 o GCC-4.5.2 o GDB-7.2

3.3.2 Installing YAGARTO Launch the YAGARTO install file to start installation. This brings the standard “Welcome” and “User agreement” dialogs. Use C:\YAGARTO as Installation directory. By default, they are all checked; do not uncheck any component as they are all required as shown in Figure 3.

Figure 3: Installing YAGARTO

For the rest of the installation: click “Next >” until the final “Installation complete” dialog appears. YAGARTO is now available from the command line. To test the installation, in Command Prompt type following: “arm-none-eabi-gcc –version” and the result should be: Arm-none-eabi-gcc (GCC) 4.5.2 Copyright (C) 2010 Foundation, Inc. This is free software; see the source for copying condition. There is …

Testtron Technologies Inc. 9 Jan 2011 TTI9XE Software User Guide SS11001-1

3.4 GNU Utilities The software examples in this guide use the make and other utilities from GNUWIN32 to manage their building process.

3.4.1 Getting GNU Utilities The two packages required for this toolchain are the Make Utility and the FileUtils Utility which is collection of file utilities.

3.4.2 Installing GNU utilities The files retrieved from the GnuWin32 web page are .exe installer. For installation, proceed with each one by double-clicking the .exe file. The installer will ask for a target directory (Example C:\GNUWIN32), which components to install as well as other minor details. The installation directory can be located anywhere, however it should be noted as it will be used for the rest of the configuration. Now, the tools must be made available system-wide. In order to do that, the directory where .exe are installed (C:\GNUWIN32\bin) must be added to the Windows PATH environment variable. 3.5 Eclipse and JRE To use Eclipse as an Integrated Development Environment for your toolchain you need to get and install the following: o Java Runtime Environment (JRE) by Sun if it is not already installed on your PC. o Eclipse Platform Runtime Binary. o Eclipse C/C++ Development Tooling – CDT 3.5.1 Installing JRE First we need to verify if the JRE is already installed on your PC. Open a command prompt and type “C:\>java –version”: the result should look like: Java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing) If the Java Runtime Environment (JRE) is not installed on your PC, you can download the JRE from the following Sun website: Java SE Downloads and save to a temp directory. For instance, the result shown above is from installing version: “jre-6u24-windows-i586.exe”. Make sure that the JRE version is at least 1.6.xx.

3.5.2 Getting Eclipse Tools First, we need the Eclipse Platform Runtime Binary latest release, the version 3.6.1 is used in this guide: “eclipse-platform-3.6.1-win32.”. Get the package and save it in the temp directory. Lastly, the Eclipse C/C++ Development Tooling - CDT latest release is needed, this guide uses the version “7.0.1: cdt-master-7.0.1-I201009241320.zip”. Get the package and save it in the temp directory.

3.5.3 Installing Eclipse Tools To install Eclipse Platform Runtime Binary, unzip the file on drive C:\, this will create a folder named C:\eclipse. In that folder you will find the “eclipse.exe” application itself, please create a shortcut on your desktop now. You can use this shortcut later to start the eclipse application.

Testtron Technologies Inc. 10 Jan 2011 TTI9XE Software User Guide SS11001-1

The Eclipse CDT tool as to be installed from within Eclipse as follow: o Start Eclipse and accept the default workspace by clicking “OK”. o In the “Welcome Menu”, click the ”Help” button and select “Install New Software”. o In the “Install Menu” click “Add” button. o In the “Add Repository” menu: set the “Name” to CDT and click “Archive” button to point where you saved the Eclipse CDT zip file. Then click OK. o Back to the “Install Menu”: select the tools to install as shown Figure 4. o Click” Next”, accept the license agreement and click “Finish” to start installation. o Click “Restart Now” to finalize the CDT installation. o Close Eclipse after the restart is done.

Figure 4: Eclipse CDT Installation

Testtron Technologies Inc. 11 Jan 2011 TTI9XE Software User Guide SS11001-1

3.6 Terminal Emulator In this user guide, we use TeraTerm as terminal emulator to communicate the TTI9XE board “DBGU” interface. In the case where there is no serial connector on our workstation, you may use a USB to serial adaptor. Download the application and install it by unzipping the file into a subdirectory of your choice. Then, run TeraTerm and the “New Configuration” window will appear as shown in Figure 5. Select “Serial” and the com port that you are using and click the “OK” button.

Figure 5: TeraTerm Setup

To configure the serial port click “Setup” then “Serial Port…” and the “Serial port setup” window will appear as shown in Figure 6. We have to use the same default parameters as the DBGU port: Baud 115200, 8-bit, no parity, 1 stop and no flow control. Then you may save this setup by clicking “Setup” and “Save Setup.

Figure 6: TeraTerm Serial Setup

Testtron Technologies Inc. 12 Jan 2011 TTI9XE Software User Guide SS11001-1 4. Configuring the Toolchain This section demonstrates how to use the newly installed toolchain by creating a project directory and compiling a software example provided with the TTI9XE package. From the TTI9XE DVD, we will use the Basic Assurance Test “TTI9XE-BAT” project as a practical design example. This is the project which is going to be referred to in the following subsections. Figure 7 shows the directory structure of the root directory where all software projects are located. Software Root Directory at91Lib Atmel specific AT91SAM Library BoardLib TTI9XE Board specific Library CompLib TTI9XE Onboard Component Library ExtLib External Library TTI9XE-BAT Project Top level (Eclipse workspace) .metadata Eclipse created project file DOC Project Documentation projLib Project specific Library BAT Project Software Top Level bin Directory for binary files obj Directory for object files .cproject Eclipse created project file .project Eclipse created project file main.c The „C‟ main file Makefile The „C‟ make file Other Projects Figure 7: Design Directory Structure

The at91Lib contains all the sources files provided by Atmel in their design package. This includes the AT91SAM peripherals, microcontroller, drivers and utilities specific to Atmel devices. The files are used without any modification. The BoardLib library contains the files specific to the TTI9XE board. For example: the “board.h” file contains the hardware configuration for the microcontroller pins. The CompLib library contains the sources files for the components used on the TTI9XE board such as the PHY device, NAND Flash, audio chip… The ExtLib library contains the source files for external libraries used for design. This includes file system, web server, CRC generator/checker … The TTI9XE-xxxx projects give their names to the top level directories, there is one such directory for each project. This is the workspace name that is specified to Eclipse when creating a new project. The following files: .metadata, .cproject and .project are created and updated by Eclipse. These files may be deleted to restart a project from scratch. The makefile is the file used by the GNU make utility to compile the design.

Testtron Technologies Inc. 13 Jan 2011 TTI9XE Software User Guide SS11001-1

4.1 Creating a New Project The first step is to launch Eclipse. The program can be found at: “c:\eclipse\eclipse.exe”. Eclipse will ask for a workspace directory: the directory where the new project will be saved. For the purpose of this example, in the root directory is “D:\Designs\TTI9XE\Software”, we will add the new project TTI9XE-BAT.

4.1.1 Workspace Launcher To start a new project, simply start Eclipse, and you will get to the Eclipse workspace launcher as shown in Figure 8 Use the browser to point to the root directory and enter the new project name “TTI9XE-BAT, then click OK. This will create the workspace directory for this project and bring up the Eclipse desktop window as shown in Figure 9.

Figure 8: Eclipse Workspace Window

In the Eclipse desktop, click the Workbench icon to go to workbench window then proceed to setting perspective.

Figure 9: Eclipse Workbench Window

If a project already exists in the workspace, the launcher will go directly to the workbench, bypassing the desktop window: this is the normal behavior to continue working on a project. Eclipse creates the file “.metadata” to keep tract of the project status, do not modify this file since it may corrupt the project status.

Testtron Technologies Inc. 14 Jan 2011 TTI9XE Software User Guide SS11001-1

4.1.2 Setting Perspective In Eclipse environment, a perspective determines the visible actions and views within a window. A perspective is useful in organizing various eclipse views around the editor area, these are also helpful in managing menus and toolbars. In this guide, we will use the "C/C++ Perspective" and the “Debug Perspective”. Setup the perspective as follow: 1) Figure 10: In the Eclipse Platform Window click "Window / Open Perspective / C/C++ ..."

Figure 10: Eclipse Perspective Setting-1

2) Figure 11: Remove the Resource perspective since it is not needed…

Figure 11: Eclipse Perspective Setting-2

3) Figure 12: Final setup for C/C++ perspective.

Figure 12: Eclipse Platform Window

Testtron Technologies Inc. 15 Jan 2011 TTI9XE Software User Guide SS11001-1

4.1.3 Creating Eclipse Project Starting in the Eclipse Platform Window we will create a C-Project directory as follow: click the "File / New / C Project" as shown Figure 13.

Figure 13: Eclipse Project Type

Type in “BAT” as "Project name", then Select "Makefile project" and "-- Other Toolchain --", finally, click the "Finish" button as shown in Figure 14.

Figure 14: Eclipse Project Name

Figure 15 shows the final window after creating an Eclipse project.

Figure 15: Eclipse Project Platform

Testtron Technologies Inc. 16 Jan 2011 TTI9XE Software User Guide SS11001-1

4.1.4 Setting Project Properties In the ”Project” tab, disable the “Build Automatically” feature as shown in Figure 16.

“ Figure 16: Eclipse Build Property

From the same “Project” tab, click the “Property” feature and the property window will open as shown in Figure 17.

Figure 17: Eclipse Project Properties

The “Property” window allows to changes the setting of various parameters for the design. We are using the default values except for the following properties:“Settings”, “Discovery Options” in the “C/C++Build” section and “Indexer” in the “C/C++ General” section: as shown below.

Testtron Technologies Inc. 17 Jan 2011 TTI9XE Software User Guide SS11001-1

In “C/C++Build”, click “Setting” and select ”GNU Elf Parser” as shown in Figure 18.

Figure 18: Eclipse Binary Parser Option

The “Discovery Options” functionality allows for improved search and code assist functions for make projects. As shown in Figure 19: select “Automate discovery…” and “GCC per project…” options, then enter “arm-none-eabi-gcc” for the Compiler invocation command.

Figure 19: Eclipse Discovery Options

Testtron Technologies Inc. 18 Jan 2011 TTI9XE Software User Guide SS11001-1

Finally, as shown in Figure 20, in the “C/C++ General” section, click the “Indexer” property, and check the “Enable project specific…” choice. Then, click the “OK” button to finalize and save all the property settings.

Figure 20: Eclipse Indexer Options

4.1.5 Project Source Files Our project is empty and we must import the project files to Eclipse. To import the files from another project: use the "File / Import..." menu and select the "File System" as input source and click “Next” button as shown in Figure 21.

Figure 21: Eclipse Project Files

Testtron Technologies Inc. 19 Jan 2011 TTI9XE Software User Guide SS11001-1

To download the files for the “BAT” project, select the directory in the "From directory", select the files with the checkmark and set the “Into folder” directory as shown in Figure 22. Then press "Finish" to close the dialog and complete the file transfer.

Figure 22: Eclipse Project File Selection

To build a project, you need a file called “Makefile” to tell the GNU “Make” tool what to do. Basically, the Makefile tells “Make” how to compile and link a program. The Makefile can also specify how to run miscellaneous commands when explicitly asked, for example, to remove certain files as a clean-up operation For the “BAT” project, there is only one source file: “main.c”. But, the project expects to be installed in a root directory with the structure shown in Figure 7. This is required since the “main.c” file may include other source files from this hierarchy. So, prior to create this project, you must have already created this director and copied the required directories: a91Lib, BoardLid, CompLib and ExtLib. Of course, you can create a brand new project using the editor or copy the files directly in the project directory and modify them.

Testtron Technologies Inc. 20 Jan 2011 TTI9XE Software User Guide SS11001-1

4.1.6 Building the Project Figure 23 shows the result of the previous “Import file” command. Now, we will build the project using the “Clean” command from the “Project” tab. The “Clean” command deletes all the result files from a previous build before executing a new build. The “Build All” command do not performs the file delete before executing the build.

Figure 23: Eclipse Project Build

In Figure 24, accept the default settings an click “OK”.

Figure 24: Eclipse Clean Window

Figure 25 shows the final result after the build for the project is done. The “Binaries” directory contains the files to use for debugging.

Figure 25: Eclipse Project Window

Testtron Technologies Inc. 21 Jan 2011 TTI9XE Software User Guide SS11001-1

4.1.7 Configuring the Debugger For the debug process we need to create the "Debug Perspective". For this purpose use "Window / Open Perspective / Debug" as shown in Figure 26.

Figure 26: Eclipse Debug Perspective

The new debug perspective will be opened. It looks like Figure 27.

Figure 27: Eclipse Debug Window

Testtron Technologies Inc. 22 Jan 2011 TTI9XE Software User Guide SS11001-1

To start the debug configuration, click the Debug menu, then click the “Debug Configuration” option as show in Figure 28.

Figure 28: Eclipse Debug Configuration-1

Then right click the “GDB Hardware Debugging” option, then click the “New” option as shown in Figure 29.

Figure 29: Eclipse Debug Configuration-2

Continue by clicking the “Search Project” , select the “TTI9XE-BAT-sram.elf” in the menu then click “OK” as shown in Figure 30.

Figure 30: Eclipse Debug Configuration-3

Testtron Technologies Inc. 23 Jan 2011 TTI9XE Software User Guide SS11001-1

Change the configuration name from “DAT Default” to “BAT SRAM” to indicate that this configuration is for the SRAM version of the design, select the “Disable auto build” option, select the “Using Standard GDB Debug…” then click the “Apply” button as shown in Figure 31.

Figure 31: Eclipse Debug Configuration-4

As shown in Figure 32, click the Debugger tab, change the GDB Command to “arm-none-eabi- gdb”, enter the port number “2331” for the Atmel SAM-ICE box then click the “Apply” button. Here, the configuration may need to be modified for different ICE device.

Figure 32: Eclipse Debug Configuration-5

Testtron Technologies Inc. 24 Jan 2011 TTI9XE Software User Guide SS11001-1

Finally, click the “Startup” tab, select the “Set breakpoint at:” and “Resume” options, enter “main” for the breakpoint then click the “Apply” button.

Figure 33: Eclipse Debug Configuration-6

We may need to run some initialization prior to loading the image. For instance, we need to initialize the DRAM controller before using the DRAM memory. Copy and paste the contents of the file “BoardLib\TTI9XE\sdram_init.gdb” into the "Initialization Commands" area 1. We are done with the debugger configuration and you may close the dialog with the "Close" button. Press "" to save the changes if asked.

Testtron Technologies Inc. 25 Jan 2011 TTI9XE Software User Guide SS11001-1 5. The TTI9XE Board The TTI9XE board is designed around the Atmel AT91SAM9XE512 microcontroller as shown in. Figure 1. Based on ARM926EJ-S processor, it integrates fast ROM and RAM, 512 Kbytes of Flash memory and a wide range of peripherals: Ethernet MAC, USB Device and Host ports, UARTs, SPI, TWI, Timer and JTAG-ICE interface. All the I/O drivers and level translators needed by the peripherals are implemented on- board.

L1 RST SW JTAG DBUG RGB LED

50MHz 5 RS232 I 4 P - PHY J S / R D

32.768KHz 18.432MHz S A -

B RS232 S S M U 2

3V RS485 M 1

Batt O 5 B C

- CAN E B S X 16MHz U 9

1.8V M E

REG M RS232 D N O A D M H S S Buzzer 1 9

MIC T microSD AUDIO A 4GBytes AD/DA EAR 6

ER Erase 1 ISO- 8 7

Scan 7816 O

SC S I 1GBytes 128MBytes WP WP D NANDflash SDRAM A P Y

CFG E Config JTAG Keypad IF K CPLD S S System Bus Expansion Bus U U B B - - TWI Bus TWI Bus X S

Temp Sensor TWI 64KBytes Bus Switch EEPROM 3.3V 5V REG

TWI-1 TWI-2 TWI-3

Figure 34: TTI9XE Block Diagram

Refer to TTI9XE Hardware User Guide for a full description of the board.

Testtron Technologies Inc. 26 Jan 2011 TTI9XE Software User Guide SS11001-1

5.1 Boot sequence At power-up the microcontroller will execute the boot sequence. Depending on the state of the ERASE jumper and the state of the bit GPNVM[3] in the microcontroller flash memory, the boot sequence will proceed according to the Figure 35.

Power Up

Erase Embedded Flash Boot from Embedded Flash ERASE And clear all GPNVM Bits. Yes = 1 Send “>FlashBOOT” to console No If on-board KEY is pressed: Clear the Boot from ROM GPNVM[3] Bit and stop. No Yes Send “>RomBOOT” to console GPNVM[3] Else: Start 1st Level Bootloader and run Wait for USB SAM-BA login. = 1 the application.

Figure 35: Power-up boot sequence

On power-up, if the ERASE jumper is installed: the microcontroller embedded flash is erased including all the GPNVM bits. On the next power-up the microcontroller will boot from ROM. On power-up if the ERASE jumper is not installed and the GPNVM[3] bit is cleared: the message “>RomBOOT” is sent to the console on the DEBUG port. The system will then wait for USB enumeration on the USB device port. The SAM-BA utility provided on the CDROM may be used to debug and configure the TTI9XE board. On power-up if the ERASE jumper is not installed and the GPNVM[3] bit is set: the booting is executed from the microcontroller embedded flash. In this mode, a bootloader needs to be present in the flash memory to control the boot sequence. When using the bootloader included in the CDROM, a test of the board tact switch “KEY” is done at power-up: if the key is pressed, the GPNVM[3] is cleared and boot sequence is stopped, this is useful to revert to booting from ROM without having to erase the complete embedded flash. If the switch is not pressed, booting will continue and the application started. 5.2 Bootstrap Application The Bootstrap application can be considered as a first level bootloader. It is a modular application, so it becomes easy to modify the framework for a particular deployment strategy. The TTI9XE board is shipped with the TTI9XE-Bootsrap application already installed in the flash memory and the GPNVM[3] bit set. The Bootstrap will perform the following tasks: o If the on-board user KEY is pressed: clear GPNVM[3] bit and abort o Perform microcontroller hardware initialization o Configure SDRAM controller o Configure on-board NandFlash memory o Load NandFlash image in the SDRAM o Run the application The TTI9XE board is shipped with TTI9XE-BAT application already installed in the NandFlash memory. So, at power up the BAT image will be loaded in the SDRAM memory and executed.

Testtron Technologies Inc. 27 Jan 2011 TTI9XE Software User Guide SS11001-1 6. Debugging the TTI9XE Board Figure 36 shows the test setup required to debug the TTI9XE board. The setup consists of the following items: o The TTI9XE board o An AC-DC wall adaptor o An Atmel SAM-ICE box o A workstation with windows environment o Serial cables include in the design kit o Software and utility DVD

SAM-ICE 5VDC TTI9XE Scan JTAG AC-DC Adapter Key Erase USB 5VDC 5%, 3A Reset NandWP DBGU RS232 Ethernet Audio LED USB-B USB-A Windows USB-CDC Environment

Figure 36: TTI9XE Debug Setup

6.1 Starting a Debug Session Before starting a debug session, the proper software applications need to be installed in the workstation and the serial cables installed. o DBGU, the RS-232 serial debug interface acts as a console during debugging. It is also used to report errors and warnings at run time. Refer to section 3.6 for the installation procedure of “TeraTerm”, the Terminal Emulator. o SAM-ICE, the Atmel In Circuit Emulator connects to the board using a 20-pin JTAG interface and to the workstation using a USB port. Refer to section 3.1 for the software installation procedure. o YAGARTO and Eclipse CDT include all the tools for a complete software development environment. It provides the compiler/linker for „C‟ application and integrates the GDB debugger. Refer to sections 3.3 and 3.5 for the installation procedure. o SAM-BA, the Boot Assistant USB application when installed on the workstation will enumerate the TTI9XE board when booting from the internal ROM if board is connected to the workstation using a USB cable. Refer to section 3.2 for the installation procedure. 6.1.1 Starting DBGU Install the serial cable and start TeraTerm as shown in Figure 37. The window shows the result of powering up the board in the ROM mode, with the GPNVM[3] bit cleared

Figure 37: TeraTerm Window

Testtron Technologies Inc. 28 Jan 2011 TTI9XE Software User Guide SS11001-1

6.1.2 Starting the Debug server Install the SAM-ICE box using an USB cable and the 20-pin cable adapter. Refer to section 3.1 for the installation procedure. Then start the GDB server as shown in Figure 38. The window shows the result of starting the server with TTI9XE board powered. All the info on the SAM-ICE and microcontroller are listed. As you can see the server is “Waiting for connection” from the Eclipse debugger.

Figure 38: GDB Server window

6.1.3 Starting Eclipse CDT First, we need to select the project to work with: we will test the TTI9XE-BAT project which is already compiled and ready for debug. Start Eclipse and use the browser to select the project TTI9XE-BAT for the “Workspace”, then clicks “OK”.

Figure 39: Eclipse Workspace Window

Testtron Technologies Inc. 29 Jan 2011 TTI9XE Software User Guide SS11001-1

Secondly, in the Eclipse platform window that is now open, click the down arrow near the debug icon “Insect” to open the menu and click the “Debug configurations…” option, this will open the “Debug Configurations” window as shown in Figure 40. In this window, select the “BAT SRAM” project and click the “Debug” button to start the debugger. Note that we selected the SRAM version of the project, there is also the SDRAM version that require the SDRAM controller to be active prior to be able to use it. Refer to section 4.1.7 on how to configure the debugger for this case.

Figure 40: Eclipse Debug Configuration Window

6.1.4 Using the Eclipse Debugger The GDB server shows that the project is running by reporting “Connected to 127.0.0.1” message in the “GDB” window as shown in Figure 41. The log window indicates the number of bytes and the address where the program was loaded. Download verification was also OK.

Figure 41: GDB Server window

Testtron Technologies Inc. 30 Jan 2011 TTI9XE Software User Guide SS11001-1

The “Debug” window is also updated to indicate the project is suspended (line 289) at the beginning of the “main” program as requested in the debug configuration as shown in Figure 42. Now we will set a breakpoint at line 298 by double-clicking in the right margin of this line: this will set a marker on this line and update the “Breakpoints” window with this new entry. We are ready to continue the program by the clicking the green arrow in the “debug” window as shown in Figure 42.

Figure 42: Eclipse Debug Window

As a result of the previous command, the debugger has run until the breakpoint and is now stopped at line 298 as shown in Figure 43. The console shows the startup banner as sent to the default display by the “main” program. By clicking again the green arrow, the program will restart and run forever causing the RGB LED to blink.

Figure 43: Console Display Window

Testtron Technologies Inc. 31 Jan 2011 TTI9XE Software User Guide SS11001-1 7. Software Applications The TTI9XE board includes a DVD-ROM which contains software applications for the microcontroller peripherals and the on-board devices: o TTI9XE-AUDIO Audio interface tests o TTI9XE-BAT Basic Assurance Test o TTI9XE-BOOTSTRAP Bootstrap application o TTI9XE-CAN CAN Bus test o TTI9XE-EMAC EMAC peripheral test o TTI9XE-EMAC_LWIP EMAC with LWIP HTTP server o TTI9XE-EMAC_UIP EMAC with UIP HTTP server o TTI9XE-ISO7816 ISO7816 testing o TTI9XE-NANDFLASH NandFlash testing o TTI9XE-SD_CARD MMC peripheral in SD mode o TTI9XE-SD_MCI MMC peripheral in MCI mode o TTI9XE-SD_SPI MMC peripheral in SPI mode o TTI9XE-TWI_EEPROM TWI access to on-board EEPROM device o TTI9XE-TWI_LCD TWI access to LCD display o TTI9XE-TWI_TEMP TWI access to Temperature Sensor device o TTI9XE-USART_MODEM MODEM port loopback o TTI9XE-USART_RS232 COMMS RS232 with flow control o TTI9XE-USART_RS485 COMMS RS485 port in loopback o TTI9XE-USB_LOOPBACK USB Host and Device connected in loopback o TTI9XE-XBUS X-Bus test

Testtron Technologies Inc. 32 Jan 2011 TTI9XE Software User Guide SS11001-1 8. Design Notes The make utility does not currently support spaces in directory or file names, so they should be avoided.

Testtron Technologies Inc. 33 Jan 2011