I tried to post an answer to a similar question on www.at91.com but have
problems with submitting to their forum. My answer is similar to the
ones in this thread, but I thought I go a little further and cover also
the next step which is debugging. I figure once somebody can build with
the Yagarto toolchain, she wants to start now debugging. So the the few
paragraphs below cover briefly how to create an Eclipse managed project
and how to debug under Eclipse using a SAM-ICE on an AT91SAM9 target.
The linker complains about unsatisfied references to functions that are
called from Yagarto's newlib system library (version 1.18). You have to
supply these functions in another module that you have to make part of
the project. Yagarto provides such a module at
http://www.yagarto.de/download/yagarto/syscalls.c. Yagarto's library
takes up quite some code space. For instance, the same TWI project (my
own based on the at91sam9m10-ek-softpack-1.9 example) is about 13 kB in
size when using Keil's library version but 50 kB using Yagarto's
library. (I think Keil's equivalent to Yagarto's syscalls.c is
<softpack-1.9 Keil example folder>at91lib/utility/retarget.c.) The
syscalls.c module contains mainly stubbed functions. Their "flesh" is
taken out being surrounded by "#if 0". If you like to have trace
functionality (dbgu.c in Atmel AT91 library) via a USART you have to
bring this code to life, for instance for _write_r():
int _write_r (struct _reent *r, int file, char * ptr, int len)
// GF: Re-entrancy structure is not used!
for (index = 0; index < len; index++)
if (ptr[index] == '\n')
What you need to have installed:
- Yagarto (www.yagarto.de)
- Eclipse with CDT (www.eclipse.org)
- GNU ARM plugin (add to Eclipse->Help->Software Updates
- JTAG device and driver, and gdb server (I am working with a SAM-ICE
from Segger and its gdb server, www.segger.com.)
How to create an Eclipse managed project using Yagarto:
- Select "New->C Project" from the Eclipse "File" menu. A window pops up
in which you can select what kind of project you like to create.
- Select Yagarto toolchain from the right pane (titled "Toolchains")
inside this popup window.
- Select "ARM Cross Target Application->Empty Project" from the left
pane (titled "Project type") inside this window.
- Enter a name into the "Project name" edit box.
- Press "Next" button. The popup window changes to "Select
- You can leave the "Debug" and "Release" configuration selected or
deselect one of them. One step later you can manage configurations in
the project properties window.
- Press the "Finish" button. The popup window closes and the created
project is added to the "Project Explorer" panel. Right now it only
contains Yagarto includes.
- Add your project files by right-clicking on your project name in the
"Project Explorer" panel and selecting "Import". As an exercise you
could choose one of the AT91 examples that come with the softpack. By
the way, "Import" copies the files into your project folder, but you can
also just point to files and / or folders by selecting "New->File" or
"New->Folder" instead of "Import". In the resulting popup window "New
..." press the "Advanced" button. This shows you a checkbox labeled
"Link to the folder / file in the file system" where you can point to
your source folder / files.
- Configure your project by right-clicking on it and selecting
"Properties". A "Properties <project name>" window pops up. I am not
going into all the details but only the ones that relate to the ARM
- Expand "C/C++ Build" in the left pane and select "Settings".
- Under the "Tool Settings" tab above the right frame click on "Target
Processor" and select your target processor from the "Processor"
drop-down list on the right.
- If you are not yet familiar with choosing all the settings go through
every entry ("Debugging", "Additional Tools", etc.) and tabs, try to
understand them, and select them as needed. Important for instance are
include folders ("Directories" entry) and compilation switches
("Preprocessor" entry). The AT91 softpack comes with GNU makefile
examples. You can look at them and choose the Eclipse project settings
according to these make files.
- Finally you are ready to build your project. Select Project->Build
Project from the Eclipse menu. The output of the compiler is displayed
in the Console window usually docked at the bottom of the Eclipse main
window. There you could compare the output of your project managed by
Eclipse with the output generated by a makefile and check whether you
missed any compiler flags or modules.
How to configure the debugger:
- Add the gdb server to the list of external tools: Select Run->External
Tools->External Tools Configurations. Enter an identifying name, the
path and executable filename, and the working directory into the
- Open the "Debug Configurations" window by selecting Run->Debug
- Under the "Main" tab give this debug configuration a name ("Name"),
browse to your project ("Project"), and select the binary ("C/C++
Application"), commonly a .elf file.
- Under the "Debugger" tab enter the gdb executable ("GDB Command"), in
my case C:\yagarto\bin\arm-none-eabi-gdb.exe. "Command Set" is
"Standard". "Protocol Version" is "mi". Check the "Use remote target"
checkbox. "JTAG Device" is "Generic". "Host name or IP address" is
"localhost ". "Port number" for the SAM-ICE is 2331.
- Under the "Startup" tab uncheck all boxes and enter the following
three lines under "Initialization Commands":
The entry in the second line "source..." is what I am using. Atmel
provides such gdb initialization files ("<example
folder>/resources/gdb/*.gdb") with their examples that use the GNU ARM
toolchain. If you like to stop at main instead of at the first startup
instruction enter "continue" under "Run Commands", check the "Set
breakpoint at:" box, and enter "main" in its field.
- Under the "Source" tab make sure that your project configuration is
listed. After you have started a debug session and Eclipse cannot find
the source an incorrect entry might be the cause. To fix this error
delete the old entry and add the correct one by browsing to it.
- The "Common" tab you can leave untouched.
- Press the "Close" button and our Eclipse debugger should be ready to
How to start a debug session:
- Start the GDB server by selecting Run->External Tools-><your gdb
server>. In my case, the Segger gdb server window comes up. Of course
you want to have the ICE and the target connected and powered up at this
- Select Run->Debug and, voila, the debug script in "source ... *.dbg"
should start communicating with the gdb server. The Eclipse console
shows what the debug scripts echoes, in my case how it initializes
DDRAM. This is done after few seconds, and Eclipse switches to the Debug
View allowing you to admire your work.