2.2.2.2 Simulavr + Insight

Unfortunately, AVR Studio 4.08 is not installed at the lab. The older version of AVR Studio has a bug that makes it incompatible with the WinAVR tool set. This is not a mistake on WinAVR's part (or any of its contributors), but on Atmel's part. WinAVR has the necessary tools to create files conforming to Atmel's description of the COFF format, but AVR Studio 3.5x itself does not conform to Atmel's own standard.

Another reason why software source should be open.

Anyway, we can still debug programs without Atmel's simulator. A GPL'd simulator, called simulavr, has been written to provide the backend to simulate the execution of AVR code on practically any platform. This simulator runs with gdb (GNU Debugger) to provide debugging ability.

Let's get familiarized with the necessary components to get this to work:

Now, let's go through the step-by-step procedures to debug a program using this tool chain:

  1. Make sure the program is compiled and linked, see subsection 2.2.2.
  2. Click the Start button, then ``run...'', then type in the following:

    simulavr --gdbserver --device at90s2313
    
    Substitute at90s2313 with whatever target MCU your program is targetted. Selecting the correct target is very important.

    Note that once simulavr runs, it does not exit. It gives you a message like ``Waiting on port 1212 for gdb client to connect...'' if everything is okay. Leave the command line interface alone (minimize it if you don't want to clutter up your screen).

  3. If you install WinAVR, you should see an icon titled ``AVR Insight (WinAVR)'' on the desktop. Run the program.

    If you do not see the desktop icon, go to the folder containing the executable and launch it manually. The full path is usually c:\WinAVR\bin\avr-insight.exe.

  4. In Insight, use ``File | Target Settings'', and select ``GDBServer/TCP'' as the Target, the ``Host'' should be ``localhost'', and the ``Port'' should be set to 1212. For convenience, make sure ``Set breakpoint at `main' '' is checked.

    Click on ``More Options'', and make sure both ``Attach to Target'' and ``Download Program'' are both checked.

    You only need to do this once. Insight saves the options autonatically.

  5. In Insight, use ``File | Open'' and locate demo.elf. Click ``Open''.

  6. In Insight, use ``Run | Download'' to upload the executable. This step should not have been necessary, but it is!

  7. Click the run icon (a running person), the program should start, and the debugger stops on the first statement.

  8. If you see a line highlighted in green, you have successfully launched the debugger!

Copyright © 2006-02-15 by Tak Auyeung