[Q]: Tailoring the Due to Eclipse..

Hi ,
Here what I did :
Arduino Ide version 1.5.1
Note Path character separator differs from the windows system, I build it on OSX
## ArduinoDueCoreLibrary
Make New C++ Project -> Arm Cross Target Library -> Sourcery G++ lite.
Import... -> file System-> /Contents/Resources/Java/hardware/arduino/sam/cores/arduino all files + USB directory
import... -> file System-> /Contents/Resources/Java/hardware/arduino/sam all content of directory variants/
Note that in the last import there is also a precompiled library : libsam_sam3x8e_gcc_rel.a

Project Properties-> C/C++ Build:
->Environment : add PATH Variable with Append option enabled and the following vaulue /Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/
->Settings->Target Processor= cortex-m3 ; Thumb enabled
->Settings->Debug = None

->Settings->Assembler GCC-> Preprocessor:
Use PreProcessor checked
-defined symbols (I defined those also here , but I think it can be skipped)

printf=iprintf
F_CPU=84000000L
ARDUINO=151
__SAM3X8E__
USB_PID=0x003e
USB_VID=0x2341
USBCON

It is possible to copy the above lines and paste directly in the eclipse "Defined Symbols" area.
->Settings->Assembler GCC C->Warnings: -Wall
->Settings->Assembler GCC C->Misc : I removed the Assembler Listing lines

->Settings->Compiler GCC C-> Preprocessor : the same of Assembler
->Settings->Compiler GCC C-> Directories :

/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/
"${workspace_loc:/${ProjName}/USB}"
"${workspace_loc:/${ProjName}}"
"${workspace_loc:/${ProjName}/variants/arduino_due_x}"
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/

Also the above code can be copied and pasted directly inside the include path area, note that the absolute paths fit in my case , you have to tailor those in respect of your situation.

->Settings->Compiler GCC C-> Optimization
Level : -Os
Function sections checked Data sections checked
->Settings->Compiler GCC C->Warnings: -Wall
->Settings->Compiler GCC C->Misc :
Optional : -c --param max-inline-insns-single=500 -nostdlib
Language Standard: Compiler Default

->Settings->Compiler GCC C++-> Every things like GCC C Compiler except for :
->Settings->Compiler GCC C->Misc :
Optional : -c --param max-inline-insns-single=500 -nostdlib
Language Standard: Compiler Default
Do not use exception: checked
Do not use RTTI : checked

Then you can build the arduinoDueCore libraries.

## ArduinoDue Blink example
Make New C++ Project -> Arm Cross Target Application -> Sourcery G++ lite.
Create a cpp file like the following one:

/*
 * Blinker.cpp
 *
 *  Created on: Jan 9, 2013
 *      Author: zad
 */

#include <Arduino.h>

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Project Properties-> C/C++ Build:
->Environment : add PATH Variable with Append option enabled and the following vaulue /Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/
->Settings->Target Processor= cortex-m3 ; Thumb enabled
->Settings->Debug = None
->Settings->Additional Tools:
Create FlashImage : Checked
Create Extended Listings: Checked
Print Size: Checked

->Settings->Assembler GCC-> Preprocessor:
The same used in the library

->Settings->Compiler GCC C-> Preprocessor : the same used in library
->Settings->Compiler GCC C-> Directories :

"${workspace_loc:/ArduinoDueLib/USB}"
"${workspace_loc:/ArduinoDueLib}"
"${workspace_loc:/${ProjName}}"
"${workspace_loc:/ArduinoDueLib/variants/arduino_due_x}"
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/

->Settings->Compiler GCC C-> Optimization:the same used in library
->Settings->Compiler GCC C->Warnings: the same used in library
->Settings->Compiler GCC C->Misc : the same used in library

->Settings->Compiler GCC C++-> the same used in library except for the directories :

"${workspace_loc:/ArduinoDueLib/USB}"
"${workspace_loc:/ArduinoDueLib}"
"${workspace_loc:/${ProjName}}"
"${workspace_loc:/ArduinoDueLib/variants/arduino_due_x}"
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/

->Settings->Linker GCC C++
Command line pattern:

${COMMAND} ${FLAGS} ${OUTPUT_FLAG}  ${OUTPUT_PREFIX}${OUTPUT} -Wl,--start-group ${INPUTS} -Wl,--end-group[\code]

