How to debug Nut/OS
  Introduction
  Nut/OS Configurator
  Hardware
  httpd example
  Eclipse
  Trouble shooting
  Back


Introduction

This is a small example which shows how to debug the Nut/OS application
httpd with Eclipse.

It is highly recommended that you completed part 1, part 2 and part 3 of the YAGARTO tutorial, and has installed OpenOCD, YAGARTO and Eclipse.

I will not describe in detail here, how to create an Eclipse project or how to configure the debugger. That was already shown in part 2 and part 3.

For this example I used the following components:

^ top  

Nut/OS Configurator

We want to debug the application in RAM. Therefore you must set the "Platform" to
arm-gccdbg.

And make sure that the linker script is set to at91_ram:

(Click inside the picture to expand)

Then rebuild the build tree and your application, in this order. Your application will no longer run in FLASH.

^ top  

Hardware

For debugging on the Ethernut 3 target, you need a JTAG Debugger Hardware like described here.

Any JTAG adapter for the ARM7TDMI may be used, but the connector layout of the Ethernut 3 is different. You need a selfmade cable adapter or the new Turtelizer 2.0, which comes with a 10-Pin JTAG connector and an additional com port:

And of course an Ethernut 3 or Elektor Internet Radio (EIR):

Ethernut3
Elektor Internet Radio (EIR)

^ top  

httpd example

I made only 3 changes in the source of httpserv.c.

First I changed MYIP from 192.168.192.35 to an address in my network, and comment out USE_DHCP and USE_DISCOVERY.

(I don't have DHCP, and I don't want to wait)

A new makefile was created, too. Here you must adapt only NUTINCDIR, NUTLIBDIR and LDSCRIPT to your requirements.

Ethernut 3 httpd example (NutOS 4.9.10) for debugging in RAM only.

Elektor Internet Radio (EIR) httpd example (NutOS 4.9.10) for RAM and Flash.

Elektor Internet Radio (EIR) webradio (NutOS 4.9.10) for RAM and Flash.

After you have download the example, take a look in the makefile.
(Do not forget to change the NUTINCDIR, NUTLIBDIR and LDSCRIPT values)

^ top  

Eclipse

I hope you completed part 3 successfully. The following will demonstrate a fast way.

Download the httpd example and expand the zip file to your temp directory.
I expanded it in the following directory:

C:\temp\httpd

For the next steps I will refer to it. Now you can start Eclipse.
(Do not forget to change the NUTINCDIR, NUTLIBDIR and LDSCRIPT values)

To create an Eclipse project use "File / New / Standard Make C Project". For the project name use "httpd".

Now use "Project / Properties" select "C/C++ Make Project" and change the "Compiler invocation command", on the "Discovery Options" tab, to your compiler executable arm-none-eabi-gcc.exe. Press "OK" to finish this dialog.

Your project is empty, and you must import the project files to Eclipse.
Use the "File / Import..." menu and select the "File System" as input source. You will find the "File System" under "General".

Browse to your temp directory C:\temp\httpd and select all files with the checkmark, press "Finish" to close the dialog.

For more information on how to create a project, take a look at part 3.

You can build your project with "Project / Build Project" now, the result of the build process will be displayed in the "Console" window. A file httpserv.elf should be created.

Change to the "Debug Perspective" and configure the debugger.

(Click inside the picture to expand)

For the "Initialization Commands" copy and paste the contents of the eclipse_ram.gdb text file into the window. The eclipse_ram.gdb file is part of the example (.\prj\eclispe_ram.gdb).

For more information on how to configure the debugger, take a look at part 3.


Note for OpenOCD 0.4.0-rc1: Before you can start with the debug session, you must update the OpenOCD installation. Therefore copy the content of the turtelizer2-update folder into the folder where you have installed the OpenOCD installation.


We may start OpenOCD now, open a command line window. On Windows change to <install-dir>/nut/tools/turtelizer2. Replace <install-dir> with the name of the folder you selected during OpenOCD installation. Make sure, that <install-dir>/nut/tools/win32 is in your path.

If you are using the Turtelizer 2.0 type:

openocd -f interface/turtelizer2.cfg -f ethernut3.cfg

This command prompt is now blocked with the OpenOCD debugger, and we may go back to Eclipse.

The debugger is configured, and OpenOCD is running. You may start your debug session now, which could look like:

(Click inside the picture to expand)

Hint: You can set the PC back to 0 by the "monitor soft_reset_halt" command in the "Console" window. Now the program can be started with "continue" without to loading again.

^ top  

Trouble shooting

In case Eclipse refuse to download the code to the target (seems like something is blocked), take the following steps:

  1. Close Eclipse
  2. Stop OpenOCD
  3. Reset Ethernut 3
  4. Start OpenOCD again
  5. Start Eclipse again

Now debugging should be possible.

^ top  


Creative Commons-Lizenz The tutorial on this site is licensed under a Creative Commons Attribution 2.5 License and is copyright (C) 2006 by me, Michael Fischer.