3. Hello world 3: Sourcery with Eclipse at Win7

17 May 2012

(Part 2) Pre<     Return to: Embedded Code Generation Home    Next> (Part 4)

  1. Install Eclipse with CDT (C/C++ Development Tooling)
  2. Install the GNU ARM Eclipse Plug-in
  3. Check the location of CodeSourcery toolchain
  4. Create an C project supported by CodeSourcery Compiler
  5. Set the Build configuration to use CodeSourcery Compiler 
  6. Build the project to get the Beagleboard-executable file


    I found a good tutorial Developing in C/C++ with Eclipse on Windows by Andrea Leganza at http://foxg20old.acmesystems.it/doku.php?id=tutorial:eclipse. It is for FoxG20, but the principles apply to Beaglebaord.

     

    1. Installing Eclipse with CDT (C/C++ Development Tooling)


    Download Eclipse IDE for C/C++ Devcelopers for Windows from the Eclipse website:

    Eclipse IDE for C/C++ Developers

     

    Simply uncompress the file directly in the working directory (i.e. c:\eclipse) then to launch Eclipse by executing  eclipse.exe. It is installation-free.  I am using the  Indigo Service Release 2 version.

     

    2. Install the GNU ARM Eclipse Plug-in


    The GNU ARM Eclipse Plug-in is an Eclipse CDT Manged Build Extension for GNU ARM Toolchains like CodeSourcery G++ Lite, GNUARM, WinARM, agarto, and supports the development of managed C/C++ applications for the ARM series of processors. The GNU ARM plug-in  can be found at http://gnuarmeclipse.livius.net/blog/

     

    Select Help > Install New Software, then copy this URL http://gnuarmeclipse.sourceforge.net/updates in the Work with field then type enter. If this link does not work, try the new URL

    http://sourceforge.net/projects/gnuarmeclipse/files/Eclipse/updates/

    This possibly is due to the update site has been migrated to the File Release System.

     

    Expand the CDT GNU Cross Development Tools and select  the GNU ARM C/C++ Development Support item and press the Next button.

    Machine generated alternative text: 3 Install
