SEARCH
TOOLBOX
LANGUAGES
modified on 17 June 2010 at 12:31 ••• 12,077 views

Using Eclipse/all

From Manuals

Jump to: navigation, search

Contents

Introduction

Overview

The purpose of this document is to show developers how to write, compile, and debug applications using the Eclipse IDE. In this document, we will be discussing how to get Eclipse set up, how to write and compile projects, and how to debug in the Eclipse environment.

The major topics to be covered in this document are:

  • Eclipse Installation
  • Writing and compiling applications
  • Debugging applications

Installation

System Requirements

Eclipse is a Java application and has the potential to be run on a wide variety of hardware and operating systems. Eclipse may install on systems with as little as 64MB of memory, however, we recommend to have 1GB of memory or more.

Software Requirements

The following software is required prior to install:

  • GNU ARM Toolchain – Tools for embedded ARM development
  • Java Runtime Environment (JRE) – Environment required for Java applications

Eclipse SDK

The Eclipse SDK includes the Eclipse Platform which provides support for a full featured IDE. The SDK is provided as an archive and should be extracted to its desired directory (commonly ‘C:\Program Files\’). Eclipse can then be run by opening ‘eclipse.exe’ under INSTALL_DIR\eclipse\ and it is recommended that a shortcut be created to the application for easy access. At startup, Eclipse will prompt the user to specify the workspace directory and should point to the directory containing all of the user’s project folders. This would be ‘C:\Program Files\Micromint\Eagle\StellarisWare\boards\eagle’ for the Eagle example applications and ‘%USERPROFILE%\Projects\Micromint\Lincoln’ for the Lincoln example applications.

Figure 1 – Specifying Workspace in Eclipse

Plug-ins

The Eclipse IDE does not come with embedded ARM development support right out of the box. Plug-ins are needed to add this functionality and can be installed by selecting ‘Help’, ‘Install new software…’ via the Eclipse File menu. Click ‘Add’ to specify a plug-in source. An internet URL can be entered into the text box or a local directory or archive can be selected. The following two plug-ins can be installed via internet repository:

Figure 2 – Installing the CDT plug-in

The following plug-in will need to be downloaded manually and installed via the archive method:

Development

Creating a New Standard Make Project

A new project can be created using standard makefiles. Makefiles will need to be created and added to the project manually. Select ‘File’, ‘New’, ‘Project’ and expand ‘C/C++’ to select ‘C Project.’ To select a standard makefile project, expand ‘Makefile project’ and select ‘Empty Project.’ Specify the project name, the toolchain you will be using, and click ‘Finish.’ If the toolchain you are using is not listed, such as devkitARM, simply select one of the other ARM GCC toolchains.

External Tools Configuration
Figure 3 – Creating a new standard make project

If your toolchain was listed in the step above, you can step this step. If your toolchain was not listed, select your project in the Project Explorer and select ‘Project’, ‘Properties’ from the File menu. Expand ‘C/C++ Build,’ select ‘Discovery Options’ and change the ‘Compiler invocation command’ to the gcc command associated with your toolchain for both the Assembler and C Compiler tools.

External OpenOCD Configuration
Figure 4 - Specifying the toolchain's compiler

To add a makefile, select ‘File,’ ‘New,’ ‘Other’ and expand ‘General’ to select ‘File.’ Hit next, enter the name of your makefile, and click Finish. To add a source file, select ‘File,’ ‘New,’ ‘Source File’ and specify the name of the source file with extension.

Creating a New Managed Make Project

New projects can also be created using managed make files which are automatically created and maintained by Eclipse. To create a new managed make project, select ‘File,’ ‘New,’ ‘Project’ and expand ‘C/C++’ to select ‘C Project.’ Click Next and select ‘Empty Project’ under ‘ARM Cross Target Application.’ Specify the name and the toolchain this project will be using and select Finish.

Debug Configurations
Figure 5 - Creating a new managed make project

If your toolchain was listed in the step above, you can skip this step. If your toolchain was not listed follow the steps as directed for standard makefile projects and these as well. In the Project Properties, select ‘Settings’ under ‘C/C++ Build,’ change the configuration setting to ‘[ All configurations ]’ and specify the correct command for your toolchain for each of the GNU ARM tools.

Toolchain Commands
Figure 6 - Specifying the toolchain commands

Figure 6 – Specifying the toolchain commands

Build Configurations

Build configurations provide a way to change how projects are built. If you create a new managed make project, Debug and Release build configurations are created automatically for you. If you create a new standard make project, a Default build configuration is created automatically.

To create a new build configuration, go to your project properties, select ‘C/C++ Build,’ ‘Manage Configurations…’ and click ‘New.’ Specify a name for the build and a configuration in which to base it on. The new configuration can then be modified in ‘C/C++ Build’ settings. To specify the build configuration as active, simply select it and click ‘Set Active’ in the ‘Manage Configurations…’ settings.

