Spark Logic

Firmata

I wanted to port Firmata to STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog boards and figured STM32duino would be the easiest path. I was able to upload a blinking programming via stlink on a nucleoF401RE board. I actually don’t need help ATM (though help is always welcome!) but posted here since there isn’t a “in progress” section. You can follow along at https://github.com/beriberikix/Arduino_STM32.

Replies20

Sat Aug 01, 2015 9:42 pm

Hi Jonathan,

I suspect that porting Fermata may not be too hard, because there is already support for the Due.

At least to start with, I would just change the code that checks for the SAM hardware, and add code to OR __STM32F1STM32F1Microcontrollers and processors…w I am not able to compile. Error message: “C:\arduino-1.6.12\hardware\Arduino_STM32\ STM32F1 \cores\maple/boards.h:39:25: fatal error: board/board.h: No such file or directory” I…View in hardware catalog __ or perhaps just replace the tests for SAM with __arm__. But you may need to do a mix of both.

Various people on this forum have ported a large number of libs, so I’m sure if you get stuck, someone will be able to help

Sun Aug 02, 2015 5:27 am

Thanks Roger! I think it’ll be pretty straight-forward as well. Just need to steal more time :) Firmata also has a HAL of sorts, which I need to decrypt, but it looks simple.

Mon Aug 10, 2015 4:01 am

I’m running into an issue where the Stream lib isn’t found (link). Any ideas?

Mon Aug 10, 2015 4:17 am

The core has Stream.h and Stream.cpp

My guess is that we don’t include Stream in quite the same place as the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog Arduion’s do.

Its included in a load of places

Arduino_STM32\STM32F1\cores\maple\HardwareSerial.h (1 hits)
Line 40: #include "Stream.h"
Arduino_STM32\STM32F1\cores\maple\Stream.cpp (1 hits)
Line 24: #include "Stream.h"
\Arduino_STM32\STM32F1\cores\maple\Stream.h (1 hits)
Line 2:   Stream.h - base class for character-based streams.
Arduino_STM32\STM32F1\cores\maple\usb_serial.h (1 hits)
Line 36: #include "Stream.h"

Mon Aug 10, 2015 2:50 pm

Added Stream.h to Firmata.h and most of the compilation errors went away. However, HardwareSerial is complaining:
/Users/me/Documents/Arduino/libraries/firmata/Firmata.cpp: In member function 'void FirmataClass::begin(long int)':
/Users/me/Documents/Arduino/libraries/firmata/Firmata.cpp:70:17: error: cannot convert 'HardwareSerial*' to 'Stream*' in assignment
FirmataStream = &Serial;

Mon Aug 10, 2015 9:11 pm

The F1 and F4 have the same ancestry, i.e libmaple, but took different routes to where we are now.

The F4 code, was forked from libmaple several years ago by the AeroQuad community, and developed separately from what leaflabs was doing on the F1 libmaple.

I did a major refactor of the F1 code when I took this whole thing on, almost a year ago, to attempt to bring libmaple in line with the Arduino 1.0 API ( as libmaple was written at the time of Arduino 0022 and not extensively updated by Leaflabs ).

@Martinaoette has done a load of work on the F4 side of things, to bring it up to Arduino 1.0 API level, but has his changes and the initial codebase are not identical for the F1 and my changes, where are still some differences between the F1 and the F4.

That being said. If you can let us know what compiles for the F1 but not the F4, or vice versa, I’d be happy to change the F4 repo, or even the F1 repo,
as long as the change didnt break any existing stuff.

Tue Aug 11, 2015 2:39 am

This error need to be investigated.
But since I don’t use HardwareSerial directly, I’ve never faced the problem.
Maybe HardwareSerial is a legacy of libmaple, that is not needed anymore, because, tell me if I’m wrong, normal Serial is using hardware port when pins match the real hardware pins.

Tue Aug 11, 2015 3:40 am

I thought hardware serial was used.

Serial is either mapped to USBSerial or Hardware serial depending on which configs you pick from the boards menu (controlled by #defines)

So.. Hardware serial is used and works.

Tue Aug 11, 2015 6:51 pm

Yesterday, I was falling to sleep, so I didn’t try to investigate.

Today, I’ve just looked at HardwareSerial of F4, and it is derived from Print not from Stream like the F1.
So, maybe it just requires to change that for both HardwareSerial and USBSerial, since same phenomena apply the this one too.
I didn’t catch this before since I didn’t had any code such Firmata that requires that and was producing the error “cannot convert ‘HardwareSerial*’ to ‘Stream*’ in assignment”.

So, @jonathanberi, maybe you can try it on your side : simple change Print to Stream in HardwareSerial.h and add #include “Stream.h”

class HardwareSerial : public Stream {

Tue Aug 11, 2015 7:43 pm

Oh insomnia – the best fix (and creator) of bugs! Let me know how & when I can help with testing.

Tue Aug 11, 2015 9:01 pm

Martin,

In the F1, I changed the Print / Steam stuff last year when i realised that the original libmaple was considerably different from the way the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog and Due Arduinos handle Print etc.

I recall needing change quite a lot of files, but I think I also did some other reorganisation at the same time, as libmaple had headers in a sub folder etc, which didn’t correspond with the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog code, so I think I took the opportunity to do a load of changes at the same time.

It was on my ToDo list, to change this myself, but I have a very long list, and it was not at the top ;-)

So thanks for looking at it..

Tue Aug 11, 2015 10:16 pm

Roger, if you don’t care if I leave the USBSerial::peek() as an empty stub for now, I think I will commit those changes soon and send you a PR.
That way, @jonathanberi will be able to continue is work with Firmata, since both HardwareSerial and USBSerial will derived from Stream.

Tue Aug 11, 2015 10:26 pm

Hi Martin

Thats fine.

Leave it empty. I may have done the same thing on the F1’s USB serial.

Tue Aug 11, 2015 10:29 pm

Ok ! Thanks ! I will probably commit later tonight …

I may have done the same thing on the F1’s USB serial.

No, you did the call to low level CDC peek(), but under F4, the CDC is completely different than the one from F1, and there is no peek() in the F4.

Tue Aug 11, 2015 10:30 pm

Hi Martin,

No worries.

I recall looking at USBSerial peek() but it was several months ago and I couldnt remember precisely what I’d done ;-)

