InstallationGuide GNU and Eclipse (1)

24
...the world's most energy friendly microcontrollers Configuring Eclipse for EFM32 Development AN0023 - Application Note Introduction This application note will show you how to install Eclipse on Windows and set up a simple project. Compiling and finally debugging the code on an EFM32 microcontroller is demonstrated. All the software components used in this application note are free of charge. This application note includes: This PDF document Eclipse support files (zip) Eclipse Embedded Systems Register View (EmbSys) plugin Eclipse GDB Hardware Debugging plugin Eclipse Cortex CPU register view patch

description

EFM32

Transcript of InstallationGuide GNU and Eclipse (1)

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 1 www.energymicro.com

    Configuring Eclipse for EFM32DevelopmentAN0023 - Application Note

    Introduction

    This application note will show you how to install Eclipse on Windows and setup a simple project. Compiling and finally debugging the code on an EFM32microcontroller is demonstrated. All the software components used in thisapplication note are free of charge.

    This application note includes:

    This PDF document Eclipse support files (zip)

    Eclipse Embedded Systems Register View (EmbSys) plugin Eclipse GDB Hardware Debugging plugin Eclipse Cortex CPU register view patch

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 2 www.energymicro.com

    1 PrerequisitesYou will need a kit with an EFM32 Cortex-M3 microcontroller and the following tools:

    Eclipse IDE for C/C++ Developers. C/C++ GDB Hardware Debugging plugin for Eclipse. Sourcery CodeBench Lite, the GNU toolchain containing gcc compiler/linker and gdb debugger. Eclipse Embedded Systems Register View plugin (EmbSys). Eclipse view of peripheral registers of

    all Energy Micro EFM32 parts. Simplicity Studio including example software and SEGGER's J-Link GDB Server.

    SEGGER's J-Link GDB Server also exists for Linux, and although this application note is Windows-specific, the procedure should be fairly similar.

    1.1 A note on versions

    To succeed in making your setup work, it is important to notice that since there are many different toolsfrom different sources involved, you should use the versions shown in Table 1.1 (p. 2) . Once youhave a stable setup, you can experiment using other tool versions. Microsoft Windows 7 Professional(32-bit) was used to prepare this application note.

    Table 1.1. Tool version information

    Tool name Version

    Eclipse IDE for C/C++ Developers Version: 3.7.2 Build id: 20120216-1857 (Indigo)

    C/C++ GDB Hardware Debugging plugin for Eclipse Version: 7.0.0.201202111925

    Sourcery CodeBench Lite 2012.03-56

    gcc version 4.6.3gdb version 7.2.50.20100908-cvs

    Eclipse Embedded Systems Register View 0.2.0

    Simplicity Studio 1.08

    1.2 Installing the tools

    1.2.1 Simplicity Studio

    Download Simplicity Studio from

    http://www.energymicro.com/downloads/software

    and install it.

    Launch Simplicity Studio and answer Yes to the question about installing the recommended packages.Answer OK to the question about installing the J-Link drivers.

    You will get a directory structure as shown below within your Simplicity Studio work directory at

    C:\%APPDATA%\energymicro\

    Note that the AppData directory is hidden by default in Windows, and pay special attention to the blinkexample as it will be used later in this application note.

    http://www.energymicro.com/downloads/software

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 3 www.energymicro.com

    Figure 1.1. Simplicity Studio and example SW file structure

    It is now time to connect the kit to your machine via the supplied USB cable and check that the J-Linkdevice driver was properly installed.

    From the start menu, launch the program called J-Link GDB Server via SWD found in the SEGGERfolder. If everything is OK, the server should be able to connect to the board and the GUI should looksomething like:

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 4 www.energymicro.com

    Figure 1.2. J-Link GDB Server GUI

    Do not exit this program before continuing.

    1.2.2 Sourcery CodeBench Lite

    Install the Sourcery CodeBench Lite software package (make sure you download the EABI Release forARM processors). It is available from:

    http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition

    When prompted with a question to add CodeBench to the PATH environment variable, you shouldaccept.

    1.2.3 Eclipse IDE for C/C++ Developers

    Eclipse is available from:

    http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2

    As Eclipse is a Java application you must have Java Runtime Environment (JRE) installed on yourcomputer before installing Eclipse. You can check if Java is installed by issuing the command:

    java -version

    in a Command Prompt, or you can visit http://java.com and click on the link named Do I have Java?

    When downloading Eclipse make sure you select the Windows version. The Indigo edition was usedin this application note.

    Unpack the zip file at C:\ and you have a full Eclipse installation at C:\eclipse.

    The two plugins needed can be installed from online repositories as described in the following sections,or by extracting an0023_efm32_eclipse_toolchain.zip. If you elect to use the plugins in the zip file, copy

    http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-editionhttp://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-editionhttp://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2http://java.com

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 5 www.energymicro.com

    the relevant files into Eclipse's features and plugins subdirectories (under C:\eclipse). This directorystructure is replicated inside the zip file.

    1.2.3.1 C/C++ GDB Hardware Debugging plugin

    Start Eclipse by executing C:\eclipse\eclipse.exe. When prompted for workspace navigate to theexamples directory for your kit in Simplicity Studio's working directory. In our case

    C:\%APPDATA%\energymicro\kits\EFM32TG_STK3300\examples

    You will now be greeted by Eclipse's welcome screen.

    Select Install New Software... from the Help pulldown menu, and enter

    http://download.eclipse.org/releases/indigo

    in the Work with field. You might need to wait a while for the plugins to show up. Browse to Mobile andDevice Development and select C/C++ GDB Hardware Debugging. Press the Next > button, and followthe instructions.

    Figure 1.3. GDB Hardware Debugging plugin installation

    The installation process may take a while... When asked to restart Eclipse, do so.

    1.2.3.2 Eclipse Embedded Systems Register View plugin

    Proceed as described in the previous section, but use http://embsysregview.sourceforge.net/update asLocation.

    Restart Eclipse when asked to do so.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 6 www.energymicro.com

    2 Working with EclipseNow it's time to continue with Eclipse. Close Eclipse's welcome screen tab and Eclipse's Workbenchview appears:

    Figure 2.1. The Eclipse Workbench View

    2.1 Create a project

    The new project will be based on the blink example provided with the STK/DK examples package alreadyinstalled.

    Create the project by selecting File->New->C Project. Use blink as project name (same name asthe project directory). Make sure that your Project type is a Makefile project with Toolchains: -- OtherToolchain --. Hit the Finish button to complete the project definition.

    Now fine-tune some project properties. Select Project->Properties:

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 7 www.energymicro.com

    Figure 2.2. The Eclipse Project Properties window

    Do the following modifications:

    C/C++ Build: Do not use default build command, uncheck the checkbox and modifiy build commandto cs-make.

    C/C++ Build: Modify build directory to ${workspace_loc:/blink/codesourcery}. C/C++ Build->Discovery Options: Uncheck the Automatic discovery of paths and symbols checkbox. C/C++ Build->Settings: Check the GNU Elf Parser checkbox.

    Hit the OK button to complete project properties fine-tuning.

    Some changes also needs to be made to the Makefile. Make a copy of the original Makefile.blink in theblink/codesourcery directory and save it with filename Makefile. These operations are easily performedby right-clicking on the files in the Project Explorer pane and selecting Copy and Paste. Open Makefileby double-clicking on it in the Project Explorer, then change the WINDOWSCS variable so that it pointsto your CodeBench Lite installation relative to the Program Files folder:

    WINDOWSCS = CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI

    Also check that the CFLAGS macro contains option -O0. The -O option select code optimizationlevel. Using -O0 makes it easier to use the debugger. Also make sure that the project name definedwith the PROJECTNAME macro has the same name as the project root directory, and that the DEVICEmacro is correct.

    2.2 Build the code

    The setup is now ready to build the code. Select Build Project or Clean... from the Project menu, orsimply use Ctrl-B from the keyboard. The output from the build process is visible in the Console tab.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 8 www.energymicro.com

    2.3 Download and debug application code

    2.3.1 Create a debug launch configuration

    To be able to download and debug the application, create a Debug configuration. Open the pulldownmenu of the Debug button:

    Figure 2.3. Debug button

    and select Debug Configurations.... Highlight GDB Hardware Debugging and hit the New launchconfiguration button.

    Fill in as shown below:

    Figure 2.4. Debug launch configuration details - Main tab

    Do the following modifications in the other tabs:

    Main tab: Click the Select other... link on the bottom where it says Using GDB (DSF) HardwareDebugging Launcher and select the Standard GDB Hardware Debugging Launcher instead, and applyby clicking the OK button.

    Debugger tab: Enter arm-none-eabi-gdb in the GDB command field. Debugger tab: Check the Use remote target checkbox. Select the Generic TCP/IP JTAG Device and

    enter localhost as Host name, and 2331 as Port number. Startup tab: Enter

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 9 www.energymicro.com

    set tdesc filename target-m3.xml mon speed 4000 mon endian little mon flash download = 1 mon flash device = EFM32TG840F32 mon reset 1

    in the Initialization Commands text box. Replace the device identificator with your own. Consult GDB'sand J-Link's manual for an explanation of these commands. The set tdesc filename command makesEclipse's CPU register view show the correct registers. The xml-file target-m3.xml needed for this isincluded in an0023_efm32_eclipse_toolchain.zip. Put it in your root eclipse directory.

    Startup tab: Check the Set breakpoint at: checkbox in the Runtime Options frame, and write main inthe textbox.

    Common tab: Check Debug checkbox in the Display in favorites menu frame.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 10 www.energymicro.com

    Figure 2.5. Debug launch configuration details - Startup tab

    Now you can flash your microcontroller and start debugging your code directly by selecting blink fromthe Debug button dropdown menu.

    Remember that you always need to have the J-Link GDB Server running to be able to flash and debug.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 11 www.energymicro.com

    Figure 2.6. A typical debug session launch

    2.3.2 Run, Stop, Single-Step, Breakpoints

    Look for the buttons shown in the figure below in the debug tab.

    Figure 2.7. Debug button

    These are all you need to do simple debugging. Breakpoints are set by doubleclicking in the left gutterin the source code tab. Set a breakpoint on the Delay(100) function call in the end of main() in blink.c,hit F8 several times and observe how the LED's on the STK/DK blink. (Hint: You must Terminate beforereflashing and starting a new debug session. Exit and restart the GDB server if you get stuck).

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 12 www.energymicro.com

    Figure 2.8. Debug with breakpoint

    2.3.3 Using EmbSys Register viewer

    The register viewer is a practical tool when you are debugging code for the peripherals of themicrocontroller. The register viewer also contain documentation on peripheral registers and their bitfields(as tooltips). Open Preferences in Eclipse's Window pulldown menu and select the correct device asshown in the figure below.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 13 www.energymicro.com

    Figure 2.9. EmbSys register viewer device selection

    Under Behavior you should increase the number of elements EmbSys Register View will show in thedropdown menu for a register to the maximal amount.

    To open a register viewer in the debug view, select Show View -> Other... in Eclipse's Window pulldownmenu. Then expand the Debug node and select EmbSys Registers.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 14 www.energymicro.com

    Figure 2.10. EmbSys register viewer in action

    Double click on a register to start viewing its content. Registers which you have selected get a green font.Changes in register contents are shown with red values. When hovering over a register's descriptioncolumn you see documentation for that register. To change a register, click on a cell in the Hex column,or the Bin column.

    2.3.4 Using the Memory viewer

    Eclipse's memory monitor view is a default part of the debug view. The figure below shows two activememory monitors, one at address 0x20000200 and one at current stackpointer address. The view usesthe Split Pane functionality, which in this case give you one hexadecimal rendering, and one ASCIIrendering. New monitors are added by clicking the green plus sign as indicated.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 15 www.energymicro.com

    Figure 2.11. Eclipse Memory Monitor

    2.4 Tweaking Eclipse

    2.4.1 Disabling parts of the Code Analysis feature

    Code Analysis is a feature of Eclipse that tries to spot errors in your code while you are writing it, but itsometimes gets in your way, and is not always so good at finding definitions hidden in other files.

    You can disable some or all of the Code Analysis warnings in Window -> Preferences, under C/C++ -> Code Analysis.

    2.4.2 Telling Eclipse about the external libraries

    To take advantage of more of Eclipse's advanced IDE-features you can add the external libraries aslinked folders in your project. Do this by right-clicking the project name, and selecting New -> Folder.Under Advanced >>, select Link to alternate location and browse to the library you want to link to.

    Add bsp and drivers from the directory corresponding to your kit. Also add the emlib folder and thefolder corresponding to your device under Device/EnergyMicro. Lastly, add a link to the install locationof Sourcery CodeBench, and Eclipse will now be able help you look up function definitions etc.

    When you have done this, Eclipse will show you function definitions when hovering over function calls,and by right-clicking you can jump to the file where the function is defined.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 16 www.energymicro.com

    Figure 2.12. Hovering a function call gives you the beginning of its definition

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 17 www.energymicro.com

    3 Eclipse summaryThis has just been an introduction to the basic steps of installing, configuring and using Eclipse as a codedevelopment environment for writing programs for EFM32 microcontrollers. Keep in mind that Eclipseis an advanced tool with hundreds of configuration options. The reader is encouraged to experimentfurther to finetune Eclipse. Use a search engine on the internet and you will find lots of articles, tutorialsand books on using Eclipse.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 18 www.energymicro.com

    4 Revision History

    4.1 Revision 1.10

    2012-08-13

    New versions of Eclipse, Sourcery CodeBench and EmbSysRegView.

    Recommend installing Simplicity Studio.

    Use C/C++ GDB Hardware Debugging plugin instead of Zylin.

    Use GDB for programming directly instead of eA Commander.

    New target-m3.xml.

    4.2 Revision 1.04

    2011-08-30

    Fixed Zylin update link.

    4.3 Revision 1.03

    2011-06-28

    Fixed typo regarding EMEclipseSupport.zip to an0023_efm32_eclipse_toolchain.zip renaming.

    4.4 Revision 1.02

    2011-03-24

    Changed the name of the zip file EMEclipseSupport.zip to an0023_efm32_eclipse_toolchain.zip onsection 1.2.4

    4.5 Revision 1.01

    2010-11-22

    Added comment about the necessity of having Java installed before installing Eclipse.

    4.6 Revision 1.00

    2010-11-10

    Initial revision.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 19 www.energymicro.com

    A Disclaimer and Trademarks

    A.1 Disclaimer

    Energy Micro AS intends to provide customers with the latest, accurate, and in-depth documentationof all peripherals and modules available for system and software implementers using or intending touse the Energy Micro products. Characterization data, available modules and peripherals, memorysizes and memory addresses refer to each specific device, and "Typical" parameters provided can anddo vary in different applications. Application examples described herein are for illustrative purposesonly. Energy Micro reserves the right to make changes without further notice and limitation to productinformation, specifications, and descriptions herein, and does not give warranties as to the accuracyor completeness of the included information. Energy Micro shall have no liability for the consequencesof use of the information supplied herein. This document does not imply or express copyright licensesgranted hereunder to design or fabricate any integrated circuits. The products must not be used withinany Life Support System without the specific written consent of Energy Micro. A "Life Support System"is any product or system intended to support or sustain life and/or health, which, if it fails, can bereasonably expected to result in significant personal injury or death. Energy Micro products are generallynot intended for military applications. Energy Micro products shall under no circumstances be used inweapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, ormissiles capable of delivering such weapons.

    A.2 Trademark Information

    Energy Micro, EFM32, EFR, logo and combinations thereof, and others are the registered trademarks ortrademarks of Energy Micro AS. ARM, CORTEX, THUMB are the registered trademarks of ARM Limited.Other terms and product names may be trademarks of others.

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 20 www.energymicro.com

    B Contact Information

    B.1 Energy Micro Corporate Headquarters

    Postal Address Visitor Address Technical Support

    Energy Micro ASP.O. Box 4633 NydalenN-0405 OsloNORWAY

    Energy Micro ASSandakerveien 118N-0484 OsloNORWAY

    support.energymicro.comPhone: +47 40 10 03 01

    www.energymicro.comPhone: +47 23 00 98 00Fax: + 47 23 00 98 01

    B.2 Global Contacts

    Visit www.energymicro.com for information on global distributors and representatives or [email protected] for additional information.

    Americas Europe, Middle East and Africa Asia and Pacific

    www.energymicro.com/americas www.energymicro.com/emea www.energymicro.com/asia

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 21 www.energymicro.com

    Table of Contents1. Prerequisites ............................................................................................................................................ 2

    1.1. A note on versions .......................................................................................................................... 21.2. Installing the tools ........................................................................................................................... 2

    2. Working with Eclipse .................................................................................................................................. 62.1. Create a project ............................................................................................................................. 62.2. Build the code ................................................................................................................................ 72.3. Download and debug application code ................................................................................................ 82.4. Tweaking Eclipse .......................................................................................................................... 15

    3. Eclipse summary ..................................................................................................................................... 174. Revision History ...................................................................................................................................... 18

    4.1. Revision 1.10 ............................................................................................................................... 184.2. Revision 1.04 ............................................................................................................................... 184.3. Revision 1.03 ............................................................................................................................... 184.4. Revision 1.02 ............................................................................................................................... 184.5. Revision 1.01 ............................................................................................................................... 184.6. Revision 1.00 ............................................................................................................................... 18

    A. Disclaimer and Trademarks ....................................................................................................................... 19A.1. Disclaimer ................................................................................................................................... 19A.2. Trademark Information ................................................................................................................... 19

    B. Contact Information ................................................................................................................................. 20B.1. Energy Micro Corporate Headquarters .............................................................................................. 20B.2. Global Contacts ............................................................................................................................ 20

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 22 www.energymicro.com

    List of Figures1.1. Simplicity Studio and example SW file structure ........................................................................................... 31.2. J-Link GDB Server GUI ........................................................................................................................... 41.3. GDB Hardware Debugging plugin installation ............................................................................................... 52.1. The Eclipse Workbench View .................................................................................................................... 62.2. The Eclipse Project Properties window ....................................................................................................... 72.3. Debug button ......................................................................................................................................... 82.4. Debug launch configuration details - Main tab .............................................................................................. 82.5. Debug launch configuration details - Startup tab ......................................................................................... 102.6. A typical debug session launch ................................................................................................................ 112.7. Debug button ....................................................................................................................................... 112.8. Debug with breakpoint ........................................................................................................................... 122.9. EmbSys register viewer device selection ................................................................................................... 132.10. EmbSys register viewer in action ............................................................................................................ 142.11. Eclipse Memory Monitor ....................................................................................................................... 152.12. Hovering a function call gives you the beginning of its definition ................................................................... 16

  • ...the world's most energy friendly microcontrollers

    2012-08-13 - an0023_Rev1.10 23 www.energymicro.com

    List of Tables1.1. Tool version information ........................................................................................................................... 2

  • Configuring Eclipse for EFM32 DevelopmentTable of Contents1Prerequisites1.1A note on versions1.2Installing the tools1.2.1Simplicity Studio1.2.2Sourcery CodeBench Lite1.2.3Eclipse IDE for C/C++ Developers1.2.3.1C/C++ GDB Hardware Debugging plugin1.2.3.2Eclipse Embedded Systems Register View plugin

    2Working with Eclipse2.1Create a project2.2Build the code2.3Download and debug application code2.3.1Create a debug launch configuration2.3.2Run, Stop, Single-Step, Breakpoints2.3.3Using EmbSys Register viewer2.3.4Using the Memory viewer

    2.4Tweaking Eclipse2.4.1Disabling parts of the Code Analysis feature2.4.2Telling Eclipse about the external libraries

    3Eclipse summary4Revision History4.1Revision 1.104.2Revision 1.044.3Revision 1.034.4Revision 1.024.5Revision 1.014.6Revision 1.00

    ADisclaimer and TrademarksA.1DisclaimerA.2Trademark Information

    BContact InformationB.1Energy Micro Corporate HeadquartersB.2Global Contacts