->Settings->Linker GCC C++->General
Script File:/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld
->Settings->Linker GCC C++->Libraries
libraries area:
[code]
ArduinoDueLib  
sam_sam3x8e_gcc_rel

the first entry above is the output of the arduinoDueCore libraries there you need to wire the output without the lib part and .a suffix , i.e. libArduinoDueLib.a becomes ArduinoDueLib

libraries search paths:

"${workspace_loc:/ArduinoDueLib/Debug}"
"${workspace_loc:/ArduinoDueLib/variants/arduino_due_x}"

In my case the output of the lib was in Debug others may have Release it depends on the C++ project and build conf.

->Settings->Linker GCC C++->Misc
Other object area add :
"${workspace_loc:/ArduinoDueLib/Debug/syscalls_sam3.o}"
Other Flags:

-lm -lgcc  -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols

For
->Settings->Create Flash
->Settings->Create Listing
leave defaults
->Settings->Print->General
I preferred the Barkeley format and Show total checked;

->Settings-> Build Steps Tab and add a post-build command:
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-objcopy -O binary ${ProjName}.elf ${ProjName}.bin

Then you can build the Blink program the program elf shall be about 9548bytes

######## Extern Tool Configurations:
new launch conf chose a name , mine was ARduino_due
Main-> Location:
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/bossac.orig
Main-> Arguments:

-U false
--port=tty.usbmodemfd121
-e
-w
-v
-b 
"${workspace_loc:}/${project_name:}/Debug/${project_name:}.bin"
 -R

Build
I have disable build before launch

Finally you can run , but before you need to press the erase button or open and close a the serial via eclipse as described by Nassa :http://arduino.cc/forum/index.php/topic,141628.0.html

Cheers
Zad[/code]

Very good Job Zad,

I was just doing the same job ...

The sketch compilation is :

C:\ARM\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin\arm-none-eabi-g++
-c -g -Os -w 
-ffunction-sections 
-fdata-sections 
-nostdlib 
--param max-inline-insns-single=500 
-fno-rtti 
-fno-exceptions 
-Dprintf=iprintf 
-mcpu=cortex-m3 
-DF_CPU=84000000L 
-DARDUINO=151 
-D__SAM3X8E__ 
-mthumb 
-DUSB_PID=0x003e 
-DUSB_VID=0x2341 
-DUSBCON 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/libsam 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/CMSIS/CMSIS/Include/ 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/CMSIS/Device/ATMEL/ 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\cores\arduino 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\variants\arduino_due_x Blink.cpp -o Blink.cpp.o

The Arduino core compilation for C file

command:C:\ARM\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin\arm-none-eabi-gcc 
-c -g -Os -w 
-ffunction-sections 
-fdata-sections 
-nostdlib 
--param max-inline-insns-single=500 
-Dprintf=iprintf 
-mcpu=cortex-m3 
-DF_CPU=84000000L 
-DARDUINO=151 
-D__SAM3X8E__ 
-mthumb 
-DUSB_PID=0x003e 
-DUSB_VID=0x2341 
-DUSBCON 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/libsam 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/CMSIS/CMSIS/Include/ 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/CMSIS/Device/ATMEL/ 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\cores\arduino 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\variants\arduino_due_x 
C:\ARM\arduino-1.5.1r2\hardware\arduino\sam\cores\arduino\cortex_handlers.c -o cortex_handlers.c.o

The Arduino core compilation for C++ file :

command:C:\ARM\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin\arm-none-eabi-g++ 
-c -g -Os -w 
-ffunction-sections 
-fdata-sections 
-nostdlib 
--param max-inline-insns-single=500 
-fno-rtti 
-fno-exceptions 
-Dprintf=iprintf 
-mcpu=cortex-m3 
-DF_CPU=84000000L 
-DARDUINO=151 
-D__SAM3X8E__ 
-mthumb 
-DUSB_PID=0x003e                                                                              
-DUSB_VID=0x2341 
-DUSBCON 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/libsam 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/CMSIS/CMSIS/Include/ 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\system/CMSIS/Device/ATMEL/ 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\cores\arduino 
-IC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\variants\arduino_due_x 
C:\ARM\arduino-1.5.1r2\hardware\arduino\sam\cores\arduino\cxxabi-compat.cpp -o cxxabi-compat.cpp.o

Lib building :

command:C:\ARM\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin\arm-none-eabi-ar 
rcs 
C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/core.a 
cortex_handlers.c.o

Link :

