<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Hardware%2FEIR%2FDebugging</id>
		<title>Hardware/EIR/Debugging - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Hardware%2FEIR%2FDebugging"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hardware/EIR/Debugging&amp;action=history"/>
		<updated>2026-05-23T06:21:47Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Hardware/EIR/Debugging&amp;diff=388&amp;oldid=prev</id>
		<title>Harald: Created page with &quot;&lt;div id=&quot;content&quot;&gt;  = Elektor Internet Radio Source Code Debugging =  This document explains how to setup Eclipse and [http://openocd.sourceforge.net/ OpenOCD] to allow source...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hardware/EIR/Debugging&amp;diff=388&amp;oldid=prev"/>
				<updated>2017-07-13T08:57:12Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;  = Elektor Internet Radio Source Code Debugging =  This document explains how to setup Eclipse and [http://openocd.sourceforge.net/ OpenOCD] to allow source...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Elektor Internet Radio Source Code Debugging =&lt;br /&gt;
&lt;br /&gt;
This document explains how to setup Eclipse and [http://openocd.sourceforge.net/ OpenOCD] to allow source code debugging of Nut/OS applications running on Elektor Internet Radio. It is assumed, that you are already familiar with creating Nut/OS applications. The [[../../pdf/enswm28e.pdf|Nut/OS Software Manual]] describes the required steps.&lt;br /&gt;
&lt;br /&gt;
This document has been originally written for Nut/OS 4.9 beta. Additional comments had been included later to cover Nut/OS 4.10.&lt;br /&gt;
&lt;br /&gt;
Note, that you don't need to use Eclipse to create your own Nut/OS applications. You favorite text editor is just fine to create the source code and building your application can be done on the command line.&lt;br /&gt;
&lt;br /&gt;
The same is true for debugging. There are a number of alternative tools available, like GDB for the command line purists or Insight, which provides a GUI for GDB. Actually, Eclipse uses GDB too, but provides a nicely integrated user interface for editing, compiling, uploading and debugging Nut/OS applications. While based on Java, it is available on all major platforms.&lt;br /&gt;
&lt;br /&gt;
One last word before you move on: If you got here, because you assume that either your application or any of the Nut/OS libraries contains a bug, you should carefully think about, whether source code debugging will really help. Multithreaded network applications often fail because of timing problems or racing conditions. Setting breakpoints and inspecting variables will seldom help to find such bugs. What you need is some sort of ''tracing''. In its most simple form, you can use the devDebug device to let your program output additional information on the serial port while running. In almost the same way you can use [http://www.ethernut.de/nutwiki/Sending_syslog_Messages syslog]. A similar situation may occur, when parts of memory are overwritten by bad pointers or buffer overflows. You should consider other debugging methods provided by Nut/OS, which are explained in the chapter ''Error Handling'' of the Nut/OS Software Manual.&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
This is a short listing only. For Details please refer to the related manuals.&lt;br /&gt;
&lt;br /&gt;
=== Required Hardware ===&lt;br /&gt;
&lt;br /&gt;
* Elektor Internet Radio Board&lt;br /&gt;
* Turtelizer 2 JTAG Dongle&lt;br /&gt;
* JTAG Connector Adapter&lt;br /&gt;
* PC with USB and RS-232 port&lt;br /&gt;
* 12V Power Supply&lt;br /&gt;
* RS-232 DB9 Null Modem Cable&lt;br /&gt;
* USB A/B Cable&lt;br /&gt;
&lt;br /&gt;
The first 2 items you can build yourself, using the Eagle 4.11 CAD files for [[../../../arc/eir10c.zip|Elektor Internet Radio]] and [[../../../arc/turtle20b.zip|Tutelizer 2.0]]. Readily built and tested devices are available at [http://www.egnite.de/en/egnite-shop.html www.egnite.de/en/egnite-shop.html] and from several [http://www.egnite.de/en/ueber-uns/distributoren.html distributors].&lt;br /&gt;
&lt;br /&gt;
=== Required Software (Windows) ===&lt;br /&gt;
&lt;br /&gt;
The following software needs to be installed on the Windows PC:&lt;br /&gt;
&lt;br /&gt;
* Windows XP or later&lt;br /&gt;
* Java Runtime Environment 1.6 or later&lt;br /&gt;
* Eclipse Platform Runtime Binary 3.6.2 (Helios)&lt;br /&gt;
* Eclipse CDT 7.0.2&lt;br /&gt;
* TeraTerm or similar Terminal Emulator&lt;br /&gt;
* Nut/OS 4.10&lt;br /&gt;
* Turtelizer OpenOCD Package&lt;br /&gt;
* Turtelizer FTDI Driver&lt;br /&gt;
&lt;br /&gt;
You can download the Java Runtime at [http://www.oracle.com/technetwork/java/javase/downloads/ www.oracle.com/technetwork/java/javase/downloads].&lt;br /&gt;
&lt;br /&gt;
Eclipse is available at [http://download.eclipse.org/eclipse/downloads/ download.eclipse.org/eclipse/downloads] and the CDT can be found at [http://www.eclipse.org/cdt/ www.eclipse.org/cdt]. Remember to install the Platform Runtime Binary. You may try Eclipse IDE for C/C++ Developers, which includes the CDT, but this version is not covered here.&lt;br /&gt;
&lt;br /&gt;
TeraTerm can be downloaded at [http://ttssh2.sourceforge.jp/ ttssh2.sourceforge.jp].&lt;br /&gt;
&lt;br /&gt;
The last 3 items are available at our [[../download/|download page]].&lt;br /&gt;
&lt;br /&gt;
Installation details can be found in the documents that come with the specific product.&lt;br /&gt;
&lt;br /&gt;
=== Required Software (Ubuntu) ===&lt;br /&gt;
&lt;br /&gt;
The following software needs to be installed on the Linux PC (tested with Ubuntu 10.10):&lt;br /&gt;
&lt;br /&gt;
* Java Runtime Environment 1.6 or later&lt;br /&gt;
* Eclipse Platform Runtime Binary 3.7 (Helios)&lt;br /&gt;
* Eclipse CDT 7.0.2&lt;br /&gt;
* minicom or other Terminal Emulator&lt;br /&gt;
* gcc-arm-elf&lt;br /&gt;
* Nut/OS 4.10&lt;br /&gt;
* Turtelizer OpenOCD Package&lt;br /&gt;
&lt;br /&gt;
You can install the Java Runtime Environment, minicom and openocd with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;apt-get install default-jre minicom openocd&amp;lt;/pre&amp;gt;&lt;br /&gt;
Eclipse is available at [http://download.eclipse.org/eclipse/downloads/ download.eclipse.org/eclipse/downloads] and the CDT can be found at [http://www.eclipse.org/cdt/ www.eclipse.org/cdt] Remember to install the Platform Runtime Binary. You may try Eclipse IDE for C/C++ Developers, which includes the CDT, but this version is not covered here. Also the eclipse package of Ubuntu doesn't work.&lt;br /&gt;
&lt;br /&gt;
Installation details can be found in the documents that come with the specific product.&lt;br /&gt;
&lt;br /&gt;
== Configuring Nut/OS ==&lt;br /&gt;
&lt;br /&gt;
When using the latest YAGARTO distribution, you must be aware of a significant change. While earlier releases used arm-elf-gcc, YAGARTO is now using arm-none-eabi-gcc. While Nut/OS 4.10 should work with this environment out of the box, Nut/OS 4.9 has been prepared to make this switch easy. Open the file ''nut/Makevars.arm-gcc'' with your text editor. Locate the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;#TRGT = arm-none-eabi-&amp;lt;/pre&amp;gt;&lt;br /&gt;
and remove the leading numero sign:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;TRGT = arm-none-eabi-&amp;lt;/pre&amp;gt;&lt;br /&gt;
Save your changes.&lt;br /&gt;
&lt;br /&gt;
In order to include debugging information in the compiled binaries you need to switch from arm-gcc to arm-gccdbg. When done, rebuild Nut/OS and recreate the application directory. The following steps will give detailed instructions.&lt;br /&gt;
&lt;br /&gt;
The screenshots were taken while running the wxWidgets version of the Nut/OS Configurator. In Nut/OS 4.10, this tool had been replaced by Qt based version. Thus, the images will slightly differ from your screen output.&lt;br /&gt;
&lt;br /&gt;
[[ccd01.png|[[File:381px-ccd01.png]]]]&lt;br /&gt;
When started for the first time, the Nut/OS Configurator will display a file selection dialog. If this is hidden by the splash window, simply click on that window to close it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd02.png|[[File:381px-ccd02.png]]]]&lt;br /&gt;
Select the file eir10c.cfg and click on ''Open''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd03.png|[[File:389px-ccd03.png]]]]&lt;br /&gt;
The Configurators main window will show the ''Nut/OS Components'' in a tree structure on the right side.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd04.png|[[File:389px-ccd04.png]]]]&lt;br /&gt;
From the ''Edit'' menu select ''Settings...''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd05.png|[[File:208px-ccd05.png]]]]&lt;br /&gt;
Nothing needs to be changed on the ''Repository'' page of the settings dialog. You may check ''Enable multiple configurations'' if you are concurrently working with different target boards.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd06.png|[[File:215px-ccd06.png]]]]&lt;br /&gt;
Select ''arm-gccdbg'' as the platform on the ''Build'' page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd07.png|[[File:215px-ccd07.png]]]]&lt;br /&gt;
On the ''Tools'' page you need to enter the path to all required tools, separated by semicolons. For the EIR board this should point to the Nut/OS win32 tools directory and the YAGARTO bin directory. While all other settings use normal slashes in paths, here we must use backslashes. If you are using Linux and the compiler is in a standard path, you don't need to insert a path here.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd08.png|[[File:215px-ccd08.png]]]]&lt;br /&gt;
On the last page titled ''Samples'' you may select ''arm-oocd'' as the programmer of choice, but this is only required for programming the flash memory, not for debugging in RAM.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd09.png|[[File:389px-ccd09.png]]]]&lt;br /&gt;
Before building the system, change the ''Linker Script'' in the components tree under ''Tools/GCC Settings'' to ''at91sam7se512_ram''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd10.png|[[File:389px-ccd10.png]]]]&lt;br /&gt;
We are using YAGARTO with Newlib 1.19. Make sure that ''Posix compatible unsetenv'' is checked under ''C runtime (target specific)/Environment''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Nut-OS_Configurator-Non-BSD.png|[[File:389px-Nut-OS_Configurator-Non-BSD.png]]]]&lt;br /&gt;
Under Linux you may need to disable Non-DSDL Code/RealNetworks RPSL/RCSL.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Nut/OS 4.9.10 contains 2 bugs, which let debugging in RAM fail for AT91SAM7SE targets. The first one is with the linker script at91sam7se512_ram.ld in directory nut\arch\arm\ldscripts. You can use a simple text editor like Notepad to fix this.&lt;br /&gt;
&lt;br /&gt;
Near the beginning of the file remove the line .&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;rom(rx)  : org = 0x00000000, len = 496k&amp;lt;/pre&amp;gt;&lt;br /&gt;
and change the value 0x00200000 in line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;iram(rw) : org = 0x00200000, len = 32k&amp;lt;/pre&amp;gt;&lt;br /&gt;
to 0x00000000, resulting in&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;iram(rw) : org = 0x00000000, len = 32k&amp;lt;/pre&amp;gt;&lt;br /&gt;
Somewhere in the middle you will find the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;.data : AT (__etext)&amp;lt;/pre&amp;gt;&lt;br /&gt;
which needs to be replaced by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;.data :&amp;lt;/pre&amp;gt;&lt;br /&gt;
The second bug is in the file crtat91sam7se512_ram.S in directory nut\arch\arm\init. Again use your favorite text editor to remove the following part:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;/*&lt;br /&gt;
 * Remapping memory, SRAM to 0x00000000&lt;br /&gt;
 */&lt;br /&gt;
