Embedded Development Quick Start

Contents

Introduction

The intention of this guide is to help users getting started with embedded development on the EVK1101 development board. It is a quick reference on how to create an application with the GNU Toolchain for the AVR32 UC3B and how to run and debug it on the EVK1101. More general information regarding the embedded development toolchain can be found at the AVR32 GNU Toolchain reference section.

Embedded development refers to development of applications without any operation system.

NOTE1: 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.

NOTE2: This guide requires a JTAGmkII emulator and a EVK1101 evaluation kit. Please check the EVK1101 user guide for hardware settings.

Step 1: Prepare a test application

Driver examples can be found under the UC3 software framework folder on the EVK1101 BSP installation CD and from the Atmel web site. It is a quick reference on how to create an application for the AVR32 UC3 and how to run and debug it on the EVK1101.

Each driver folder includes code to handle the peripheral, example code to use the driver, building scripts (Makefile) and documentation (readme.html). This quick step guide will use the ADC example.

Copy the UC3 software framework from your installation CD and to your own location.


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 ADC driver application note by calling 'make' from the copied source location:

cd /your-local-location/DRIVERS/ADC/EXAMPLE/AT32UC3B/GCC/
make

This will run the GNU Makefile which calls avr32-gcc and produces the object file uc3b0256-adc_example.elf.

Step 3: Program uploading

The application avr32program can be used to program the device.

Program the device with the ADC example. Use the following command line:

avr32program program -finternal@0x80000000,256Kb -e -v uc3b0256-adc_example.elf
  • '-finternal@0x80000000,256Kb' tells the programmer that the internal flash starts at address 0x80000000

and that the size is 256Kb.

  • '-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

For example, to program, reset and run the target,

avr32program program -finternal@0x80000000,256Kb -e -v -R -r uc3b0256-adc_example.elf
  • '-R' is used to reset the MCU,
  • '-r' is used to run the program.


The Makefile also comes with pre-built Make targets:

  • [all]: Default goal: build the project.
  • clean: Clean up the project.
  • rebuild: Rebuild the project.
  • elf file.elf: Link: create ELF output file from object files.
  • lss file.lss: Create extended listing from target output file.
  • sym file.sym: Create symbol table from target output file.
  • bin file.bin: Create binary image from ELF output file.
  • sizes: Display target size information.
  • cpuinfo: Get CPU information.
  • halt: Stop CPU execution.
  • program: Program MCU memory from ELF output file.
  • reset: Reset CPU.
  • debug: Open a debug connection with the MCU.
  • run: Start CPU execution.
  • readregs: Read CPU registers.

To program the target and run the program, you could type:

 make program reset run

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.

Image:avr32_embedded_debugging.png


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 'extended-remote' with port number '4242':

avr32gdbproxy -finternal@0x80000000,256Kb  -a extended-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 ADC example can be debugged.

Start a new terminal (Cygwin) and go to the your source directory:

cd /your-local-location/DRIVERS/ADC/EXAMPLE/AT32UC3B/GCC/

Start the GDB-client with the following command:

avr32-gdb

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 extended-remote:4242

This connects the gdb-client to the avr32gdbproxy server (assuming host name 'extended-remote' and port number '4242'). Then load the symbol table from executable file:

(gdb) sym uc3b0256-adc_example.elf

To start executing the test application:

(gdb) cont

For further information about GDB please refer to the AVR32 GDB reference