Skip to content

stm32duino port (Maple, Blue Pill etc.) - #568

Merged
focalintent merged 1 commit into
FastLED:masterfrom
kolyshkin:stm32
Aug 31, 2018
Merged

focalintent merged 1 commit into
FastLED:masterfrom
kolyshkin:stm32

Conversation

@kolyshkin

Copy link
Copy Markdown
Contributor

This mostly builds on previous work for SparkCore STM32103 (Cortex M3),
and patches from Evey Quirk @evq.

Unfortunately, stm32duino distribution does not include a header
with definitions for CoreDebug registers and flags etc.
so they were added to a newly created cm3_regs.h from
https://github.com/ARM-software/CMSIS/blob/master/CMSIS/Include/core_cm3.h

Tested on my Blue Pill, works fine

@kolyshkin

Copy link
Copy Markdown
Contributor Author

Should fix #142, #531, #564

@kolyshkin

Copy link
Copy Markdown
Contributor Author

@focalintent PTAL, and let me know if I can improve anything

@thepiratebae

thepiratebae commented Apr 16, 2018 •

Copy link
Copy Markdown

@kolyshkin Works great on APA102, but when I used it on WS2813 (a clockless chipset) the animation ran half as fast as the exact same code running on Uno. Any idea could be causing that? Thanks for your work on this!

@thepiratebae

Copy link
Copy Markdown

Seems that when interrupts are disabled in order to send WS281x data then the SysTick isn't running. I set up a sketch to print seconds since program start. Each "second" took 2 seconds. When I disabled FastLED.show() the timer operated correctly. Not sure if this is an issue with this port or Arduino_STM32. I'm hoping there's a way to tweak the interrupt priority so SysTick always runs.

@focalintent

Copy link
Copy Markdown
Contributor

The stm code defaults to not allowing interrupts while writing out WS2812 style led data - you can try changing this by putting:

#define FASTLED_ALLOW_INTERRUPTS 1

before you include FastLED.h. The initial stm32 code was done for the sparkcore MCUs, and I think I defaulted to keeping interrupts disabled because some of their interrupts always ran too long, but honestly I don't fully remember.

Comment thread platforms/arm/stm32/fastpin_arm_stm32.h Resolved
@thepiratebae

Copy link
Copy Markdown

@focalintent Thanks for the suggestion. I tried allowing interrupts and it seems to fix the SysTick issue but then I experience the LED strip glitching or freezing on some animations (but not others, weirdly). I'll keep investigating.

@focalintent

Copy link
Copy Markdown
Contributor

The glitching might be a sign of the WAIT_TIME parameter being a bit off. It also might be the frame retry that attempts to happen if an interrupt takes too long, that can cause some glitching effects - the stm clockless code is out of date compared to some of the others, so comment out lines 32 and 33 in platforms/arm/stm32/clockless_arm_stm32.h:

 29   virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
 30     mWait.wait();
 31     if(!showRGBInternal(pixels)) {
 32       sei(); delayMicroseconds(WAIT_TIME); cli();
 33       showRGBInternal(pixels);
 34     }
 35     mWait.mark();
 36   }

@Yona-Appletree

Copy link
Copy Markdown

Would love to see this get merged. What work is still required here?

@focalintent

Copy link
Copy Markdown
Contributor

The pin definitions need to be fixed to be numbers, among other things

This mostly builds on previous work for SparkCore STM32103 (Cortex M3),
and patches from Evey Quirk.

Unfortunately, stm32duino distribution does not include a header
with definitions for CoreDebug registers and flags etc. (used in )
so they were added to a newly created cm3_regs.h from
https://github.com/ARM-software/CMSIS/blob/master/CMSIS/Include/core_cm3.h

[v2: changed PIN numbers to be int]

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin

Copy link
Copy Markdown
Contributor Author

The pin definitions need to be fixed to be numbers, among other things

@focalintent thank you for your review; commit updated accordingly; also rebased to current master

