[Q]: Tailoring the Due to Eclipse..

Hi,

I found the solution to upload your programs with Eclipse.
The Arduino IDE uses Bossa Due flash programming for ARM BOSSA | shumatech.com

How to configure Eclipse:

#8. Aduino Due program loader settings:

  • In Eclipse, on the menu “Run/External Tools/External Tools Configurations…”
  • In the dialog box select on the “Program” item in the tree area, and click on the “New launch configuration” icon.
  • In the “Name” field, type “Arduino Due”.
  • In the “Main” tab, in the “Location” field, type the path: “C:\arduino-1.5.1r2\hardware\tools\bossac.exe”.
  • In the “Arguments” field, type : “--port=COM3 -U false -e -w -v -b ${project_path}\Release${project_name}.hex -R”
  • Warning, the port argument value is “COM3” change this value if your board is connected on another Com Port.
  • In the “Common” tab, enable the checkbox “External Tools”, and click on the “Apply” button.

#9. Upload program to the Arduino Due board:

#10. Connect the terminal to the Arduino Due board:

  • Modify your main.cpp file :
#define ARDUINO_MAIN
#include "Arduino.h"

#ifdef USB_SERIAL
usb_serial_class Serial;
#endif

int main(void) {
	init();

	delay(1);

#if defined(USBCON)
	USBDevice.attach();
#endif

	Serial.begin(38400);
	pinMode(13, OUTPUT);

	for (;;) {
		digitalWrite(13, HIGH);
		Serial.println("Hello World");
		delay(50);
		digitalWrite(13, LOW);
		delay(950);
	}
}
  • Compile and upload this program.
  • To open the terminal view, click on the menu “Window/Show View/Other…”.
  • In the “Show View” dialog box, in the tree area, select “Terminal/Terminal” and click on the “OK” button.
  • In the Terminal view, click on the “Settings” icon to open the “Terminal Settings” dialog box.
  • Type “Arduino Due” on the “View Title”, select “Serial” “Connection Type” select box, select the “Port”, select the “Baud Rate” to 38400 and click on the “OK” button.
  • Click on the “Connect” button, the “Hello Word” message appears every second.

Good Luck !
Nassa.

Very well documented Nassa and thanks for the effort.

Nowhere near turnkey enough for this little black duck though, let me know when we just have to do step #10 :slight_smile:


Rob

Hi Graynomad,

Thanks for your message.
Yes, I spent a lot of time, it was not easy.
For example how to uplaod a program in the board.
I used the Arduino IDE Due, I have compiled a sample program and I clicked on upload button.
As I do not have Arduino Due board, the Arduino Due IDE displays the following message: "No device found on COM3".
I did a search for text "No device found on" in the folder of the Arduino Due IDE, and I found the file bossac.exe.
I replaced this file with a small program that just prints on the stdout the arguments that are get in parameter.
I clicked on upload button on the Arduino Due IDE, and the parameter are displayed in the Arduino IDE.
In this way I got the list of parameters to use with bossac.exe.

I make an improvement on a tool chain path configuration described on the #2 Step.

If like me, you use different board with different toolchain (AVR, Teensy 3.0, Arduino Due...), you will need to modify the PATH environment variable in Windows depending on the board you are using. It is heavy!
In Eclipse, it is possible to configure environment variable to a workspace and therefore no need to change the Winwdows PATH environment variable :

  • Set the tool chain path, click in “Windows/Preferences”.
  • In the tree area in the left of “Preferences” dialog box, select “C C++/Build/Environment”.
  • On “Preferences/Environment” clicks on the “select…” button.
  • In the “Select variables” dialog box, enable checkbox of “Path” item, and click on the “OK” button.
  • Back on the “Preferences/Environment” select the “Path” item added, and click on the “Edit…” button.
  • In the “Edit variables” dialog box, add the tool chain path “C:\arduino-1.5.1r2\hardware\tools\g++_arm_none_eabi\bin” without remove the current path values, and click on the “OK” button.
  • In the “Preferences/Environment” click on the “OK” button.

Good luck

Nassa.

Hi Nassa ,
just for further reference, in the file hardware/arduino/sam/board.txt are listed all the parameters needed to upload the firmware on every boards , for example in case of arduino due

arduino_due_x_dbg.name=Arduino Due (Programming Port)
arduino_due_x_dbg.upload.tool=bossac
arduino_due_x_dbg.upload.protocol=sam-ba
arduino_due_x_dbg.upload.maximum_size=524288
arduino_due_x_dbg.upload.use_1200bps_touch=true
arduino_due_x_dbg.upload.wait_for_upload_port=false
arduino_due_x_dbg.upload.native_usb=false
arduino_due_x_dbg.build.mcu=cortex-m3
arduino_due_x_dbg.build.f_cpu=84000000L
arduino_due_x_dbg.build.core=arduino
arduino_due_x_dbg.build.extra_flags=-D__SAM3X8E__ -mthumb -DUSB_PID={build.pid} -DUSB_VID={build.vid} -DUSBCON
arduino_due_x_dbg.build.ldscript=linker_scripts/gcc/flash.ld
arduino_due_x_dbg.build.variant=arduino_due_x
arduino_due_x_dbg.build.variant_system_lib=libsam_sam3x8e_gcc_rel.a
arduino_due_x_dbg.build.vid=0x2341
arduino_due_x_dbg.build.pid=0x003e

arduino_due_x.name=Arduino Due (Native USB Port)
arduino_due_x.upload.tool=bossac
arduino_due_x.upload.protocol=sam-ba
arduino_due_x.upload.maximum_size=524288
arduino_due_x.upload.use_1200bps_touch=true
arduino_due_x.upload.wait_for_upload_port=true
arduino_due_x.upload.native_usb=true
arduino_due_x.build.mcu=cortex-m3
arduino_due_x.build.f_cpu=84000000L
arduino_due_x.build.core=arduino
arduino_due_x.build.extra_flags=-D__SAM3X8E__ -mthumb -DUSB_PID={build.pid} -DUSB_VID={build.vid} -DUSBCON
arduino_due_x.build.ldscript=linker_scripts/gcc/flash.ld
arduino_due_x.build.variant=arduino_due_x
arduino_due_x.build.variant_system_lib=libsam_sam3x8e_gcc_rel.a
arduino_due_x.build.vid=0x2341
arduino_due_x.build.pid=0x003e

hope it helps.
BR
Zad

Hi Nassa ,

thank you very much for this guide. Maybe, you should create a specific page in a "tutorial" form, in order to be easier to read and follow.
However, I've tried it on my Ubuntu machine and I've encountered some problem:

  • I had to install TM-trminal as explained in this guide How to open a serial terminal in Eclipse Juno? - Stack Overflow (via "Install new software" feature) because I couldn't locate the proper "dropin" folder
  • in #5 and #7, I think you mean "Same setting for “ARM Sourcery Windows GCC C++ Compiler/Preprocessor” and “ARM Sourcery Windows GCC C++ Compiler/Directories”" (just a typo probably)
  • in #8 I had to modify the working directory in ${project_loc}/Release/ and set the bossac parameter parameter as “--port=ttyACM0 -U false -e -w -v -b ${project_name}.hex -R”. In particular, pay attention to the ${project_loc} variable, as opposed to ${project_path} which is just relative and didn't work for me
  • the hex file is quite large: ~150kB for your "blinking" main.c example, whereas the ArduinoIDE's blink example is just ~10kB when compiled.

The last problem is particularly annoying. Can you give me some more insight?
Thank you very much for your effort!!

Oh, and by the way, I forgot to mention the most important thing:
for the main.cpp you posted, I was expecting something like a blinking LED on pin13.

However, after uploading the heavy hex, no blinking LED is present! Any idea?!?

Hi Dabbede,

For the #5 and #7 steps the correct sentence is :
Same setting for “ARM Sourcery Windows GCC C++ Compiler/Directories” and “ARM Sourcery Windows GCC C Compiler/Directories”, and click on “OK”

On the size of the binary, I think there is one or more embedded library are unnecessary. I can verify that.

When I wrote this compilation method for Eclipse, I had no Arduino Due Board. I have not tested.
Today I have an Arduino Due board but the command line Bossac for download only function 1 in 50 on my PC and I do not understand why.
I must first solve this problem.

Thanks for your test.

Nassa.

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!