command:C:\ARM\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin\arm-none-eabi-g++ 
-Os 
-Wl,--gc-sections 
-mcpu=cortex-m3 
-TC:\ARM\arduino-1.5.1r2\hardware\arduino\sam\variants\arduino_due_x/linker_scripts/gcc/flash.ld 
-Wl,-Map,C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/Blink.cpp.map 
-o C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/Blink.cpp.elf 
-LC:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp 
-lm 
-lgcc 
-mthumb 
-Wl,--cref 
-Wl,--check-sections 
-Wl,--gc-sections 
-Wl,--entry=Reset_Handler 
-Wl,--unresolved-symbols=report-all 
-Wl,--warn-common 
-Wl,--warn-section-align 
-Wl,--warn-unresolved-symbols 
-Wl,--start-group 
C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/syscalls_sam3.c.o 
Blink.cpp.o 
C:\ARM\arduino-1.5.1r2\hardware\arduino\sam\variants\arduino_due_x/libsam_sam3x8e_gcc_rel.a 
C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/core.a -Wl,--end-group

Binary file :

command:C:\ARM\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin\arm-none-eabi-objcopy 
-O binary 
C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/Blink.cpp.elf 
C:\Users\XXX\AppData\Local\Temp\build3490308093235427635.tmp/Blink.cpp.bin

This is a command line used by ArduinoDue IDE.

Nassa.

Next challenge is integrating additional libraries like Servo and company.
Cheers
Zad

Nassarane:
Hi Zad,

What file .h .c .cpp the ARDUINO define is it used, I don't found it ?

I resolved my Bossac problem last night in this topic : http://arduino.cc/forum/index.php/topic,141628.0.html

I used the terminal to erase the memory of the MCU :

  • I open the terminal from eclipse.
  • I close the terminal from eslipse.
  • I launch the Bossac command line from eclipse.

The software upload running...

Thanks very much Zad.

Nassa.

About the bossac problem , It seems that in the Arduino due main page, the figure displaying the arduino shows a wrong indication of the native port.
I've tried to open and close the programming port, the one near the power jack , using the Target Terminal plugin without be able to run the bossac. it works instead when the serial port is opened and closed at a rate of 1200, which shall be the behavior of the native port http://arduino.cc/en/Guide/ArduinoDue .

BTW to upload the arduinoDue without have to press the erase button I've made a little java program wich uses RXTX library. This because I don't know how automatically use the "Target Terminal Management" plugin in eclipse, if someone knows how to open and close a serial connection in eclipse using external tool configuration please let me know.
So using this little program which open the serial at 1200 , I've created a run configuration, with two external tool configurations:

First download the file in attach
and expand it inside the AduinoDueLibrary
A new directory called tools is expanded.

Create a new external tool : Run->External Tool -> External tool configurations...
Create a new program and name it as you wish , mine is ArduinoDue_eraseViaSerial
Then in Location: /usr/bin/java (Put your specific path to java)
in Working directory : the path to the expanded zip : ${workspace_loc:/ArduinoDueLib/tools/}
in Args:

-jar
${workspace_loc:/ArduinoDueLib/tools/openSerial_fat.jar}
usbmodemfd121

In place of usbmodemfd121 the specific name of the arduino port shall be used.

in the Build tab uncheck "Build before launch"
then Save.

in Eclipse menu : Run -> Run Configurations
Create a new launch groups and choose a name , I used Arduino_upload.
In the Launches tab press add and select Program->"NameYouGaveToTheReaseProcedure" and as Post Launch action select "wait until terminated"
Then add the other Program , which is the one that uses bossac.
In Common Tab is possible to show the run configuration in the preferite, I have checked it.

Save it .
It shall appear on the eclipse play icon , pushing the down arrow near it.

The java program has been tested in a OSX 1.6.0 intel 64 bit, let me know if it works also in windows, in the zip are contained dll for win32 bit , libraries and dll has been downloaded from her
http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins/
Unfortunately aren't provided 64 bit dll library , you can search them on the net if you need.
Cheers
Zad

tools.zip (223 KB)

zad80:
Next challenge is integrating additional libraries like Servo and company.
Cheers
Zad

Library Used successfully , just import from filesystem , choose the library you want to import and check the "create top level directory" just to keep the project clean.
Add the new directory inside the include
"${workspace_loc:/${ProjName}/uOLED}"
and compile.

I've try the uOLED library and here the result in attach.

Ok the image quality isn't so good, I'm sorry.

