Avr-studio

Version 13 (Anthony Rowe, 02/02/2008 05:07 pm)

1 1 Anthony Rowe
2 1 Anthony Rowe
= AVR Studio =
3 1 Anthony Rowe
4 1 Anthony Rowe
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.
5 1 Anthony Rowe
6 12 Anthony Rowe
AVR Studio is good for debugging execution of complicated C algorithms, or debugging memory problems.  It is not good for simulating network interactions or multiple nodes communicating.  For that you need a network wide simulation environment.
7 12 Anthony Rowe
8 2 Anthony Rowe
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
9 2 Anthony Rowe
10 2 Anthony Rowe
'''Step 1:  Install AVR Studio[[BR]]'''
11 2 Anthony Rowe
12 2 Anthony Rowe
'''Step 2:  Install Service Pack 2[[BR]]'''
13 2 Anthony Rowe
14 2 Anthony Rowe
'''Step 3:  Install Nano-RK and WinAVR on a Windows Machine[[BR]]'''
15 3 Anthony Rowe
 * 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!).
16 3 Anthony Rowe
17 3 Anthony Rowe
'''Step 4:  Build an elf file[[BR]]'''
18 3 Anthony Rowe
 * 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:
19 3 Anthony Rowe
  * main.o
20 3 Anthony Rowe
  * main.d
21 3 Anthony Rowe
  * main.lst
22 3 Anthony Rowe
  * main.eep
23 4 Anthony Rowe
  * main.lss  
24 4 Anthony Rowe
   * You may need to run make twice for this one.  It is an extended list file with all assembly code for all functions
25 3 Anthony Rowe
  * main.sym
26 1 Anthony Rowe
  * main.map
27 1 Anthony Rowe
  * main.hex
28 4 Anthony Rowe
  * '''main.elf'''  
29 4 Anthony Rowe
   * This is the file we need for the simulator!
30 5 Anthony Rowe
   * You can copy this file to a separate debugging directory if you like...
31 5 Anthony Rowe
32 5 Anthony Rowe
'''Step 5:  Start up AVR Studio[[BR]]'''
33 5 Anthony Rowe
 * Start-> Programs -> Atmel AVR Tools -> AVR Studio 4
34 5 Anthony Rowe
35 5 Anthony Rowe
'''Step 6: Load the elf file[[BR]]'''
36 5 Anthony Rowe
 * Click "Open" and navigate to your .elf file
37 5 Anthony Rowe
 * On the next screen, save the .aps file in the same directory. 
38 5 Anthony Rowe
  * This file is used to store debugger settings etc
39 5 Anthony Rowe
40 5 Anthony Rowe
'''Step 7: AVR Simulator Settings[[BR]]'''
41 5 Anthony Rowe
 * For the Debugging Platform select: AVR Simulator
42 5 Anthony Rowe
 * For the Device select: ATmega1281
43 6 Anthony Rowe
 * Press Finish
44 6 Anthony Rowe
 * make sure you see something like the following in the Messages window:
45 1 Anthony Rowe
46 6 Anthony Rowe
{{{
47 6 Anthony Rowe
Loaded plugin STK500
48 6 Anthony Rowe
Loaded partfile: E:\Program Files\Atmel\AVR Tools\PartDescriptionFiles\ATmega1281.xml
49 6 Anthony Rowe
AVR Simulator: Please wait while configuring simulator...
50 6 Anthony Rowe
AVR Simulator: ATmega1281 Configured OK
51 6 Anthony Rowe
Loaded objectfile: E:\Documents and Settings\agr\Desktop\nrk-debug\main.elf
52 6 Anthony Rowe
}}}
53 6 Anthony Rowe
54 6 Anthony Rowe
55 6 Anthony Rowe
56 6 Anthony Rowe
'''Step 8: Set processor speed [[BR]]'''
57 1 Anthony Rowe
 * Go Debug Menu -> AVR Simulator Options
58 1 Anthony Rowe
 * Set Frequency to 8 MHz
59 6 Anthony Rowe
60 7 Anthony Rowe
----
61 7 Anthony Rowe
62 7 Anthony Rowe
= Tips =
63 7 Anthony Rowe
64 8 Anthony Rowe
'''View -> Memory'''
65 7 Anthony Rowe
 * This lets you look at the various memories on the processor.
66 7 Anthony Rowe
67 8 Anthony Rowe
'''View -> Watch'''
68 10 Anthony Rowe
 * This lets you monitor particular variables in your code.
69 7 Anthony Rowe
 * Select the variable in your code window and then right click -> Add Watch: "xxx"
70 7 Anthony Rowe
71 8 Anthony Rowe
'''Setting Breakpoints'''
72 7 Anthony Rowe
 * You can set break points anywhere in your code (even in sections not currently displayed in the debugger)
73 7 Anthony Rowe
 * File -> Open File
74 7 Anthony Rowe
  * Navigate to any source file in Nano-RK
75 7 Anthony Rowe
  * Once it opens, you can right click -> Toggle Breakpoint
76 7 Anthony Rowe
  * This will cause the simulator to stop once it reaches that point
77 7 Anthony Rowe
78 11 Anthony Rowe
'''Dissassembler Window'''
79 7 Anthony Rowe
  * View -> Disassembler will show the raw assembly
80 7 Anthony Rowe
  * You can switch back and forth from the C code to the assembly code etc
81 7 Anthony Rowe
82 7 Anthony Rowe
----
83 7 Anthony Rowe
84 7 Anthony Rowe
= Trouble? =
85 7 Anthony Rowe
86 7 Anthony Rowe
87 6 Anthony Rowe
If you see the following in the Message Window:
88 6 Anthony Rowe
{{{
89 6 Anthony Rowe
Coordinator: The object file does not contain source code information.
90 6 Anthony Rowe
}}}
91 13 Anthony Rowe
You probably did not select the elf file (the hex file will load without source) or you are using an old version of AVR Studio.