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]