Cheers
Zad

Hi Zad,

It is not necessary to use a JAVA program to request the flash erasing.

Here's a batch for Windows to send erase flash request and upload program :

@mode com5:1200,n,8,1
@sleep 1
@C:\arduino-1.5.1r2\hardware\tools\bossac.exe %*

Copy this MS-DOS program in the "upload.bat" file and replace bossac.exe by upload.bat in your Eclipse External Tools.
(Here, it is the com5 is used, change the value and the bossac path if necessary)

You can find the equivalent for OSX / Linux.

Nassa.

Oops : you can use this simplified command line :

@mode com5:1200
@sleep 1
@C:\arduino-1.5.1r2\hardware\tools\bossac.exe %*

Nassa.

Not necessary to set your com port with this script :

@mode %2:1200
@sleep 1
@C:\arduino-1.5.1r2\hardware\tools\bossac.exe %*

Nassa.

Well, first sorry to bump this post but since my problem came using the guide posted here, I think this is the best choice.

I've followed the guide on OSX tweaking all the differences between the original Windows config to mine, and I got Eclipse to successfully build the library and the Blink project. I also followed a tip from Zad to generate a .bin file although it didn't solve my problem.
The thing is that despite the file is compiled (I think) correctly, and flashed without errors to the DUE, it doesn't work. The .hex file is 126kb and the .bin is 45kb. Any idea what can be wrong or any way I can debug it?

Anyway, thank you Nassarane for the guide, it's the only one I've found around and it's pretty straight forward.

And now my two cents:

One of the differences I encountered between Windows and OSX was the external tools part. The first tweak to Nassa's code is to change the way arguments are passed to Bossac inside the script. The unix command is $@ in stead of %*.
Then, the main change is how to erase the flash memory. If you run $ stty -f /dev/tty.usbmodemxxx 1200 from terminal it works perfectly, but it doesn't work from a script. To make it work this way you have to tweak ".Profile" file and I didn't feel like changing system files. So I came up with another solution, using a very simple Python script. You need to install Pyserial library to get it to work.

So now I have two script files: arduinoDueFlash.sh in bash, and eraseDueFlash.py in python. Here's the code:
arduinoDueFlash.sh

#!/bin/sh

python /Path/to/eraseDueFlash.py

sleep 1

/Path/to/bossac $@

eraseDueFlash.py

import serial

s = serial.Serial(port='/dev/tty.usbmodemXXX', baudrate=1200)
s.close()

It may also work a solution like Nassa's using the very argument to set the port and not to hardcode it. I'll try it eventually.

You must also check the path in the arguments you put in Eclipse:
--port=tty.usbmodem411 -U false -e -w -v -b ${workspace_loc}${project_path}/Release/${project_name}.bin -R

This works for OSX, I guess it works as well on any linux but I don't know if there's a simpler solution to open the port.

Cheers

Thanks for the good work Nassa & Zad,.
I am new to this and I followed your notes to start my work with my Arduino Due in Ubuntu 12.04,,I could build the ArduinoDueCoreLibrary with some warnings.I could build the ## ArduinoDue Blink example without errors ( I guess this [\code] at the end of the command line pattern came by mistake${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} -Wl,--start-group ${INPUTS} -Wl,--end-group[\code]. I tried with that command line pattern, got some errors and then I removed[\code] and now it is building without errors., ) and without problems I can load the .hex to the board, but the LED is not blinking.What can be the problem?Please help me to solve this.I am waiting for your reply.

What should be the size for ArduinoDueCoreLibrary?? I am getting a lib.a file with 141.6kb size.
I can build the ArduinoDueCoreLibrary without errors,5 warnings.But after that if i try to open some files say Arduino.h it is giving semantic errors like Type 'uint32_t' could not be resolved.I did something wrong???? Please help, I am struggling with this..

I just noticed your questions did you ever get things straightened out?

I have eclipse working great on Ubuntu 13.04, I'll be glad to help if you still need any.

My libarduinoDueCore.a is 115,096 bytes.

Nope, still not working. I've been using a Teensy3 on Eclipse with Nassarane's guide on PJRC forums, very similar to this one.

This time I followed exactly step by step Zad's guide, as I am also using OSX, with the same result as before.
My libArduinoDuoCore.a is 121.846 bytes (pretty similar to yours) and the Blink.bin 42.340 bytes.
It compiles well, flashes it as Arduino IDE would do, but the LED is not flashing. I don't know what else to try.