Tue Aug 11, 2015 10:54 pm

I’ve done the commit and the PR while my souper was cooking … ;)

Tue Aug 11, 2015 11:21 pm

Martin,
The PR has been actioned.

@jonathanberi, please grab the latest copy of the repo and see if this addresses your issue.

Thanks

Wed Aug 12, 2015 12:03 am

w00t, progress! After a git pull EchoPing now compiles without error. I don’t have the board handy ATM the moment but will test it when I get home.

Now when I start trying out the different builds variations of Firmata (with different features,) I get all different, albeit useful, errors.

StandardFIrmata:

Arduino: 1.6.5 (Mac OS X), Board: "STM32 NUCLEO F401RE"

Using library Servo in folder: /Applications/Arduino.app/Contents/Java/libraries/Servo
Using library Firmata in folder: /Users/me/Documents/Arduino/libraries/firmata

WARNING: library Servo claims to run on [AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog , sam] architecture(s) and may be incompatible with your current board which runs on [STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog ] architecture(s).

/Users/me/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_NucleoNucleoDevelopment and computing boards…o have this dev board for BlueNRG at a pretty hefty price tag though, hopefully the ‘ nucleo ’ & common dev board versions would be out soon Laughing … 007v1.html oops/oh found an…View in hardware catalog _f401re -DVECT_TAB_BASE -DERROR_LED_PORT=GPIOD -DERROR_LED_PIN=14 -mcpu=Cortex-M4Cortex-M4Microcontrollers and processors… the Due form factor) e.g. … 4de7935aae Mini-version-STM32F407VET6-development-board- Cortex-M4 -STM32-minimum-system-board.jpg Mini-version-STM32F407VET6-development-board-Cortex…View in hardware catalog -DF_CPU=168000000L -DARDUINO=10605 -DARDUINO_STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog _NucleoNucleoDevelopment and computing boards…o have this dev board for BlueNRG at a pretty hefty price tag though, hopefully the ‘ nucleo ’ & common dev board versions would be out soon Laughing … 007v1.html oops/oh found an…View in hardware catalog _F401RE -DARDUINO_ARCH_STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog -DMCU_STM32F406VG -mthumb -DSTM32_HIGH_DENSITY -DSTM32F2 -DSTM32F4 -DBOARD_discovery_f4 -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog /libmaple -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog /libmaple/usbF4 -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog /libmaple/usbF4/STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog _USB_Device_Library/Core/inc -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog /libmaple/usbF4/STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog _USB_Device_Library/Class/cdc/inc -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog /libmaple/usbF4/STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog _USB_OTG_Driver/inc -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog /libmaple/usbF4/VCP -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /cores/MapleMapleDevelopment and computing boards…expensive short of buying in bulk. many resort to usb-serial converters. today comes leaflabs maple , stm32duino it is ‘disruptive’ in a similar light, user customizable usb is no…View in hardware catalog -I/Users/me/Documents/Arduino/hardware/Arduino_STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog /STM32F4STM32F4Microcontrollers and processors…uild.board' preference. Auto-set to: STM32F3_DISCOVERY_F3 Board Arduino_STM32-master: STM32F4 :discovery_f407 doesn't define a 'build.board' preference. Auto-set to: STM32F4_DISCO…View in hardware catalog /variants/NucleoNucleoDevelopment and computing boards…o have this dev board for BlueNRG at a pretty hefty price tag though, hopefully the ‘ nucleo ’ & common dev board versions would be out soon Laughing … 007v1.html oops/oh found an…View in hardware catalog _f401re -I/Applications/Arduino.app/Contents/Java/libraries/Servo/src -I/Users/me/Documents/Arduino/libraries/firmata /var/folders/00/144nr000h01000cxqpysvccm004hkq/T/build3263617536636599899.tmp/StandardFirmata.cpp -o /var/folders/00/144nr000h01000cxqpysvccm004hkq/T/build3263617536636599899.tmp/StandardFirmata.cpp.o
In file included from StandardFirmata.ino:28:0:
/Applications/Arduino.app/Contents/Java/libraries/Servo/src/Servo.h:67:2: error: #error "This library only supports boards with an AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog or SAM processor."
#error "This library only supports boards with an AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog or SAM processor."
^
StandardFirmata.ino:29:18: fatal error: Wire.h: No such file or directory
compilation terminated.
Multiple libraries were found for "Firmata.h"
Used: /Users/me/Documents/Arduino/libraries/firmata
Not used: /Applications/Arduino.app/Contents/Java/libraries/Firmata
Error compiling.

Wed Aug 12, 2015 12:10 am

martinayotte wrote:Ok ! Thanks ! I will probably commit later tonight …

I may have done the same thing on the F1’s USB serial.

No, you did the call to low level CDC peek(), but under F4, the CDC is completely different than the one from F1, and there is no peek() in the F4.

Wed Aug 12, 2015 12:35 am

re:

#error “This library only supports boards with an AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog or SAM processor.”

This is caused because one of the libs has a setting which explicitly says it only works on AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog and SAM

The only way to fix this is to update the library.

Look in the library.properties file for the library in question and you’ll see a line that says something like

architectures=avr

Post a reply

Optional · up to 10 MiB