Back to main page

AVR®32 AT32UC3 Series Software Framework: Embedded Development Quick Start

Copyright © 2007 Atmel Corporation

Introduction

The intention of this guide is to help users getting started with AVR32 UC3 embedded development. It is a quick reference on how to create an application for the AVR32 UC3A with the GNU Toolchain and how to run and debug it..

NOTE: Make sure to install all tools before using this guide.

Atmel recommends that you upgrade your software by visiting http://www.atmel.com/avr32 and download the latest versions of the UC3 Software Framework and the GNU Toolchain.

 

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.

 

Hardware Requirements

This quick guide has been designed for the EVK1100 evaluation kit and AT32UC3A0512.
  • Connect the provided power cable (with 5.5/2.1mm DC plug) to a power supply (8 to 20V)or plug a USB cable.
  • Set the board’s power switch according to your settings ("EXT" for external supply, "USB" for USB cable supply) .
  • Connect the JTAGICE mkII emulator to the EVK1100 's JTAG connector and to you PC. Make sure you have the latest tools installed so the emulator will be well recognized by your operating system.
  • The UC3 Software Framework ADC driver example is used in the following. This example uses a RS232 link. Connect the EVK1100 's USART_1 to your serial port via a standard RS-232 D-SUB9 cable. Set the following settings in your terminal of choice: 57600bps / 8bit data / 1 stop bit / no flow control.

     

     

    Quick Start with the GNU Toolchain

     

    Step 1: Prepare a test application

    Each driver folder of the UC3 Software Framework (/DRIVERS directory) 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 or from Atmel web site to your own location. You may also want to check the installation page for details regarding the installation of the Software Framework.

     

    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/AT32UC3A-x.y.z/DRIVERS/ADC/EXAMPLE/AT32UC3A0512/GCC/
    make
    

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

     

    Step 3: Program uploading

    The application avr32program can be used to program the device.

    To program-only the device with the ADC example, use the following command line:

    avr32program program -finternal@0x80000000,512Kb -e -v uc3a0512-adc_example.elf
    

    For more information about avr32program usage and parameters, use the builtin help command:

    avr32program -h
    

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

    avr32program program -finternal@0x80000000,512Kb -e -v -R -r uc3a0512-adc_example.elf
    


    The Makefile also comes with pre-built Make targets:

  • [all]: Default goal: build the project.
  • clean: Clean up the project.
  • rebuild: Rebuild the project.
  • ccversion: Display CC version information.
  • cppfiles file.i: Generate preprocessed files from C source files.
  • asfiles file.x: Generate preprocessed assembler files from C and assembler source files.
  • objfiles file.o: Generate object files from C and assembler source files.
  • a file.a: (Archive) Create an archive output file from object files.
  • 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.
  • hex file.hex: Create Intel HEX image from ELF output file.
  • bin file.bin: Create binary image from ELF output file.
  • sizes: Display target size information.
  • isp: Use ISP instead of JTAGICE mkII when programming.
  • cpuinfo: Get CPU information.
  • halt: Stop CPU execution.
  • chiperase: Perform a JTAG Chip Erase command.
  • erase: Perform a flash chip erase.
  • program: Program MCU memory from ELF output file.
  • secureflash: Protect chip by setting security bit.
  • reset: Reset MCU.
  • debug: Open a debug connection with the MCU.
  • run: Start CPU execution.
  • readregs: Read CPU registers.
  • doc: Build the documentation.
  • cleandoc: Clean up the documentation.
  • rebuilddoc: Rebuild the documentation.
  • verbose: Display main executed commands.
  •  

    So for example, to program the target, reset the target and then run the program, you could also type:

     make program reset run
    

     

    Step 4: Debugging

    The application can be debugged on target using the GNU Project Debugger(GDB) and a 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.

    GBD Proxy Interface

    Image:avr32_embedded_debugging.png


     

    Step 4.1: 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,512Kb  -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
    


    Step 4.2: 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 your source directory:

    cd /your-local-location/AT32UC3A-x.y.z/DRIVERS/ADC/EXAMPLE/AT32UC3A0512/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 started, 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 uc3a0512-adc_example.elf
    

    To start executing the test application:

    (gdb) cont
    

     


    AVR is a registered trademark of Atmel Corporation.