I started a web tutorial that never got finished, then didn't update it to reflect the new library format. I'll try to get it completed and post a link in the next few days.

If I remember correctly when mine looked like it was good but the sketch didn't run there were some undefined symbols in the linking stage that eclipse didn't flag as errors, I found them in the console output.

I definitely have to subscribe to this thread :stuck_out_tongue:

Here's the console output for the library:

00:27:34 **** Incremental Build of configuration Debug for project ArduinoDueLib ****
make all 
Building file: ../variants/arduino_due_x/variant.cpp
Invoking: ARM Sourcery Mac OS X GCC C++ Compiler
arm-none-eabi-g++ -Dprintf=iprintf -DF_CPU=84000000L -DARDUINO=151 -D__SAM3X8E__ -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/USB" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/variants/arduino_due_x" -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns="variants/arduino_due_x/variant.o.lst" -fno-exceptions -fno-rtti -c --param max-inline-insns-single=500 -nostdlib -MMD -MP -MF"variants/arduino_due_x/variant.d" -MT"variants/arduino_due_x/variant.d" -mcpu=cortex-m3 -mthumb -o "variants/arduino_due_x/variant.o" "../variants/arduino_due_x/variant.cpp"
../variants/arduino_due_x/variant.cpp: In function 'void init()':
../variants/arduino_due_x/variant.cpp:383: warning: comparison between signed and unsigned integer expressions
Finished building: ../variants/arduino_due_x/variant.cpp
 
Building file: ../avr/dtostrf.c
Invoking: ARM Sourcery Mac OS X GCC C Compiler
arm-none-eabi-gcc -Dprintf=iprintf -DF_CPU=84000000L -DARDUINO=151 -D__SAM3X8E__ -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/USB" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/variants/arduino_due_x" -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns="avr/dtostrf.o.lst" -c --param max-inline-insns-single=500 -nostdlib -MMD -MP -MF"avr/dtostrf.d" -MT"avr/dtostrf.d" -mcpu=cortex-m3 -mthumb -o "avr/dtostrf.o" "../avr/dtostrf.c"
../avr/dtostrf.c: In function 'dtostrf':
../avr/dtostrf.c:23: warning: implicit declaration of function 'sprintf'
../avr/dtostrf.c:23: warning: incompatible implicit declaration of built-in function 'sprintf'
In file included from ../IPAddress.cpp:3:
/Users/X/Documents/arduino-workspace/ArduinoDueLib/IPAddress.h: In member function 'IPAddress::operator uint32_t()':
/Users/X/Documents/arduino-workspace/ArduinoDueLib/IPAddress.h:51: warning: dereferencing type-punned pointer will break strict-aliasing rules
/Users/X/Documents/arduino-workspace/ArduinoDueLib/IPAddress.h: In member function 'bool IPAddress::operator==(const IPAddress&)':
/Users/X/Documents/arduino-workspace/ArduinoDueLib/IPAddress.h:52: warning: dereferencing type-punned pointer will break strict-aliasing rules
/Users/X/Documents/arduino-workspace/ArduinoDueLib/IPAddress.h:52: warning: dereferencing type-punned pointer will break strict-aliasing rules
Finished building: ../avr/dtostrf.c
 
Building file: ../main.cpp
Invoking: ARM Sourcery Mac OS X GCC C++ Compiler
arm-none-eabi-g++ -Dprintf=iprintf -DF_CPU=84000000L -DARDUINO=151 -D__SAM3X8E__ -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/USB" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/variants/arduino_due_x" -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns="main.o.lst" -fno-exceptions -fno-rtti -c --param max-inline-insns-single=500 -nostdlib -MMD -MP -MF"main.d" -MT"main.d" -mcpu=cortex-m3 -mthumb -o "main.o" "../main.cpp"
Finished building: ../main.cpp
 
Building file: ../wiring_shift.c
Invoking: ARM Sourcery Mac OS X GCC C Compiler
arm-none-eabi-gcc -Dprintf=iprintf -DF_CPU=84000000L -DARDUINO=151 -D__SAM3X8E__ -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/USB" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib" -I"/Users/X/Documents/arduino-workspace/ArduinoDueLib/variants/arduino_due_x" -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/CMSIS/Include/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/CMSIS/Device/ATMEL/ -I/Applications/Arduino-due.app/Contents/Resources/Java/hardware/arduino/sam/system/libsam/ -Os -ffunction-sections -fdata-sections -Wall -Wa,-adhlns="wiring_shift.o.lst" -c --param max-inline-insns-single=500 -nostdlib -MMD -MP -MF"wiring_shift.d" -MT"wiring_shift.d" -mcpu=cortex-m3 -mthumb -o "wiring_shift.o" "../wiring_shift.c"
Finished building: ../wiring_shift.c
 