ldr     r1, =MC_BASE&lt;br /&gt;
mov     r0, #01&lt;br /&gt;
str     r0, [r1, #MC_RCR_OFF]&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Use 2 cycles for flash access.&lt;br /&gt;
 */&lt;br /&gt;
ldr     r1, =MC_BASE&lt;br /&gt;
mov     r0, #MC_FWS_2R3W&lt;br /&gt;
str     r0, [r1, #MC_FMR_OFF]&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then remove all lines starting from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;/*&lt;br /&gt;
 * The watchdog is enabled after processor reset. Disable it.&lt;br /&gt;
 */&lt;br /&gt;
ldr     r1, =WDT_BASE&lt;br /&gt;
ldr     r0, =WDT_WDDIS&lt;br /&gt;
str     r0, [r1, #WDT_MR_OFF] :&amp;lt;/pre&amp;gt;&lt;br /&gt;
up to and including&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;        /*&lt;br /&gt;
         * Switch to PLL clock.&lt;br /&gt;
         */&lt;br /&gt;
        ldr     r0, [r1, #PMC_MCKR_OFF]&lt;br /&gt;
        orr     r0, r0, #PMC_CSS_PLL_CLK&lt;br /&gt;
        str     r0, [r1, #PMC_MCKR_OFF]&lt;br /&gt;
wait_pllsel:&lt;br /&gt;
        ldr     r0, [r1, #PMC_SR_OFF]&lt;br /&gt;
        tst     r0, #PMC_MCKRDY&lt;br /&gt;
        beq     wait_pllsel&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally remove this part:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;        /*&lt;br /&gt;
         * Relocate .data section (Copy from ROM to RAM).&lt;br /&gt;
         */&lt;br /&gt;
        ldr     r1, =__etext&lt;br /&gt;
        ldr     r2, =__data_start&lt;br /&gt;
        ldr     r3, =__data_end&lt;br /&gt;
&lt;br /&gt;
_41:&lt;br /&gt;
        cmp     r2, r3&lt;br /&gt;
        ldrlo   r0, [r1], #4&lt;br /&gt;
        strlo   r0, [r2], #4&lt;br /&gt;
        blo     _41&amp;lt;/pre&amp;gt;&lt;br /&gt;
Save your changes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd11.png|[[File:389px-ccd11.png]]]]&lt;br /&gt;
Now we are ready to build Nut/OS for debugging. Select ''Build Nut/OS'' in the ''Build'' menu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd12.png|[[File:176px-ccd12.png]]]]&lt;br /&gt;
A message box shows the settings for creating the build directory. Verify them and click ''OK'' to build this directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd13.png|[[File:183px-ccd13.png]]]]&lt;br /&gt;
A second message box shows the settings for building the system. Again verify them and click ''OK''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd14.png|[[File:381px-ccd14.png]]]]&lt;br /&gt;
The build may take a few minutes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd15.png|[[File:389px-ccd15.png]]]]&lt;br /&gt;
When done, make sure that it has been terminated successfully.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd16.png|[[File:389px-ccd16.png]]]]&lt;br /&gt;
Nut/OS uses a separate directory for the application code. A template can be created by selecting ''Create Sample Directory'', containing all Nut/OS samples that are included in the distribution. Remember, that we will use the events sample.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd17.png|[[File:214px-ccd17.png]]]]&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
When runnign the wxWidget based Configurator, a message box will show the current settings. Click ''OK'', if everything looks as expected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd18.png|[[File:389px-ccd18.png]]]]&lt;br /&gt;
When done, you may exit the Configurator by selecting ''Exit'' in the ''File'' menu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[ccd19.png|[[File:207px-ccd19.png]]]]&lt;br /&gt;
Because we changed at least the linker script, the Configurator asks, whether to save these changes. In order to preserve the original settings, you may simply click No. Alternatively you can select Yes and choose a different filename like eir10c-debug.cfg in the following file selection dialog.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Configuring Eclipse ==&lt;br /&gt;
&lt;br /&gt;
It is assumed that you successfully installed Eclipse and the CDT plug-in. For a first demonstration we will use the events sample that is included in the Nut/OS distribution.&lt;br /&gt;
&lt;br /&gt;
[[scd01.png|[[File:330px-scd01.png]]]]&lt;br /&gt;
When started, Eclipse will ask for the Workspace Path. Choose the Nut/OS sample directory, e.g. C:\Ethernut-4.10\nutapp or ~/ethernut-4.9.10/nutapp under Linux.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd02.png|[[File:431px-scd02.png]]]]&lt;br /&gt;
The welcome page appears. Click on ''Workbench'' in the upper right corner.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd03.png|[[File:431px-scd03.png]]]]&lt;br /&gt;
The so called Java Perspective appears. We will later change to the C Perspective.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd04.png|[[File:431px-scd04.png]]]]&lt;br /&gt;
In the ''File'' menu select ''New'' and ''Project...''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd05.png|[[File:278px-scd05.png]]]]&lt;br /&gt;
In the ''New Project'' dialog choose ''C Project'' and click on ''Next''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd06.png|[[File:278px-scd06.png]]]]&lt;br /&gt;
In the ''C Project'' dialog enter ''events'' for the project name. Then choose ''Empty Project'' and ''-- Other Toolchain --''. Again click on ''Next''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd07.png|[[File:278px-scd07.png]]]]&lt;br /&gt;
On the next page click on ''Advanced settings...''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd08.png|[[File:437px-scd08.png]]]]&lt;br /&gt;
In the ''Project Properties'' page select ''Settings'' and check ''GNU Elf Parser''. Then click on ''OK''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd09.png|[[File:298px-scd09.png]]]]&lt;br /&gt;
Back in the ''C Project'' dialog click ''Finish''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd11.png|[[File:281px-scd11.png]]]]&lt;br /&gt;
Click ''Yes'' to open the C/C++ perspective.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd12.png|[[File:484px-scd12.png]]]]&lt;br /&gt;
We do not need the ''Java'' Perspective, therefore you should close it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd13.png|[[File:441px-scd13.png]]]]&lt;br /&gt;
Uncheck ''Build Automatically'' in the ''Project'' menu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd13.1.png|[[File:441px-scd13.1.png]]]]&lt;br /&gt;
In the same menu select ''Properties''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd13.2.png|[[File:524px-scd13.2.png]]]]&lt;br /&gt;
In the ''Properties'' dialog select ''Environment'' in the tree on the right. Then click ''Add''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd13.3.png|[[File:343px-scd13.3.png]]]]&lt;br /&gt;
The variable ''Name'' must be &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;. You need to enter the path to all required tools as the ''Value'', separated by semicolons. The first path should point to the Nut/OS win32 tools directory and the second one to the YAGARTO bin directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd13.4.png|[[File:524px-scd13.4.png]]]]&lt;br /&gt;
Click ''OK'' to store the updated Environment.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd14.png|[[File:441px-scd14.png]]]]&lt;br /&gt;
Then, in the same menu, select ''Build Project''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd15.png|[[File:434px-scd15.png]]]]&lt;br /&gt;
Building this simple application requires a few seconds only.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When done, the newly created files appear in the ''Project Explorer''. The file ''events.elf'' contains the executable binary including all debug information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging the Application ==&lt;br /&gt;
&lt;br /&gt;
[[scd16.png|[[File:451px-scd16.png]]]]&lt;br /&gt;
Click on the ''Open Perspective'' button [[File:30px-b02.png]] and select ''Debug''. This will open the ''Debug Perspective''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd17.png|[[File:441px-scd17.png]]]]&lt;br /&gt;
Click on the tiny arrow near the bug [[File:26px-b01.png]] in the toolbar to open the related menu. Then select ''Debug Configuration...''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd18.png|[[File:314px-scd18.png]]]]&lt;br /&gt;
In the ''Debug Configurations'' dialog select ''GDB Hardware Debugging'' and click on the ''New'' button.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd19.png|[[File:384px-scd19.png]]]]&lt;br /&gt;
Enter &amp;lt;code&amp;gt;EIR Debugging&amp;lt;/code&amp;gt; as the configuration name and &amp;lt;code&amp;gt;events&amp;lt;/code&amp;gt; as the project name. Next click on ''Search Project...''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd20.png|[[File:195px-scd20.png]]]]&lt;br /&gt;
Select ''events.elf'' and click ''OK''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd22.png|[[File:357px-scd22.png]]]]&lt;br /&gt;
Back in the ''Debug Configurations'' dialog click on ''Select other''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd21.png|[[File:240px-scd21.png]]]]&lt;br /&gt;
Choose ''Standard GDB Hardware Debugging Launcher'' as the preferred launcher and click ''OK''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd21.1.png|[[File:402px-scd21.1.png]]]]&lt;br /&gt;
Back in the ''Debug Configurations'' dialog click on the ''Debugger'' tab and enter &amp;lt;code&amp;gt;arm-none-eabi-gdb&amp;lt;/code&amp;gt; in ''GDB Command''. Although we will use remote target debugging, ''Use remote target'' must be unchecked here.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd21.2.png|[[File:402px-scd21.2.png]]]]&lt;br /&gt;
Now click on the ''Startup'' tab. ''Set breakpoint at'' and ''Resume'' must be checked. Enter &amp;lt;code&amp;gt;NutInit&amp;lt;/code&amp;gt; as the breakpoint target.&lt;br /&gt;
&lt;br /&gt;
Then copy and paste the following commands into the field ''Initialization Commands''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;target remote localhost:3333&lt;br /&gt;
monitor jtag_khz 30&lt;br /&gt;
monitor reset&lt;br /&gt;
monitor sleep 500&lt;br /&gt;
monitor poll&lt;br /&gt;
monitor soft_reset_halt&lt;br /&gt;
monitor gdb_breakpoint_override soft&lt;br /&gt;
monitor mww 0xfffff130 0xffffffff&lt;br /&gt;
monitor mww 0xfffff124 0xffffffff&lt;br /&gt;
monitor mww 0xfffffd44 0x00008000&lt;br /&gt;
monitor mww 0xffffff00 0x00000001&lt;br /&gt;
monitor mww 0xFFFFFC20 0x00000601&lt;br /&gt;
monitor sleep 10&lt;br /&gt;
monitor mww 0xFFFFFC2C 0x00481c0e&lt;br /&gt;
monitor sleep 10&lt;br /&gt;
monitor mww 0xFFFFFC30 0x00000004&lt;br /&gt;
monitor sleep 10&lt;br /&gt;
monitor mww 0xFFFFFC30 0x00000007&lt;br /&gt;
monitor sleep 10&lt;br /&gt;
monitor mww 0xfffff474 0x3f800000&lt;br /&gt;
monitor mww 0xfffff404 0x3f800000&lt;br /&gt;
monitor mww 0xfffff674 0x0003effd&lt;br /&gt;
monitor mww 0xfffff604 0x0003effd&lt;br /&gt;
monitor mww 0xfffff870 0x0000ffff&lt;br /&gt;
monitor mww 0xfffff804 0x0000ffff&lt;br /&gt;
monitor mww 0xffffff80 0x00000002&lt;br /&gt;
monitor mww 0xffffffb8 0x2192215a&lt;br /&gt;
monitor sleep 10&lt;br /&gt;
monitor mww 0xffffffb0 0x00000011&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000012&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000014&lt;br /&gt;
monitor mww 0x20000000 0x00000000&lt;br /&gt;
monitor mww 0xffffffb0 0x00000013&lt;br /&gt;
monitor mww 0x20000014 0xcafedede&lt;br /&gt;
monitor mww 0xffffffb4 0x00000013&lt;br /&gt;
monitor mww 0xffffffb0 0x00000010&lt;br /&gt;
monitor mww 0x20000000 0x00000180&lt;br /&gt;
monitor jtag_khz 12000&lt;br /&gt;
set mem inaccessible-by-default off&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd22.1.png|[[File:357px-scd22.1.png]]]]&lt;br /&gt;
Finally click ''Apply'' to store the settings and ''Close'' to close the dialog.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd23.png|[[File:441px-scd23.png]]]]&lt;br /&gt;
Once again click on the tiny arrow near the bug to open the menu and select ''Organize Favorites...''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd24.png|[[File:190px-scd24.png]]]]&lt;br /&gt;
Click ''Add''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd25.png|[[File:170px-scd25.png]]]]&lt;br /&gt;
Check ''EIR Debugging'' and click ''OK''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd26.png|[[File:190px-scd26.png]]]]&lt;br /&gt;
In the previous dialog click ''OK'' again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will now setup the hardware, using the following steps:&lt;br /&gt;
&lt;br /&gt;
* Connect the Turtelizer's JTAG port to the JTAG Connector board's 10-pin connector.&lt;br /&gt;
* Connect the JTAG port of the EIR to the JTAG Connector board's 20-pin connector.&lt;br /&gt;
* Attach the power supply to the EIR and switch it on. The red LED on the EIR should go on.&lt;br /&gt;
* Connect the Turtelizer's USB port to the PC using the USB A/B cable.&lt;br /&gt;
&lt;br /&gt;
[[EIR-JTAG-TURT.png|[[File:480px-EIR-JTAG-TURT.png]]]]&lt;br /&gt;
If the Turtelizer is used for the first time, it will be required to install the FTDI driver. For more details please refer to the Turtelizer's documentation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next we will start OpenOCD. We could do this within Eclipse, but for the first time it makes sense to start it manually to check the output in case of problems.&lt;br /&gt;
&lt;br /&gt;
[[scd26.1.png|[[File:438px-scd26.1.png]]]]&lt;br /&gt;
Now open a command line and change to directory &amp;lt;code&amp;gt;C:\Ethernut-4.10\nut\tools\turtelizer2&amp;lt;/code&amp;gt;. Add the Nut/OS tools directory for Windows to your path, using the following command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;set PATH=C:\ethernut-4.10\nut\tools\win32;%PATH%&amp;lt;/pre&amp;gt;&lt;br /&gt;
Yout don't need to set the path under Linux. Then start OpenOCD using&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;openocd -f board/eir.cfg -f interface/turtelizer2.cfg&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd27.2.png|[[File:250px-scd27.2.png]]]]&lt;br /&gt;
The ''events'' sample will create some output on the RS-232. To make it visible, we start a ''terminal emulator''. On Windows PCs we could use ''HyperTerminal'', but ''TeraTerm'' is the preferred one. After ''TeraTerm'' started, select ''Serial port...'' from the ''Setup'' menu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd27.1.png|[[File:213px-scd27.1.png]]]]&lt;br /&gt;
Select the COM port to which the Ethernut board is connected. Configure the port to 8 data bits, no parity, 1 stop bit and no flow control and click on ''OK''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Bildschirmfoto-Terminal-minicom.png|[[File:300px-Bildschirmfoto-Terminal-minicom.png]]]]&lt;br /&gt;
Under Linux you can use the following command on a terminal to start minicom:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;minicom -D /dev/ttyUSB0 -b 115200&amp;lt;/pre&amp;gt;&lt;br /&gt;
You need to replace /dev/ttyUSB0 with the correct device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's get back to ''Eclipse''. Remember that we specified a breakpoint at &amp;lt;code&amp;gt;NutInit&amp;lt;/code&amp;gt; in the debugger configuration. For some unknown reason the debugger fails, if this is not defined. However, the function NutInit is located in the initialization of Nut/OS, while you will be mostly interested in debugging your application code.&lt;br /&gt;
&lt;br /&gt;
[[scd26.2.png|[[File:441px-scd26.2.png]]]]&lt;br /&gt;
Lets specify a second breakpoint at the beginning of the application code, which is the function main. Click on the tab ''C/C++'' in the upper right corner to change to the C Perspective.&lt;br /&gt;
&lt;br /&gt;
In the ''Project Explorer'' double click on the events folder to expand it. Then click on the tiny arrow in front of ''events.c'' to expand this part of the tree. Note, that this arrow will appear only when moving the mouse over the ''Project Explorer'' window.&lt;br /&gt;
&lt;br /&gt;
Now double click on ''main(void)'' to open the source file at this location.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd26.3.png|[[File:441px-scd26.3.png]]]]&lt;br /&gt;
At the first line click with the right mouse button on blue border to open the context menu. Select ''Toggle Breakpoint''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd27.png|[[File:441px-scd27.png]]]]&lt;br /&gt;
Switch back to the debug perspective by clicking on the tab ''Debug'' in the upper right corner. Click on the bug button in the toolbar to start debugging.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd28.png|[[File:441px-scd28.png]]]]&lt;br /&gt;
The code will be downloaded to the target and started. Then it stops at the first breakpoint at the beginning of NutInit. Press ''F8'' or click the ''Resume'' button [[File:30px-b03.png]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd29.png|[[File:441px-scd29.png]]]]&lt;br /&gt;
The target code will run up to the next breakpoint in main. You can now press ''F5'' or click the button [[File:30px-b04.png]] to step execute a single line, ''F6'' or click the button [[File:30px-b05.png]] to step over a function call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd29.2.png|[[File:439px-scd29.2.png]]]]&lt;br /&gt;
Now continue pressing ''F6'' until we stepped over the first &amp;lt;code&amp;gt;puts()&amp;lt;/code&amp;gt; function call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd29.1.png|[[File:226px-scd29.1.png]]]]&lt;br /&gt;
When this statement has been executed, the text &amp;lt;code&amp;gt;Nut/OS Event Queue Demo&amp;lt;/code&amp;gt; should appear in the terminal emulator window.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd29.4.png|[[File:439px-scd29.4.png]]]]&lt;br /&gt;
As you continue stepping through the main loop...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[scd29.3.png|[[File:226px-scd29.3.png]]]]&lt;br /&gt;
...additional output appears on the serial port.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may set additional breakpoints, evaluate variables or memory areas and do many other useful things during debugging. Please refer to the Eclipse documentation for further details.&lt;br /&gt;
&lt;br /&gt;
Under Linux an Error occures in the output of openocd, when debugging:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;Error: address + size wrapped(0xfffffffe, 0x00000004)&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>