@focalintent
focalintent merged commit bf6b765 into FastLED:master Aug 31, 2018
@Fxlr8

Fxlr8 commented Dec 9, 2018 •

Copy link
Copy Markdown

@kolyshkin, what exactly should I do with https://github.com/ARM-software/CMSIS/blob/master/CMSIS/Include/core_cm3.h file to make things work? I get fatal error: avr/io.h: No such file or directory error every time

@Fxlr8

Fxlr8 commented Dec 13, 2018

Copy link
Copy Markdown

Maybe it was a problem with FaslLED version, I updated it and now I get fatal error: application.h: No such file or directory. Where is that file supposed to be?

@Simon-L

Simon-L commented Dec 13, 2018

Copy link
Copy Markdown

Same as what @Fxlr8 explains here!
I tried several platforms (Bluepill, also the F1 from the Discovery series) and get the same error.
It seems the first issue arises from line 22 in led_sysdefs.h:

#elif defined(STM32F10X_MD) || defined(__STM32F1__)
#include "platforms/arm/stm32/led_sysdefs_arm_stm32.h"

Where no matter which STM32 platform I select, it doesn't catch this #ifdef.
I took a close look at the compiling lines. Make sure setting "All" display for both Compiling and Upload in your arduino preferences.
Can anyone who got it working can paste the output of compiling? Specifically I'm interested in the defines that are set.

@AndKe

AndKe commented Feb 19, 2019 •

Copy link
Copy Markdown

is there any solution yet ?
blue pill with fastled 3.2.6

/home/andre/Arduino/projects/libraries/FastLED/platforms/arm/stm32/led_sysdefs_arm_stm32.h:4:25: fatal error: application.h: No such file or directory
 #include <application.h>
                         ^
compilation terminated.

@AndKe

AndKe commented Feb 20, 2019

Copy link
Copy Markdown

@Simon-L per your request:







