FastLED / FastLED

The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.
http://fastled.io
MIT License
6.42k stars 1.63k forks source link

compilation fail for STM32F103C (Blue Pill) #741

Closed AndKe closed 5 years ago

AndKe commented 5 years ago
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.

tested FastLED 3.2.1 ... 3.2.6(current release)

@kolyshkin you surely have a working version?

kolyshkin commented 5 years ago

I took a look yesterday and I can't figure out where the hell application.h is coming from. Note that I'm not the one who added this #include statement. All in all, this is still a mystery to me :-\

I took another look, and it seems that application.h is some file which is auto-generated by Arduino.

Perhaps you can either try

  1. changing <application.h> to "application.h", or
  2. just commenting this line altogether.
kolyshkin commented 5 years ago

For the reference, this #include "applcation.h" statement was added by commit f149084f46 (by @focalintent) and later changed to #include <application.h>" (which I believe is wrong since it's supposed to be a local include) by commit 6fd236684.

@AndKe which arduino version are you using? Please try the workarounds I provided above, let us know if it helps.

kolyshkin commented 5 years ago

Well, I have removed #include <application.h> and everything seems working just fine. Not sure why it worked for me before, and if this is a correct solution.

Now I have to dig a blue pill out of my closet and give it a try )

kolyshkin commented 5 years ago

@focalintent maybe you can shed some light? It seems this #include <application.h> is some kind of leftover that needs to be removed

focalintent commented 5 years ago

The stm32 code was originally done for the particle photon boards and that platform needed the application.h - support for other stm32 variants has mostly come in from folks tweaking things to support other stm32 based boards, and they never took it out - if someone can figure out when it should be there vs when not - I’d prefer being able to gate when the include is used - otherwise I’m removing it I just open myself up to a bunch of issues complaining about things missing :)

kolyshkin commented 5 years ago

Oh, in such case it should be very easy to fix -- since the original code used STM32F10X_MD define, this is what we should use :)

@focalintent PTAL at https://github.com/FastLED/FastLED/pull/742

AndKe commented 5 years ago

I tried FastLED master, on Arduino 1.8.8

FastLED.addLeds<NEOPIXEL, RGB_FL>(leds, 0, NUM_LEDS_PER_STRIP);

RGB_FL is PAx or PBx throws this error:

/home/andre/Arduino/projects/libraries/FastLED/fastpin.h:207:2: error: static assertion failed: Invalid pin specified

certainly an improvement, but it does not seem to "understand" PA0 pr PB6 or any other ports/pins I tried.

I see the library defines blue pill pins, and fail to understand why it would not do so, with these defines:

/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=10808 -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/Mav2HoTT-bluepill.ino.cpp -o /dev/null
/
focalintent commented 5 years ago

What is the actual value for RGB_FL - if there isn’t a definition for that pin in platforms/arm/stm32/fastpin_stm32.h, then that will cause this error (for performance reasons, FastLED does its own definitions/mappings for pins to ports)

focalintent commented 5 years ago

Looking at the commit for blue pill support - it looks like it doesn’t have pin definitions for all the pins on the blue pill board (eg pins 25-28, possibly others?)

AndKe commented 5 years ago

I tried PA0...6 and PB5..9 (mentioned it before) so RGB_FL is/was PA0 , then PA1 and so on to me, it seems like all the pins I tried to use are just fine here: https://github.com/FastLED/FastLED/blob/master/platforms/arm/stm32/fastpin_arm_stm32.h#L107

focalintent commented 5 years ago

What’s the whole compiler output - there should be more context to that message to show what it thinks RGB_FL is - Also where is RGB_FL getting defined? It wasn’t referenced in the Arduino STM32 core that I found.

focalintent commented 5 years ago

Oh - also, what happens if you use integers instead of PA? I generally tell folks to use integer pins - because on some platforms D or other ways of defining pins end up not being constant expressions.

focalintent commented 5 years ago

Oh - I see what you mean, you’re defining RGB_FL to be something like PA0 - it depends on how the core/platform you’re using defines PA0 and friends. But again, I generally discourage the use of named pins vs PIN numbers (there’s a reason you never see D10 in an example, but rather just 10)

AndKe commented 5 years ago

yes, using integers build it successfully... except: "Sketch uses 96600 bytes (147%) of program storage space. Maximum is 65536 bytes"

this is kind of crazy, I had this program, with the same libraries, fit on a Atmega 328 just fine, but not on this 64k STM32 Something must be eating lots of space ?

AndKe commented 5 years ago

..if I omit FastLED library and a few kb of code related to it, I am down to 52% of space.

focalintent commented 5 years ago

That sounds odd - I wonder if the stm32 compiler is doing a poor job of pruning unreferenced code?

kolyshkin commented 5 years ago

Haha, @AndKe, you're following my steps! The reason is, you need to add a flag. Please see https://github.com/rogerclarkmelbourne/Arduino_STM32/pull/444 and https://github.com/rogerclarkmelbourne/Arduino_STM32/issues/296

AndKe commented 5 years ago

@kolyshkin "I generally tell folks to use integer pins" I tried to use integers like 10 for PA0 , 11 for PA1 , then it compiles but the application does not seem to run on microcontroller (crashes ( hangs at FastLED.addLeds) (I see it on UART activity) then I tried 14,15,16,17 for PA4,5,6,7 then it runs, but the led strips does not do anything

as for the compiler flags, I hope that becomes a permanent fix at some point, or easily selectable.