Avr-studio

Version 9 (Anthony Rowe, 02/02/2008 05:01 pm) → Version 10/16 (Anthony Rowe, 02/02/2008 05:01 pm)


= AVR Studio =

This page talks about debugging the kernel and user functions using the simulator that is built into AVR Studio. AVR Studio® 4 is the professional Integrated Development Environment (IDE) for writing and debugging AVR® applications in Windows® 9x/NT/2000/XP environments. AVR Studio 4 includes an assembler and a simulator.

In order to run Nano-RK inside AVR Studio, you will need version 4.13 build 571 or newer. This can be downloaded for free from the following link: http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725

'''Step 1: Install AVR Studio[[BR]]'''

'''Step 2: Install Service Pack 2[[BR]]'''

'''Step 3: Install Nano-RK and WinAVR on a Windows Machine[[BR]]'''
* This is required so that the source can be correctly linked against the binary file. Using a binary built in linux works except that you will not be able to browse the connected C source, just the assembly (with no comments!).

'''Step 4: Build an elf file[[BR]]'''
* The Nano-RK build system automatically builds the elf file when you run make in a project. To test this, go into a project like basic_tasks and type "make". You should see the following files:
* main.o
* main.d
* main.lst
* main.eep
* main.lss
* You may need to run make twice for this one. It is an extended list file with all assembly code for all functions
* main.sym
* main.map
* main.hex
* '''main.elf'''
* This is the file we need for the simulator!
* You can copy this file to a separate debugging directory if you like...

'''Step 5: Start up AVR Studio[[BR]]'''
* Start-> Programs -> Atmel AVR Tools -> AVR Studio 4

'''Step 6: Load the elf file[[BR]]'''
* Click "Open" and navigate to your .elf file
* On the next screen, save the .aps file in the same directory.
* This file is used to store debugger settings etc

'''Step 7: AVR Simulator Settings[[BR]]'''
* For the Debugging Platform select: AVR Simulator
* For the Device select: ATmega1281
* Press Finish
* make sure you see something like the following in the Messages window:

{{{
Loaded plugin STK500
Loaded partfile: E:\Program Files\Atmel\AVR Tools\PartDescriptionFiles\ATmega1281.xml
AVR Simulator: Please wait while configuring simulator...
AVR Simulator: ATmega1281 Configured OK
Loaded objectfile: E:\Documents and Settings\agr\Desktop\nrk-debug\main.elf
}}}

'''Step 8: Set processor speed [[BR]]'''
* Go Debug Menu -> AVR Simulator Options
* Set Frequency to 8 MHz

----

= Tips =

'''View -> Memory'''
* This lets you look at the various memories on the processor.

'''View -> Watch'''
* This lets you monitor particular variables values in your code.
* Select the variable in your code window and then right click -> Add Watch: "xxx"

'''Setting Breakpoints'''
* You can set break points anywhere in your code (even in sections not currently displayed in the debugger)
* File -> Open File
* Navigate to any source file in Nano-RK
* Once it opens, you can right click -> Toggle Breakpoint
* This will cause the simulator to stop once it reaches that point

'''Dissassembler Window''''
* View -> Disassembler will show the raw assembly
* You can switch back and forth from the C code to the assembly code etc

----

= Trouble? =

If you see the following in the Message Window:
{{{
Coordinator: The object file does not contain source code information.
}}}
You probably did not select the elf file (the hex file will load without source) or you are using an old version AVR Studio.