Debugging using Eclipse

OpenOCD

OpenOCD is open source application designed to assist in the debugging of embedded target devices and will provide a debugging interface to our device by acting as a GDB Server. It is necessary to have OpenOCD running before beginning a debug session. Eclipse can make this easier by configuring it as an external tool. To do this, select ‘Run,’ ‘External Tools,’ ‘External Tools Configurations…’ and double-click on ‘Program’ to create a new program configuration. Specify the name, location, and working directory of your OpenOCD configuration. Advance to the ‘Build’ tab, unselect ‘Build before launch,’ click ‘Apply’ and then ‘Close.’

Configuring OpenOCD
Figure 7 – Configuring OpenOCD as an external tool

To run OpenOCD, click the ‘Run Last Tool’ icon and select OpenOCD. This only needs to be done once you begin a new Eclipse session as OpenOCD will remain running until Eclipse exits. Any output printed by OpenOCD can be viewed in the console tab. WARNING: Eclipse sometimes does not close OpenOCD when debugging is finished. In order to open a new debugging session OpenOCD's process needs to be shutdown using Windows Task Manger.

Running OpenOCD
Figure 8 - Starting OpenOCD

Debug Configuration

Before beginning a debug session, a debug configuration must be made describing how Eclipse will handle debugging the application. To do this, right click on the project you wish to debug, select ‘Debug As,’ ‘Debug Configurations,’ and double-click ‘Zylin Embedded debug (Native)’ to create a new configuration. Specify the name for this configuration and browse to the application binary for this project.

New Debug Configuration
Figure 9 – Creating a new debug configuration

Advance to the ‘Debugger’ tab and if necessary, change the GDB debugger to match your toolchain. Advance to the ‘Commands’ tab and enter the following for the initialization commands for the Eagle 50:

target remote localhost:3333
monitor jtag arp_init
monitor reset init
b main
load

Enter the following for the initialization commands for the Lincoln 60:

target remote localhost:3333
monitor jtag arp_init
monitor reset init
b main
load
monitor reg pc 0x00000000

Enter the following for the run commands for the Eagle 50:

j ResetISR
GDB Commands
Figure 10 – Specifying GDB commands

Click ‘Apply’ and ‘Close’ to complete the debug configuration. Debugging To begin a new debug session, click the arrow next to the Debug icon and select ‘Debug Configurations…’

Running Debug
Figure 11 – Running a debug configuration

Click ‘Debug’ and click ‘Yes’ when Eclipse prompts you to move to the debug configuration. Your perspective should look similar to the figure below. The Resume, Suspend, Terminate, Step Into, and Step Over buttons are highlighted in red.

Debugging Perspective
Figure 12 – Eclipse’s debug perspective

The program should be stopped at the first instruction in main. This is due to specifying the breakpoint main as one of the debug initialization commands. You can view your source code in the center of the screen and navigate through the project in the Outline tab on the right. Details about your current debug configuration can be seen in the Debug tab in the upper left hand corner. Current variables, breakpoints, and register values can be seen in their corresponding tabs in the upper right hand corner. Console output can be viewed in the Console tab at the bottom. To step to the next instruction, click the ‘Step Over’ icon. To step to the next assembly instruction, click the ‘Instruction Stepping Mode’ icon and click the ‘Step Over’ icon. Assembly code can then be viewed on the right next to the Outline tab. To insert a breakpoint, double-click on the bar to the left of the instruction that you wish to break at. To add a breakpoint condition, right click on the breakpoint and select ‘Breakpoint Properties,’ ‘Common,’ and enter the breakpoint condition. To watch an expression, select the variable, right click, and select ‘Add watch expression…’ The expression can then be viewed in the Expressions tab in the upper right hand corner of the screen. The Resume, Suspend, and Terminate buttons can simply be used to continue, break, or end the debugging session.

Debugging the Eagle 50s Blinky example application