Building target: libArduinoDueLib.a
Invoking: ARM Sourcery Mac OS X GCC Archiver
arm-none-eabi-ar -r  "libArduinoDueLib.a"  ./variants/arduino_due_x/variant.o  ./avr/dtostrf.o  ./USB/CDC.o ./USB/HID.o ./USB/USBCore.o  ./IPAddress.o ./Print.o ./Reset.o ./RingBuffer.o ./Stream.o ./UARTClass.o ./USARTClass.o ./WInterrupts.o ./WMath.o ./WString.o ./cortex_handlers.o ./cxxabi-compat.o ./hooks.o ./iar_calls_sam3.o ./itoa.o ./main.o ./syscalls_sam3.o ./wiring.o ./wiring_analog.o ./wiring_digital.o ./wiring_pulse.o ./wiring_shift.o   
Finished building target: libArduinoDueLib.a
 

00:28:05 Build Finished (took 31s.474ms)

I had to delete some stuff to meet the max characters limitation on the post

And here's console output for the published Blink.cpp:

00:39:07 **** Incremental Build of configuration Debug for project ArduinoTemplate ****
make all 
Building target: ArduinoTemplate.elf
Invoking: ARM Sourcery Mac OS X GCC C++ Linker
arm-none-eabi-g++ -L"/Users/victor/Documents/arduino-workspace/ArduinoDueLib/Debug" -L"/Users/victor/Documents/arduino-workspace/ArduinoDueLib/variants/arduino_due_x" -Wl,-Map,ArduinoTemplate.map -lm -lgcc  -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -mcpu=cortex-m3 -mthumb -o  "ArduinoTemplate.elf" -Wl,--start-group  ./Blink.o ./main.o  /Users/victor/Documents/arduino-workspace/ArduinoDueLib/Debug/syscalls_sam3.o -lArduinoDueLib -lsam_sam3x8e_gcc_rel -Wl,--end-group
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/bin/ld: warning: changing start of section .fini by 2 bytes
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/bin/ld: warning: changing start of section .fini by 2 bytes
Finished building target: ArduinoTemplate.elf
 
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/bin/ld: warning: changing start of section .fini by 2 bytes
/Users/victor/Documents/arduino-workspace/ArduinoDueLib/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a(startup_sam3xa.o): In function `Reset_Handler':
startup_sam3xa.c:(.text.Reset_Handler+0x54): warning: undefined reference to `_srelocate'
startup_sam3xa.c:(.text.Reset_Handler+0x58): warning: undefined reference to `_szero'
/Applications/Xcode.app/Contents/Developer/usr/bin/make --no-print-directory post-build
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-objcopy -O binary ArduinoTemplate.elf ArduinoTemplate.bin
 
Invoking: ARM Sourcery Mac OS X GNU Create Flash Image
arm-none-eabi-objcopy -O ihex ArduinoTemplate.elf  "ArduinoTemplate.hex"
Finished building: ArduinoTemplate.hex
 
Invoking: ARM Sourcery Mac OS X GNU Create Listing
arm-none-eabi-objdump -h -S ArduinoTemplate.elf > "ArduinoTemplate.lst"
Finished building: ArduinoTemplate.lst
startup_sam3xa.c:(.text.Reset_Handler+0x5c): warning: undefined reference to `_erelocate'
startup_sam3xa.c:(.text.Reset_Handler+0x60): warning: undefined reference to `_ezero'
 
Invoking: ARM Sourcery Mac OS X GNU Print Size
arm-none-eabi-size  --format=berkeley ArduinoTemplate.elf
   text	   data	    bss	    dec	    hex	filename
   4078	     16	    424	   4518	   11a6	ArduinoTemplate.elf
Finished building: ArduinoTemplate.siz
 
startup_sam3xa.c:(.text.Reset_Handler+0x64): warning: undefined reference to `_sfixed'

00:39:08 Build Finished (took 942ms)

Aand it's not working. I don't see anything weird except for some Warnings and the fact that something inside Eclipse is using XCode's make, but I don't know if this is usual or not

