[Q]: Tailoring the Due to Eclipse..

Hi Nassa!

Bossac doesn't work?! It happened to me, too. Are you using a USB 3 port? This could be the problem.
To fix it, just program the Arduino by using a USB 2 port or, if you don't have it, through a USB 2.0 Hub!
Cheers

I tried to follow to tutorial. But I cant build the static library I think some includes are wrong but I cant find out wich.

I got the following error log (not the complete log just this is just a small part) when trying to build. I'm on osx maybe that got something to do with it

'__disable_irq' was not declared in this scope	interrupt_sam_nvic.h	/ArduinoDueCore/src/lib/libsam/include	line 123
'__DMB' was not declared in this scope	interrupt_sam_nvic.h	/ArduinoDueCore/src/lib/libsam/include	line 123
'__enable_irq' was not declared in this scope	interrupt_sam_nvic.h	/ArduinoDueCore/src/lib/libsam/include	line 135
'_dwIrq' was not declared in this scope	USARTClass.cpp	/ArduinoDueCore/src/core	line 60
'_pUsart' was not declared in this scope	USARTClass.cpp	/ArduinoDueCore/src/core	line 43
'Adc' was not declared in this scope	adc.h	/ArduinoDueCore/src/lib/libsam/include	line 175
'Dacc' was not declared in this scope	dacc.h	/ArduinoDueCore/src/lib/libsam/include	line 67
'IRQn_Type' does not name a type	USARTClass.h	/ArduinoDueCore/src/core	line 35
'NVIC_DisableIRQ' was not declared in this scope	USARTClass.cpp	/ArduinoDueCore/src/core	line 72
'NVIC_EnableIRQ' was not declared in this scope	USARTClass.cpp	/ArduinoDueCore/src/core	line 60
'p_adc' was not declared in this scope	adc.h	/ArduinoDueCore/src/lib/libsam/include	line 173
'p_dacc' was not declared in this scope	dacc.h	/ArduinoDueCore/src/lib/libsam/include	line 66
'p_tc' was not declared in this scope	tc.h	/ArduinoDueCore/src/lib/libsam/include	line 73
'p_tc' was not declared in this scope	tc.h	/ArduinoDueCore/src/lib/libsam/include	line 71
'Pdc' does not name a type	dacc.h	/ArduinoDueCore/src/lib/libsam/include	line 70
'Pio' does not name a type	pio.h	/ArduinoDueCore/src/lib/libsam/include	line 124
'pPio' was not declared in this scope	pio.h	/ArduinoDueCore/src/lib/libsam/include	line 109
'pPwm' was not declared in this scope	pwmc.h	/ArduinoDueCore/src/lib/libsam/include	line 76

Hi Joppuh,

I do not think your problem is not OSX.
In my opinion, there are two possibilities :

Either you forgot one of the 3 defines :
SAM3X8E
USB_PID=0x003E
USBCON

Either you forgot an include path or one or more files are missing.

Warning, and include Defines Path must be set in the configuration C and C+ + (Tool Settings) :
ARM Sourcery Windows GCC C Compiler
and
ARM Sourcery Windows GCC C + + Compiler

Let me known please.

Nassa.

These are my defined symbols in C and C++ compiler
SAM3X8E
USB_PID=0x003E
USBCON

These are my included paths

"${workspace_loc:/${ProjName}/src/core}"
"${workspace_loc:/${ProjName}/src/lib/CMSIS/Device/ATMEL}"
"${workspace_loc:/${ProjName}/src/lib/CMSIS/CMSIS/Include}"
"${workspace_loc:/${ProjName}/src/lib/libsam/include}"
"${workspace_loc:/${ProjName}/src/lib/libsam}"
"${workspace_loc:/${ProjName}/src/lib/CMSIS/Device/ATMEL/sam3xa/include}"
"${workspace_loc:/${ProjName}/src/lib/variants/arduino_due_x}"

The processor Define is :
SAM3X8E
and not
SAM3X8E
There is 2 underscore before and 2 underscore after.

Could you verify ?

And let me know please.

Nassa.

Still got 135 errors but all in USBcore.cpp

But Im able to build I got a libArduinoDueCore.a in my Release folder.

But I think the linker script isnt working for de MyProject
If I build your example I only get a main.o and a syscalls_sam3.o in my release folder..

