Firmata
jonathanberi Sat Aug 01, 2015 7:56 pm
jonathanberi Sat Aug 01, 2015 7:56 pm
RogerClark Sat Aug 01, 2015 9:42 pm
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 __STM32F1__ 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
jonathanberi Sun Aug 02, 2015 5:27 am
jonathanberi Mon Aug 10, 2015 4:01 am
RogerClark Mon Aug 10, 2015 4:17 am
My guess is that we don’t include Stream in quite the same place as the AVR 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"
jonathanberi Mon Aug 10, 2015 2:50 pm
/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;
RogerClark Mon Aug 10, 2015 9:11 pm
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.
martinayotte Tue Aug 11, 2015 2:39 am
RogerClark Tue Aug 11, 2015 3:40 am
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.
martinayotte Tue Aug 11, 2015 6:51 pm
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 {
jonathanberi Tue Aug 11, 2015 7:43 pm
RogerClark Tue Aug 11, 2015 9:01 pm
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 AVR 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 AVR 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..
martinayotte Tue Aug 11, 2015 10:16 pm
RogerClark Tue Aug 11, 2015 10:26 pm
Thats fine.
Leave it empty. I may have done the same thing on the F1’s USB serial.
martinayotte Tue Aug 11, 2015 10:29 pm
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.
RogerClark Tue Aug 11, 2015 10:30 pm
No worries.
I recall looking at USBSerial peek() but it was several months ago and I couldnt remember precisely what I’d done ![]()
martinayotte Tue Aug 11, 2015 10:54 pm
RogerClark Tue Aug 11, 2015 11:21 pm
@jonathanberi, please grab the latest copy of the repo and see if this addresses your issue.
Thanks
jonathanberi Wed Aug 12, 2015 12:03 am
Now when I start trying out the different builds variations of Firmata (with different features,) I get all different, albeit useful, errors.
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 [avr, sam] architecture(s) and may be incompatible with your current board which runs on [STM32F4] 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_nucleo_f401re -DVECT_TAB_BASE -DERROR_LED_PORT=GPIOD -DERROR_LED_PIN=14 -mcpu=cortex-m4 -DF_CPU=168000000L -DARDUINO=10605 -DARDUINO_STM32F4_NUCLEO_F401RE -DARDUINO_ARCH_STM32F4 -DMCU_STM32F406VG -mthumb -DSTM32_HIGH_DENSITY -DSTM32F2 -DSTM32F4 -DBOARD_discovery_f4 -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4 -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_Device_Library/Core/inc -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_Device_Library/Class/cdc/inc -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/STM32_USB_OTG_Driver/inc -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple/libmaple/usbF4/VCP -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/cores/maple -I/Users/me/Documents/Arduino/hardware/Arduino_STM32/STM32F4/variants/nucleo_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 AVR or SAM processor."
#error "This library only supports boards with an AVR 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.
mrburnette Wed Aug 12, 2015 12:10 am
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.
RogerClark Wed Aug 12, 2015 12:35 am
#error “This library only supports boards with an AVR or SAM processor.”
This is caused because one of the libs has a setting which explicitly says it only works on AVR 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