Avr-studio

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