EDIT
All the errors about USBcore.ccp are could not be resolved errors like:

Field 'UOTGHS_DEVCTRL' could not be resolved

Clean your ArduinoDueCore project :

  • clean ArduinoDueCore project
  • in the "Problems" tab right click on the root errors node, when the popup is open, click on "Delete" item. You can do the same for warnings.
  • bluid ArduinoDueCore.

Build MyProject.

Nassa.

No more errors or warnings!

But nothing in the release folder of myprojects..

I'll try to make a new project

EDIT
Got a .map file in my release folder but not a hex..

Hi Nassa ,
I played a bit with arduino uno elipse integration and looking at your guide I don't see the define which says which board is beeng compiled.
In case of Aduino due it is -DARDUINO=151.
Zad

Hi Nassa,
if I well understood ,to use the PROGRAMMING port with bossac you shall use one of the two procedures reported in the AduinoDue main page. that are :

  1. pressing the erase button on the arduino while running bossac
  2. Open the serial port without bossac, which activates the Erase and Reset sequence , and then launch the bossac .

Unfortunately I can only use the bossac via command line while pressing the erase button, if I do that using the eclipse external tool it doesn't works.
I'll do a script which opens the port ,closes it and then run the bossac.

By the way, to understand how the bossac is actually run by the arduino IDE , I substituted the original bossac with a simple shell script and run the upload procedure on the IDE.
Here the code :

echo $@ >/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/bossac.arg
/Applications/Arduino-due.app/Contents/Resources/Java/hardware/tools/bossac.orig $@

Zad

I've got these error's now in myProject
These error's keep coming back I defined -L but it seems i't cant find the library or something if I build like 3 times in a row it completes but only shows the .o files

undefined reference to `digitalWrite'	main.cpp	/MyProject/src	 	C/C++ Problem
undefined reference to `USBDevice'	main.cpp	/MyProject/src	 	C/C++ Problem
undefined reference to `USBDevice_::attach()'	main.cpp	/MyProject/src	 	C/C++ Problem
undefined reference to `pinMode'	main.cpp	/MyProject/src	 	C/C++ Problem
undefined reference to `delay'	main.cpp	/MyProject/src	 	C/C++ Problem
undefined reference to `init'	main.cpp	/MyProject/src	 	C/C++ Problem

EDIT:

Fixed it now I got a elf file!

I resolved the problem with bossac in Eclipse , for some reasons ,in my case , if as first parameter in the arguments list is placed --port=tty.usbmodemfd121 the command ends with :
No device found on tty.usbmodemfd121 also when I press the erase button.
if --port is used as seconds parameter, using the erase button, eclipse and bossac run like a charm.

Erase flash
Write 9556 bytes to flash

[                              ] 0% (0/38 pages)
[=======                       ] 26% (10/38 pages)
[===============               ] 52% (20/38 pages)
[=======================       ] 78% (30/38 pages)
[==============================] 100% (38/38 pages)
Verify 9556 bytes of flash

[                              ] 0% (0/38 pages)
[=======                       ] 26% (10/38 pages)
[===============               ] 52% (20/38 pages)
[=======================       ] 78% (30/38 pages)
[==============================] 100% (38/38 pages)
Verify successful
Set boot flash true
CPU reset.

I tried to open the programming port and then to launch bossac , but I have still the uploading problem.
For the moment it works fine with the erase button.

@joppuh123:
It seems your core library doesn't contain wiring_digital.c , do you have it in yours library files? it is contained inside variants/arduino_due_x

Cheers
zad

I do got a wiring_digital.c I have it in /src/core not in variants...

I got an elf file I was able to upload the elf file but the led doesn't blink...

Is it because I dont got the -DARDUINO=151 define.

Also the library does build but is was browsing the source file and an error poped up.

Field 'PIO_OSR' could not be resolved	wiring_digital.c	/ArduinoDueCore/src/core	line 62	Semantic Error

Getting an stm32 working in eclipse is easier than this!

HI All,
finally I did it !
I'm able to build the blinky led program and upload it using the external tool all done in eclipse.
The last tiny problem is the bossac manually operation...
I've followed a different path from the one proposed by Nassa, obviously is due to him if I'm at this stage.
I will soon post how I did it .
Cheers
Zad

Congrats I'm excited to hear how you did it!

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.

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