Available Software
Check the items that you wish to install.
Work with: http://sourceforge.net/projects/g nuarmeclipse/files/Eclipse/updates/  [ Add... J
Find more software by working with the 閳ユ穾vailable Software Sites閳?preferences.
type filter text
Name Version
鐓鑴?CDT GNU Cross Development Tools
L1鏋?GNU ARM C/C++ Development Support 0.54.201202210114
j Select All j [__Deselect All ] 1 item selected
Details
Show only the latest versions of available software  Hide items that are already installed
E?1 Group items by category What is already installed?
D Show only software applicable to target environment
R1 Contact all update sites during install to find required software
[ < Back ]j Next > ] [ Finish j [ Cancel j
. .- I .rm ii a ii ii .i h

     

    3. Check the location of CodeSourdery Toolchain


    It would be good to write down the path of the following files:

    • arm-none-linux-gnueabi-gcc.exe
    • arm-none-linux-gnueabi-gdb.exe
    • arm-none-linux-gnueabi-ld.exe
    • arm-none-linux-gnueabi-objcopy.exe
    • arm-none-linux-gnueabi-objdump.exe
    • arm-none-linux-gnueabi-size.exe

    Note: we are using  linux-gnueabi version, not the EABI version.

     

     

    4. Create your first project


    File > New > C Project to create a new C project. Type in a project name (e.g. helloworld). At the left panel, select 'Project Type' to 'Empty Project' under the 'ARM Cross Target Application'. At the  right panel, select the toolchains to ARM Windows GCC (Sourcery G++ Lite) and click 'Finish'. 

    Machine generated alternative text: ARM Cross Target Application
閳?Empty Project
ARM Cross Target Static Library
Executable
Shared Library
Static Library
. Makefile project
GNU Autotools
Browse...
Toolchains:
ARM Windows CCC (GNUARM, WinARM)
ARM Windows CCC (Sourcery C++ Lite)
ARM Windows CCC (Summon)
ARM Windows CCC (Yagarto)
ARM Windows CCC (devkitPro)
E?1 Show project types and toolchains only if they are supported on the platform
[ <Back j Ne> ] [ Finish j [ Cancel j
Project name: helloworldi
Use default location
Location: E:\Beagle\Eclipseworkspace\helloworld
Choose file system: [default .rj
Project type:

     

    Create a new file, i.e., main.c and write a Hellow World! Example.

    Machine generated alternative text: 3 c/c++ - helloworld/main3.c - Eclipse
File Edit Source Refactor Navigate Search Run Project Window Help
閳?z4 helloworld
鍐?Binaries
gii Includes
Debug
閳? helloworldeif - [arm/le]
i閳? main3,o - [arm/le]
hellooIst
helloworld.lst
helloworidmap
. main3,d
ma in 3o. 1st
makefile
objects.mk
sources.mk
e subdirmk
E main3.c
4w Aj閳ユ┗1 閳ヮ敺J閳ユ績?妾?wfl 閳ユΜ
Proj S鑹?Outl!J Mak 鎺?fl_f閳ユ紝main3.c N
#include 閳ユ笩tdio.h閳?#10;[j c/c++ I
a
:
mt main(void)
{
printf(閳ユ饥ello world!\n閳?;
printf(閳?compiled by Sourcery in Eclipse (Win7)\n閳?;
return 0;
閳?
H __
Problems S閳?.a Tasks  Console Properties
O items _____
Description
閳ユǚ?妯??#10;4
/helloworld/Debug/helloworld.elf

     

     

    5. Configure the Builder


    Select the project, right click and select 'Properties'. Set the parameters of C/C++ build as follows:
           (1) In the "C/C++ Build" -> "Setting"->Tab "Tool Settings"-> Target processor : cortex-a8 and select 'Thumb (-mthumb)'

    C/C++ Build -> Settings

     

    (2) Debugging: Debug fromat -> Toolchain Default

    Machine generated alternative text: S Properties for helloworid LJ 
type filter text Settings 閳ユ 閳ユ 閳ユ
Resou ice
A
Builders
C/C++ Build Configuration: Debug [Active] E [Manage Configurations...j
Build Variables
Discovery Options
Environment iF5eiig閳?Build Stepsji Build Artifac]Ji Binary Parsers O Error Parsers
Logging 鑾?Target Processor Debug level Maximum (-g3) 閳ユ
Settings  Debugging
Tool Chain Editor Debug format Toolchain Default E
Additional Tools
C/C++ General
搴?ARM Sourcery Windows GCC Assembler Other debugging flags
Project References  Preprocessor D Generate prof information (-p)
Refactoring History  Directories D Generate gprof information (-pg)
Run/Debug Settings  Warnings

     

    (3) Additional Tools:

    Machine generated alternative text: S Properties for helloworld
type filter text Settings 閳?w
Resource
a
Builders ________________________
C/C++ Build Configuration: Debug [Active] _________  [Manage Configurations...j
Build Variables
Discovery Options
Environment  Build Artifact j 闅?Binary Parsers Error Parsers
Logging S Target Processor  D Create Flash Image
Tool Chain Editor 5 Additional Tools  Print Size
Settings 5 Debugging Create Extended Listing
C/C++ General
搴?ARM Sourcery Windows GCC Assembler
Project References 5 Preprocessor
I i;-+-.-..

     

    (4) ARM Sourcery Windows GCC Assembler:  arm-none-linux-gnueabi-gcc

    Machine generated alternative text: Tool Settings Build Steps Build Artifact [ Binary Parsers j G Error Parsers
Target Processor Command: arm-none-Iinux-gnueabi-gcc
Debugging All options: -x assembler-with-cpp -Wall -Wa,-adhlns=閳?@.lst閳?#10;Additional Tools -c -fmessage-length=O -mcpu=cortex-a8 -mthumb
搴?ARM Sourcery Windows CCC Assembler -g3
Preprocessor
Directories
Warnings Expert settings:
i鎷?Miscellaneous Command ${COMMAND} ${FLACS} ${OUTPUT_FLAG} ${OUTPUT_PR
搴?ARM Sourcery Windows CCC C Compiler line pattern:
Preprocessor

     

    (5) ARM Sourcery Windows GCC C Compiler:  arm-none-linux-gnueabi-gcc

    Machine generated alternative text: 搴?Tool Settings LE7Build Steps L Build Artifact 闅?Binary Parsers O Error Parsers
Target Processor Command: arm-none-linux-gnueabi-gcc
Debugging All options: -oo -Wall -Wa,-adhlns=閳?@.lst閳?-c -fmessage
Additional Tools length=O -mcpu=cortex-a8 -mthumb -g3
搴?ARM Sourcery Windows 6CC Assembler
Preprocessor
Directories
Warnings Expert settings:
Miscellaneous Command ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PR
閳ユアRM Sourcery Windows CCC C Compiler line pattern:
Preprocessor
i Directories
Optimization
Warnings
Miscellaneous


    Add include paths and symbols:
    "C:\CodeSourcery\lib\gcc\arm-none-linux-gnueabi\4.6.1\include"
    "C:\CodeSourcery\arm-none-linux-gnueabi\libc\usr\include"

    Adding include path

    In some cases, you may need additional two paths:
      C:\CodeSourcery\lib\gcc\arm-none-linux-gnueabi\4.6.1\include-fixed
      C:\CodeSourcery\arm-none-linux-gnueabi\include
    Alternatively, the include path can be set at Project->Properties->C/C++ General -> Paths and Symbols. The bold paths are user-defined paths. Below the bold paths are 'Built-in' paths. Ticking the box 'Show built-in values' to show the built-in paths. It can be seen that the paths we added have be in the 'Built-in' values, but the path separator slash (/) is in Linux style, while MS Windows uses \.
    After adding these DOS/Windows paths, you may get Warnings of duplicated paths when you build the project. Something like:

    Invalid project path: Duplicate path entries found (/BeagleCOM [Include path] isSystemInclude:true includePath: C:/CodeSourcery/arm-none-linux-gnueabi/libc/usr/include), path: [/BeagleCOM].

    That is OK.

    Adding include path

     

    (6) ARM Sourcery Windows GCC C Linker:  arm-none-linux-gnueabi-gcc

    Machine generated alternative text: 搴?Tool Settings Build Steps j Build Artifact 鐭?Binary Parsers O Error Parsers
Target Processor Command: arm-none-linux-gnueabi-gcc
Debugging All options: -Wl,-Map,helloworldmap -mcpu=cortex-a8 -
Additional Tools mthumb -g3
搴?ARM Sourcery Windows 6CC Assembler
Preprocessor
Directories
c鎷?Warnings Expert settings:
Miscellaneous Command ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PR
搴?ARM Sourcery Windows 6CC C Compiler line pattern:
Preprocessor
Directories
Optimization
Warnings
Miscellaneous
4)ARM Sourcery Windows 6CC C Linker
General
c Libraries
Miscellaneous

     

    (7) ARM Sourcery Windows GNU Create Listing:  arm-none-linux-gnueabi-objdump

    Machine generated alternative text: 搴?Tool Settings Build Steps J Build Artifacij Binary Parsers Ji Error Parsers
Target Processor Command: a471-none-Iinux-gnueabi-objdump
Debugging All options: -h -S helloworld.elf a
閾嗘嫥 Additional Tools
搴?ARM Sourcery Windows CCC Assembler
Preprocessor
Directories
Warnings Expert settings:
Miscellaneous Command ${COMMAND} ${FLACS} ${OUTPUT_FLAG} ${OUTPUT_PR
搴?ARM Sourcery Windows CCC C Compiler line pattern:
Preprocessor
Directories
Optimization
Warnings
Miscellaneous
搴?ARM Sourcery Windows GCC C Linker
General
J Libraries
Miscellaneous
搴?ARM Sourcery Windows GNU Create Listing
General
搴?ARM Sou rcery Windows GNU Print Size
General

     

    (8) ARM Sourcery Windows GNU Print Size:  arm-none-linux-gnueabi-size

    arm-none-linux-gnueabi-size reports the size of the executable file.

    Machine generated alternative text: 搴?Tool Settings Build Steps Build Artifact Binary Parsers O Error Parsers
Target Processor Command: arm-none-Iinux-gnueabi-size
Debugging All options: --format=berkeley helloworldelf
Additional Tools
搴?ARM Sourcery Windows GCC Assembler
Preprocessor
Directories
Warnings Expert settings:
Miscellaneous Command ${COMMAND} ${INPUTS} ${FLAGS}
閳?搴?ARM Sourcery Windows CCC C Compiler line pattern:
J Preprocessor
Directories
Optimization
Warnings
Miscellaneous
閳?搴?ARM Sourcery Windows CCC C Linker
General
Libraries
Miscellaneous
搴?ARM Sourcery Windows GNU Create Listing
General
ARM Sourcery Windows GNU Print Size
General

     

     

    6. Build the project to get the Beagleboard-executable file


    Right click the project name, select 'Build Project'. Or  use hot key Ctrl+B to build the project.   The output file *.elf is located at ./debug with the name <projectname>.elf. See the configuration at 'C/C++ Build' > 'Settings' > 'Build Artifact' tab

     

    Machine generated alternative text: 3 Properties for helloworld2
type filter text Settings e C
Resource
Builders _______________________
閳?C/C++ Build Configuration: [Debug [Active] ______________ e] [Manage Configurations...]
Build Variables
Discovery Options
Environment  Tool Settings[ Build Steps Build Artifact  Binary Parsers Error Parsers[
! Logging Artifact Type: ARM Cross Target Application ___________________ ____________________________
Settings
Tool Chain Editor Artifact name: ${ProjName}
C/C++ General Artifact extension: elf e
Project References
Refactoring History Output prefix:
Run/Debug Settings
! Task Repository
WikiText

     

    When the build procedure completes successfully, you will see the output information at Eclipse's Console window

    Machine generated alternative text: ProblemsaTasks Q Console fl Properties 鑴狫Git Repositories History  Error Log ______ _____
CDT Build Console [helloworld]  ij r x 鑹?Q 
TTTIlsneu uuiiuing: . ./mdlrI3.c. a
閳ユイuilding target: helloworld.elf閳?#10;閳ユキnvoking: ARM Sourcery Windows 6CC C Linker閳?#10;arm-none-linux-gnueabi-gcc -Wl,-Map,helloworld.map -mcpu=cortex-a8 -mthumb -g3 -o
閳ユ笁elloworld.elf閳?./main3.o
閳ユォinished building target: helloworld.elf閳?#10;閳ユキnvoking: ARM Sourcery Windows GNU Create Listing閳?#10;arm-none-linux-gnueabi-objdump -h -S helloworld.elf > 閳ユ笁elloworld.lst閳?#10;閳ユォinished building: helloworld.lst閳?#10;閳ユキnvoking: ARM Sourcery Windows GNU Print Size閳?#10;arm-none-linux-gnueabi-size --format=berkeley helloworld.elf
text data bss dec hex filename
1056 292 4 1352 548 helloworld.elf
nished building: helloworld.siz閳?#10;**** Build Finished ****

 

Created with Microsoft OneNote 2010
One place for all your notes and information