Please follow these steps to debug the Eagle 50s blinky example application using open OCD for the first time:

  • 1. Open the Eclipse IDE.
  • 2. When prompted browse to.
  • 3. Click 'OK'.
  • 4. Press the 'F5' key on the keyboard to refresh the files.
  • 5. Close all of the open projects by right clicking on the project and selecting "Close Project".
  • 6. Open the blinky project by right clicking on the project and selecting "Open Project". If the Sourcery G++ Lite compiler is not installed and devkitARM is installed then click on "Window>Preferences>C/C++>Build>Environment" and add a variable called "COMPILER" with the value set to "devkitARM".
  • 7. Right click on the blinky project and select build. If the project builds correctly then continue.
  • 8. Right click on the blinky project and select "Debug As>Debug Configurations".
  • 9. Double-click "Zylin Embedded debug (Native)" to create a new configuration.
  • 10. Browse for the blinky out file by clicking on the "Browse" button next to the "Search Project" button. The directory should be "blinky.out".
  • 11. Click on the "Debugger" tab. If necessary change the GDB debugger to match your tool chain For Sourcery G++ Lite browse to "%INSTALLDRECTORY%\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gdb.exe".
  • 12. Click on the "Commands" tab.
  • 13. Type the following in the "Initialze" commands window:
    target remote localhost:3333
    monitor jtag arp_init
    monitor reset init
    b main
    load
  • 14. Type "j ResetISR" in the "'Run' commands" tab.
  • 15. Click "Apply".
  • 16. Close the debug configuration.
  • 17. Open Windows Explorer and browse to "C:\Program Files\Micromint\Tools\openocd" and click on "openocd-eagle" btch file to start open OCD and a screen similar to Figure 13 should open and stay open. If the window does not stay open then the computer could not find the Eagle 50. If Windows Firewall asks if you wish to keep blocking this program click on "Unblock".
Open OCD for Eagle 50
Figure 13 – Eagle 50 Open OCD screen
  • 18. In the Eclipse IDE click on the arrow next to the bug icon and select "1 Blinky Default" to start debugging .
  • 19. Click the green arrow again and the program will start running.
  • 20. Scroll down to "LED_PORT_DATA_R |= LED_PIN;" instruction and click next to it to insert a break point. The program should stop running.
  • 21. If you click the green arrow again the program will start running and will stop at the "LED_PORT_DATA_R |= LED_PIN;" instruction.
  • 22. Press the red square to halt the debugging session.

If at any time power is lost or the reset button is pushed on the Eagle 50 board the OpenOCD-Eagle window needs to be closed and the steps starting at number 17 have to be repeated.

Debugging the Lincoln 60s Blinky example application

Please follow these steps to debug the Lincolns blinky example application using open OCD for the first time:

  • 1. Open the Eclipse IDE.
  • 2. When prompted browse to "%USERPROFILE%\Projects\Micromint\Lincoln" .
  • 3. Click 'OK'.
  • 4. Press the 'F5' key on the keyboard to refresh the files.
  • 5. Close all of the open projects by right clicking on the project and selecting "Close Project".
  • 6. Open the blinky project by right clicking on the project and selecting "Open Project". If the Sourcery G++ Lite compiler is not installed and devkitARM is installed then click on "Window>Preferences>C/C++>Build>Environment" and add a variable called "COMPILER" with the value set to "devkitARM".
  • 7. Right click on the blinky project and select build. If the project build correctly then continue.
  • 8. Right click on the blinky project and select "Debug As>Debug Configurations".
  • 9. Double-click "Zylin Embedded debug (Native)" to create a new configuration.
  • 10. Browse for the blinky elf file by clicking on the "Browse" button next to the "Search Project" button. The directory should be "%USERPROFILE%\Projects\Micromint\Lincoln\CMSIS\projects\blinky\lincoln-all\gcc\blinky.elf".
  • 11. Click on the "Debugger" tab. If necessary change the GDB debugger to match your tool chain For Sourcery G++ Lite browse to "%INSTALLDRECTORY%\CodeSourcery\Sourcery G++ Lite\bin\arm-none-eabi-gdb.exe".
  • 12. Click on the "Commands" tab.
  • 13. Type the following in the "Initialze" commands window:
     target remote localhost:3333
     monitor jtag arp_init
     monitor reset init
     b main
     load
     monitor reg pc 0x00000000
     c
  • 14. Click "Apply".
  • 15. Close the debug configuration.
  • 16. Open Windows Explorer and browse to "C:\Program Files\Micromint\Tools\openocd" and click on "openocd-lincoln" btch file to start open OCD and a screen similar to Figure 13 should open and stay open. If the window does not stay open then the computer could not find the Lincoln 60. If Windows Firewall asks if you wish to keep blocking this program click on "Unblock".
Open OCD for Lincoln 60
Figure 13 – Lincoln 60 Open OCD screen
  • 17. In the Eclipse IDE click on the arrow next to the bug icon and select "1 Blinky Default" to start debugging .
  • 18. Click on the green arrow to start the program.
  • 19. Scroll down to line 71 (the first for loop) and click next to it to insert a break point. The program should stop running.
  • 20. If you click the green arrow again the program will start running and will stop at line 71 again.
  • 21. Press the red square to halt the debugging session.

If at any time power is lost or the reset button is pushed on the Lincoln 60 board the OpenOCD-Lincoln window needs to be closed and the steps starting at number 16 have to be repeated.