STK1000/Embedded Development Quick Start
From AVRFreaks Wiki
Contents |
Introduction
The intention of this guide is to help users getting started with embedded development on the STK1000 development board. It is a quick reference on how to create an application for the AVR32 and how to run and debug it on the STK1000. More general information regarding the embedded development toolchain can be found at the AVR32 Embedded Development Reference section.
Embedded development refers to development of applications without any operation system. Users who want to develop Linux based applications, should read AVR32 Linux Development Reference.
NOTE: Make sure to install all tools before using this guide. Then start Cygwin or a standard Linux terminal, to execute the commands described in each step. Also note that this guide requires a JTAGmkII emulator.
Step 1: Prepare a test application
Application notes can be found under the appnote folder on the STK1000 BSP installation CD and from the Atmel web site. Each application note includes building scripts (Makefile) and documentation (readme.html). This quick step guide will use the pio controller application note as example.
Copy the appnotes/avr32101_the_avr32_interrupt_controller/
directory from your installation CD and to your own location.
Set jumpers on STK1000 and STK1002 as described in interrupt_example_gcc.c
- The header SW6 must be jumped to GPIO (on STK1002)
- The header SW4 must be jumped to GPIO (on STK 1002)
- Connect a cable from J6 to J15 (on STK 1000)
- Connect a cable from J3 to J25 (on STK 1000)
Step 2: Compiling
GCC, the GNU Compiler Collection is used at the compilation stage. The avr32 version of GCC is used by calling avr32-gcc. The compiler supports c-code compilation, assembly and linking.
Compile the pio controller application note by calling 'make'
from the copied source
location:
cd /your-local-location/appnotes/avr32101_the_avr32_interrupt_controller/src make
This will run the GNU Makefile which calls avr32-gcc and produces the object file
interrupt_project.elf
Step 3: Program uploading
The application avr32program
can be used to program the device.
First make sure that the processor is stopped. Use the following command line:
avr32program halt
Then program the device with the pio application note. Use the following command line:
avr32program program -e -v -f0,8Mb interrupt_project.elf
'-f 0,8Mb'
tells the programmer that the flash starts at address 0
and that the size is 8 Mb. The size may also be postfixed with Kb.
'-e'
is used to erase the flash before programming it.'-v'
is used to verify the flash programming.
For more information about avr32program usage and parameters please use the built in help command:
avr32program -h
Step 4: Debugging
The application can be debugged on target using GNU Project Debugger (GDB) and JTAGICE mkII. This requires that a GDB proxy server is used. The proxy will translate standard GDB requests such as read memory, read registers and set breakpoints into JTAGICE mkII operations.
GDB is an open standard and any debugger supporting GDB may be connected to the GDB proxy server using socket communication.
Start GDB proxy server
The AVR32 GDB proxy server must be started before using a GDB-client. Use the following command to start avr32gdbproxy and connect it to a host called 'remote' with port number '4242' :
avr32gdbproxy -f 0,8Mb –a remote:4242
The -f parameter tells the GDB proxy server where the flash memory is located. For information about additional parameters use:
avr32gdbproxy -h
Start GDB-client
Once the GDB proxy server is up an running, the user can communicate with it using any debugger with GDB support. This is done by using the same host name and port number as when avr32gdbproxy was invoked. avr32-gdb is a command line based GDB-client, and it can be used to demonstrate how the pio controller application note can be debugged.
Start a new terminal (Cygwin) and go to the your source directory:
cd /your-local-location/appnotes/avr32101_the_avr32_interrupt_controller/
Start the GDB-client with the following command:
avr32-gdb interrupt_project.elf
Remember to keep the avr32gdbproxy running during the entire debug session. If a command line based GDB-client like avr32-gdb is used, it must be called from a new terminal. If Cygwin is used, one can easily do this by starting Cygwin one more time, so that there are two Cygwin windows: one with the GDB proxy and one with the GDB-client.
Once the GDB-client is startet, use the following GDB commands to initiate a debug session:
(gdb) target remote:4242
This connects the gdb-client to the avr32gdbproxy server (assuming host name 'remote' and port number '4242').
(gdb) set $pc = _start
This sets the program counter to the start address (symbol '_start' is defined in pio_project.elf)
(gdb) cont
This will let the target start executing the test application. Try pressing the switches and see if the LEDs are set. For more details, please refer to the application note documentation.
For further information about GDB please refer to the AVR32 GDB reference