The lines in your output that show this are the undefined symbols I was talking about.

startup_sam3xa.c:(.text.Reset_Handler+0x5c): warning: undefined reference to `_erelocate'
startup_sam3xa.c:(.text.Reset_Handler+0x60): warning: undefined reference to `_ezero'

These should be marked as errors but they aren't I'm sure it is related to some of the options in the linking command but as long as my set up works I'm not going to spend much effort to find it.

In any case, you are missing the linker script, for me it is:

${workspace_loc:}/arduinosource/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld

This is in the box at the top of the dialog under Properties->C/C++ Build->Settings->ARM Sourcery Linux GCC C++ Linker->General

Your link process should look like:

Building target: blink.elf
Invoking: ARM Sourcery Linux GCC C++ Linker
arm-none-eabi-g++ -T"workspace/arduinosource/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/flash.ld" -L"workspace/arduinoDueCore/Release" -L"arduinoDueCore/arduino_due_x" -Wl,-Map,blink.map -lm -lgcc  -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -mcpu=cortex-m3 -mthumb -o  "blink.elf" -Wl,--start-group  ./src/Blink.o  workspace/arduinoDueCore/Release/syscalls_sam3.o -larduinoDueCore -lsam_sam3x8e_gcc_rel -Wl,--end-group
Finished building target: blink.elf
 
make --no-print-directory post-build
workspace/arduinosource/hardware/tools/g++_arm_none_eabi/bin/arm-none-eabi-objcopy -O binary blink.elf blink.bin
 
Invoking: ARM Sourcery Linux GNU Create Flash Image
arm-none-eabi-objcopy -O ihex blink.elf  "blink.hex"
Finished building: blink.hex
 
Invoking: ARM Sourcery Linux GNU Create Listing
arm-none-eabi-objdump -h -S blink.elf > "blink.lst"
Finished building: blink.lst

Of course your paths will be different, but the only thing I see missing is the -T ...linker_scripts/gcc/flash.ld

If you still don't get a blinking led, do a make clean before you make debug. You have the default debug and release make targets, I use only release which is also changing the paths a bit, shouldn't make any difference though.

Thank you very much! that finally solved the problem :smiley: I don't know why I forgot that, but I finally can focus on coding

Cheers

My program also compiles and downloads "successfully", but it does not run, meaning the LED does not blink. I do not have the undefined reference warnings though.

Here is some information about my development environment:
32 bit eclipse juno cdt
arduino 1.5.1r2 beta
windows 8 64bit

My compile output is too big for this post, I will break it up in the posts below.

Any help would be greatly appreciated.

Program:

#include "Arduino.h"

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;


// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

Download Output:

Status for device COM5:
-----------------------
    Baud:            1200
    Parity:          None
    Data Bits:       8
    Stop Bits:       1
    Timeout:         ON
    XON/XOFF:        OFF
    CTS handshaking: OFF
    DSR handshaking: OFF
    DSR sensitivity: OFF
    DTR circuit:     ON
    RTS circuit:     ON

      1 [main] sleep 7652 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer.  Please report this problem to
the public mailing list cygwin@cygwin.com
Erase flash
Write 27477 bytes to flash

[                              ] 0% (0/108 pages)
[==                            ] 9% (10/108 pages)
[=====                         ] 18% (20/108 pages)
[========                      ] 27% (30/108 pages)
[===========                   ] 37% (40/108 pages)
[=============                 ] 46% (50/108 pages)
[================              ] 55% (60/108 pages)
[===================           ] 64% (70/108 pages)
[======================        ] 74% (80/108 pages)
[=========================     ] 83% (90/108 pages)
[===========================   ] 92% (100/108 pages)
[==============================] 100% (108/108 pages)
Verify 27477 bytes of flash

[                              ] 0% (0/108 pages)
[==                            ] 9% (10/108 pages)
[=====                         ] 18% (20/108 pages)
[========                      ] 27% (30/108 pages)
[===========                   ] 37% (40/108 pages)
[=============                 ] 46% (50/108 pages)
[================              ] 55% (60/108 pages)
[===================           ] 64% (70/108 pages)
[======================        ] 74% (80/108 pages)
[=========================     ] 83% (90/108 pages)
[===========================   ] 92% (100/108 pages)
[==============================] 100% (108/108 pages)
Verify successful
Set boot flash true
CPU reset.

-Madison