/home/andre/Arduino/arduino-1.8.7/arduino-builder -dump-prefs -logger=machine -hardware /home/andre/Arduino/arduino-1.8.7/hardware -hardware /home/andre/.arduino15/packages -hardware /home/andre/Arduino/projects/hardware -tools /home/andre/Arduino/arduino-1.8.7/tools-builder -tools /home/andre/Arduino/arduino-1.8.7/hardware/tools/avr -tools /home/andre/.arduino15/packages -built-in-libraries /home/andre/Arduino/arduino-1.8.7/libraries -libraries /home/andre/Arduino/projects/libraries -fqbn=stm32duino:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=DFUUploadMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10807 -build-path /tmp/arduino -warnings=all -build-cache /tmp/arduino_cache_8039 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.stm32tools.path=/home/andre/.arduino15/packages/stm32duino/tools/stm32tools/2019.2.4 -prefs=runtime.tools.stm32tools-2019.2.4.path=/home/andre/.arduino15/packages/stm32duino/tools/stm32tools/2019.2.4 -prefs=runtime.tools.arm-none-eabi-gcc.path=/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -prefs=runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -verbose /home/andre/Arduino/projects/Mav-bluepill/Mav-bluepill.ino
/home/andre/Arduino/arduino-1.8.7/arduino-builder -compile -logger=machine -hardware /home/andre/Arduino/arduino-1.8.7/hardware -hardware /home/andre/.arduino15/packages -hardware /home/andre/Arduino/projects/hardware -tools /home/andre/Arduino/arduino-1.8.7/tools-builder -tools /home/andre/Arduino/arduino-1.8.7/hardware/tools/avr -tools /home/andre/.arduino15/packages -built-in-libraries /home/andre/Arduino/arduino-1.8.7/libraries -libraries /home/andre/Arduino/projects/libraries -fqbn=stm32duino:STM32F1:genericSTM32F103C:device_variant=STM32F103C8,upload_method=DFUUploadMethod,cpu_speed=speed_72mhz,opt=osstd -ide-version=10807 -build-path /tmp/arduino -warnings=all -build-cache /tmp/arduino_cache_8039 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.stm32tools.path=/home/andre/.arduino15/packages/stm32duino/tools/stm32tools/2019.2.4 -prefs=runtime.tools.stm32tools-2019.2.4.path=/home/andre/.arduino15/packages/stm32duino/tools/stm32tools/2019.2.4 -prefs=runtime.tools.arm-none-eabi-gcc.path=/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -prefs=runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1 -verbose /home/andre/Arduino/projects/Mav-bluepill/Mav-bluepill.ino
Using board 'genericSTM32F103C' from platform in folder: /home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4
Using core 'maple' from platform in folder: /home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4
Detecting libraries used...
/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10807 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/stm32f1/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/stm32f1 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/usb_lib -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/cores/maple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/variants/generic_stm32f103c /tmp/arduino/sketch/Mav-bluepill.ino.cpp -o /dev/null
/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10807 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/stm32f1/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/stm32f1 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/usb_lib -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/cores/maple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/variants/generic_stm32f103c -I/home/andre/Arduino/projects/libraries/GCS_MAVLink /tmp/arduino/sketch/Mav-bluepill.ino.cpp -o /dev/null
/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10807 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/stm32f1/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/stm32f1 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/usb_lib -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/cores/maple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/variants/generic_stm32f103c -I/home/andre/Arduino/projects/libraries/GCS_MAVLink -I/home/andre/Arduino/projects/libraries/uTimerLib/src /tmp/arduino/sketch/Mav-bluepill.ino.cpp -o /dev/null
/home/andre/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -c -g -Os -w -DDEBUG_LEVEL=DEBUG_NONE -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_generic_stm32f103c -DVECT_TAB_ADDR=0x8002000 -DERROR_LED_PORT=GPIOC -DERROR_LED_PIN=13 -w -x c++ -E -CC -mcpu=cortex-m3 -DF_CPU=72000000L -DARDUINO=10807 -DARDUINO_GENERIC_STM32F103C -DARDUINO_ARCH_STM32F1 -DSERIAL_USB -DGENERIC_BOOTLOADER -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -DMCU_STM32F103C8 -mthumb -march=armv7-m -D__STM32F1__ -DARDUINO_ARCH_STM32 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/stm32f1/include -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/stm32f1 -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/system/libmaple/usb/usb_lib -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/cores/maple -I/home/andre/.arduino15/packages/stm32duino/hardware/STM32F1/2019.2.4/variants/generic_stm32f103c -I/home/andre/Arduino/projects/libraries/GCS_MAVLink -I/home/andre/Arduino/projects/libraries/uTimerLib/src -I/home/andre/Arduino/projects/libraries/FastLED /tmp/arduino/sketch/Mav-bluepill.ino.cpp -o /dev/null
In file included from /home/andre/Arduino/projects/libraries/FastLED/led_sysdefs.h:23:0,
                 from /home/andre/Arduino/projects/libraries/FastLED/FastLED.h:41,
                 from /home/andre/Arduino/projects/Mav-bluepill/Mav-bluepill.ino:42:
/home/andre/Arduino/projects/libraries/FastLED/platforms/arm/stm32/led_sysdefs_arm_stm32.h:4:25: fatal error: application.h: No such file or directory
 #include <application.h>
                         ^
compilation terminated.
Using library GCS_MAVLink in folder: /home/andre/Arduino/projects/libraries/GCS_MAVLink (legacy)
Using library uTimerLib at version 1.1.0 in folder: /home/andre/Arduino/projects/libraries/uTimerLib 
Using library FastLED at version 3.2.6 in folder: /home/andre/Arduino/projects/libraries/FastLED 
exit status 1
Error compiling for board Generic STM32F103C series.

@kolyshkin

Copy link
Copy Markdown
Contributor Author

Please see #741 for latest discussions about #include <application.h>.

@kolyshkin

Copy link
Copy Markdown
Contributor Author

Proposed fix: #742

@zackees zackees mentioned this pull request Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants