STM32Duino with GNU ARM Eclipse plugin

Development environment specific, Arduino, Eclipse, VS2013,Em::Blocks etc
Post Reply
Lieven
Posts: 5
Joined: Tue Aug 16, 2016 4:07 pm

STM32Duino with GNU ARM Eclipse plugin

Post by Lieven » Thu Aug 25, 2016 10:36 pm

Looking at what was already created in this community , I didn't want to start from scratch on using STM32 Maple boards. But the Arduino IDE is not really to my liking. So spend some trial and error on getting the Source repository included in a project without changing the sources.
Don't know if someone did this before : Compile and debug STM32Duino just using Eclipse + GNU ARM Eclipse + J-LINK Segger clone
Included a word document with screenshots on the different steps and the resulting project imprtable into eclipse.
Maybe useful to someone else...

there are probably better ways, as the project includes the STM32Duino source tree.

https://we.tl/m3nt5P8CBs - Word Doc
https://we.tl/OXQvCnCvd5 - Archive of project in Eclipse ( 42 MB !)

User avatar
Rick Kimball
Posts: 945
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: STM32Duino with GNU ARM Eclipse plugin

Post by Rick Kimball » Fri Aug 26, 2016 4:06 am

I did one a few months back using the stm32 system workbench (openstm32.org) which is essentially eclipse but from an ST surrogate (AC6)

http://www.stm32duino.com/viewtopic.php?f=41&t=1054
-rick

User avatar
RogerClark
Posts: 6391
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32Duino with GNU ARM Eclipse plugin

Post by RogerClark » Fri Aug 26, 2016 6:03 am

If you use Windows, there is also the option of using Microsoft Visual Studio (Community Edition) and the Visual Micro plugin.

I don't use this myself, as I try to use open source tools where possible, but MSVC is a very fully featured IDE and some people prefer to use it for programming the Arduino.

michael_l
Posts: 336
Joined: Mon Aug 24, 2015 6:11 pm

Re: STM32Duino with GNU ARM Eclipse plugin

Post by michael_l » Fri Aug 26, 2016 12:55 pm

Thanks for sharing. Did you check the binaries they contain same binary code that was created by Arduino IDE ?

My lazy nature would like to create a script that would do the same 'semi-automatically' :D User could select the board etc. and script would do the rest and create a project for Eclipse IDE... the Eclipse project file is well structured, i.e. XML, isn't it ??

Lieven
Posts: 5
Joined: Tue Aug 16, 2016 4:07 pm

Re: STM32Duino with GNU ARM Eclipse plugin

Post by Lieven » Fri Aug 26, 2016 6:05 pm

The code of the blink example compiled, linked and runned correctly, so I was pleased with the result.

To get exactly the same binary there are so many options on compiler and linker level, it's very unlikely to come out with the same result between eclipse build and arduino ide build.

your idea of generating the xml files from eclipse ( .project,.cproject ) by a script based on a working template would certainly be feasible and help all variants to be generated, thanks to the structure of directories and filenames this would be not too difficult. I leave this to the reader as an exercise. ;)

working on a stm32 bootloader through wifi ( esp8266 ) to be integrated now.

Lieven
Posts: 5
Joined: Tue Aug 16, 2016 4:07 pm

Re: STM32Duino with GNU ARM Eclipse plugin

Post by Lieven » Sun Aug 28, 2016 8:59 am

Blink hello world works, but ...

USB Serial doesn't seem to work properly. USB interrupt functions inside code are called,installed the drivers from STM32DUINO, nut no device appears
On WIndows : USB Device not recognized.In device Manager asking for Hardware id's. shows USB\UNKNOWN. Would expect at least VID & PID
Running Windows 7.

Guess I'm still missing something..

Any idea's ?

Same hardware worked fine with cdc_acm on opencm3.

Code: Select all

#include <Arduino.h>
#include <usb_serial.h>

const int led = PB1;

void setup(void) {
	pinMode(led, OUTPUT);
	digitalWrite(led, 1); // turn led off
	Serial1.begin(115200);
	// Initialize virtual COM over USB on Maple Mini
	Serial.begin(9600); // BAUD has no effect on USB serial: placeholder for physical UART
	// wait for serial monitor to be connected.

	while (!(Serial.isConnected() && (Serial.getDTR() || Serial.getRTS()))) {
		// toggleLED();     // <--- retired function can be user replaced
		delay(100);         // fast blink
	}
}

void loop(void) {
	while (Serial.isConnected() && Serial.available()) {
		Serial1.write(Serial.read());
	}
	Serial1.println(" The quick brown fox jumps over the lazy dog.");
	digitalWrite(led, 0); // turn led on
	delay(100);
	digitalWrite(led, 1); // turn led off
	delay(900);
}

Honig
Posts: 1
Joined: Fri Aug 19, 2016 12:31 pm

Re: STM32Duino with GNU ARM Eclipse plugin

Post by Honig » Sun Aug 28, 2016 10:14 am

Dear Lieven,

Many thanks for this sharing! Since I am a newbie to STM32 world, what you have
shared is very useful to me.

I directly import the existing project "maple_template" to my eclipse
workspace, clean project and re-compile:

Eclipse IDE for C/C++ Developers
-------------------
Version: Neon Release (4.6.0)
Build id: 20160613-1800


Erros (4 items)
-------------------

Code: Select all

Description	Resource	Path	Location	Type
call of overloaded 'utoa(unsigned char&, char [9], unsigned char&)' is ambiguous	WString.cpp	/maple_template/Arduino_STM32/STM32F1/cores/maple	line 74	C/C++ Problem
recipe for target 'Arduino_STM32/STM32F1/cores/maple/WString.o' failed	subdir.mk	/maple_template/Debug/Arduino_STM32/STM32F1/cores/maple	line 73	C/C++ Problem
conflicting declaration of C function 'char* utoa(long unsigned int, char*, int)'	itoa.h	/maple_template/Arduino_STM32/STM32F1/cores/maple	line 34	C/C++ Problem
make: *** [Arduino_STM32/STM32F1/cores/maple/WString.o] Error 1	maple_template		 	C/C++ Problem

Warnings (27 items)
---------------------

Code: Select all

Description	Resource	Path	Location	Type
comparison between signed and unsigned integer expressions [-Wsign-compare]	usb_cdcacm.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple/usb/stm32f1	line 489	C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare]	usb_cdcacm.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple/usb/stm32f1	line 473	C/C++ Problem
unused parameter 'exitcode' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 173	C/C++ Problem
unused parameter 'f' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 168	C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 161	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 158	C/C++ Problem
unused variable 'tmp' [-Wunused-variable]	gpio_f1.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple	line 145	C/C++ Problem
unused parameter 'c' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 115	C/C++ Problem
unused parameter 'cnt' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 109	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 109	C/C++ Problem
unused parameter 'ignored' [-Wunused-parameter]	adc_f1.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple	line 105	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 100	C/C++ Problem
unused parameter 'pos' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 100	C/C++ Problem
unused parameter 'whence' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 100	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 96	C/C++ Problem
missing initializer for member 'stm32_pin_info::pinMode' [-Wmissing-field-initializers]	board.cpp	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini	line 94	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 92	C/C++ Problem
unused parameter 'method' [-Wunused-parameter]	util.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple	line 91	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 87	C/C++ Problem
unused parameter 'fd' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 83	C/C++ Problem
unused parameter 'flags' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 79	C/C++ Problem
unused parameter 'path' [-Wunused-parameter]	syscalls.c	/maple_template/Arduino_STM32/STM32F1/variants/maple_mini/wirish	line 79	C/C++ Problem
#warning USB CDC ACM relies on LeafLabs board-specific configuration. You may have problems on non-LeafLabs boards. [-Wcpp]	usb_cdcacm.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple/usb/stm32f1	line 65	C/C++ Problem
comparison between signed and unsigned integer expressions [-Wsign-compare]	rcc.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple	line 64	C/C++ Problem
unused parameter 'dev' [-Wunused-parameter]	i2c.h	/maple_template/Arduino_STM32/STM32F1/system/libmaple/stm32f1/include/series	line 62	C/C++ Problem
unused parameter 'ignored' [-Wunused-parameter]	spi_f1.c	/maple_template/Arduino_STM32/STM32F1/cores/maple/libmaple	line 57	C/C++ Problem
unused parameter 'state' [-Wunused-parameter]	wiring_pulse_f1.cpp	/maple_template/Arduino_STM32/STM32F1/cores/maple/stm32f1	line 29	C/C++ Problem

Infos (3 items)
---------------------

Code: Select all

Description	Resource	Path	Location	Type
candidate: char* utoa(unsigned int, char*, int)	maple_template		line 204, external location: d:\program files (x86)\gnu tools arm embedded\5.4 2016q2\arm-none-eabi\include\stdlib.h	C/C++ Problem
previous declaration 'char* utoa(unsigned int, char*, int)'	maple_template		line 204, external location: d:\program files (x86)\gnu tools arm embedded\5.4 2016q2\arm-none-eabi\include\stdlib.h	C/C++ Problem
candidate: char* utoa(long unsigned int, char*, int)	itoa.h	/maple_template/Arduino_STM32/STM32F1/cores/maple	line 34	C/C++ Problem
I did not modify any file, simply extracted the compressed file.

Sorry for my newbie question...

Thank you and Best regards,
Honig

Lieven
Posts: 5
Joined: Tue Aug 16, 2016 4:07 pm

Re: STM32Duino with GNU ARM Eclipse plugin

Post by Lieven » Sun Aug 28, 2016 11:25 am

Dear Honig,

thanks for reporting, indeed my description didn't cover all :
1/ The warnings you can ignore. All these unused parameter warnings can be avoided by setting compiler option -Wunused-parameter or that the code of Roger gets some cosmetic cleanup to avoid these warnings. ;) ( Hope he is listening )
2/ The error : on itoa and utoa comes from the fact that there are conflicting/ambigious definitions for these functions : with STM32_Arduino and within the standard libraries of the c compiler. Where the first argument is an "int" vs "long int" , doesn't really make a difference because both are 32bits
I'll have to check how I corrected this part. Forgotten in the overview. When you pass this function and argument of char, the compiler doesn't know to which version this needs casting.

One way to solve this that everywhere this function is called , you make an explicit cast. Or that one of both versions is not part of the compile.

I'll come back on this one.
regards
Lieven

Lieven
Posts: 5
Joined: Tue Aug 16, 2016 4:07 pm

Re: STM32Duino with GNU ARM Eclipse plugin

Post by Lieven » Sun Aug 28, 2016 10:50 pm

Dear Honig,

a bit closer to understanding why you had errors on "utoa" redeclaration. Apparently you were using a more recent version og GNU ARM gcc : 5.4 2016q2.

I was using the version : 4.8 2014q2.
The difference is that your more recent version 5.4 includes "utoa" function in the standard libraries, coming in conflict with the stm32duino one.
So I upgraded also to your version.

To solve this I changed itoa.h :
before : extern char* utoa( unsigned long value, char *string, int radix ) ;
after : extern char* utoa( unsigned value, char *string, int radix ) ;

And excluded itoa.c from the build. Right Click the file in the eclispe navigator -> C++ Build -> setting -> exclude from build.

That should compile completely. You can find it here : https://github.com/vortex314/workspace_2016

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests