Skip to content

Add support for STM32duino Core - #872

Closed
GianniDPC wants to merge 3 commits into
FastLED:masterfrom
GianniDPC:master
Closed

GianniDPC wants to merge 3 commits into
FastLED:masterfrom
GianniDPC:master

Conversation

@GianniDPC

Copy link
Copy Markdown

I have not tested it extensively, but this should finally fix the compile errors when using STM32duino Core for the BluePill at least.

@GianniDPC

GianniDPC commented Aug 22, 2019 •

Copy link
Copy Markdown
Author

Edit: pin numbering should work, if anyone else could test.

#else
/* Workaround for STM32duino Core.
Because F_CPU is defined in stm32_def.h */
#define CPU_F 72000000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use the defined F_CPU in stm32_def.h? It doesn't need to be redefined here - and then this way there isn't special case code for the STM32 littered everywhere (I'm trying to pull those out - and keep platform specific code/definitions in the platforms/* files/headers. There's still some that need to be cleaned out, but I'd like to minimize adding more)

@GianniDPC GianniDPC Aug 26, 2019 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this error it doesn't work the value of 'SystemCoreClock' is not usable in a constant expression

If you could help me fix this problem, I tried a few things but it didn't work. I am not very experienced in C++.

@fpistm fpistm Aug 26, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a PR to help on this issue.
stm32duino/Arduino_Core_STM32#613

See my comment here:
stm32duino/Arduino_Core_STM32#612 (comment)

any feedbacks are welcome and discussions are opened ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much every other Arduino platform has F_CPU as a compile time constant. I'd really like to not pepper the code with special casing for the stm32 (and I have a way to work around F_CPU possibly not being constant, but it is for the redesign/refactor - I don't think I'll pull it back to the FastLED 3.x tree)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but the main topics is that clock freq can change during execution then constant is no more relevant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of what FastLED does at compile time it can’t really handle the clock speed being changed dynamically (I’ll work on fixing that for some platforms with the rgbw refactor - but that is still a little bit away) - so programs using FastLED shouldn’t be changing it.

@kriegsman

Copy link
Copy Markdown
Member

It looks like the underlying stm32duino core was updated here to allow re#definition of F_CPU stm32duino/Arduino_Core_STM32@a107d29

Now that that's been merged there, what's the suggestion for merging this PR here? Any changes needed, @GianniDPC, or should this be good to merge now as-is?

Thank you for all the work on this issue! Much appreciated!

@kriegsman kriegsman self-assigned this May 25, 2020
@sallevan

sallevan commented May 30, 2020 •

Copy link
Copy Markdown

My ¢2: with slight patching of library I've un-broken software Pin access, and now able to compile FastLED library using -DFASTLED_FORCE_SOFTWARE_PINS with both STM32 cores exist: either with "official" STM32 core from ST Microelectronics or with Roger Clarke's Maple port.
Official core works fine with Fire2012 example while Roger's has issues with brightness support.

UPD: to use official STM32 core I wrote build_opt,h in Fire2012 directory with "-DF_CPU=72000000".

@sallevan

Copy link
Copy Markdown

Now that that's been merged there, what's the suggestion for merging this PR here? Any changes needed, @GianniDPC, or should this be good to merge now as-is?

I suggest to change #ifdefs and file names to conform to real life more closely. :)

For example, it's wrong to assume that all STM32F103 variants of boards will have the same pin layout, as such, one should check for, e.g, ARDUINO_BLUEPILL_F103C8 when it comes to pin definitions -- while checking for ARDUINO_ARCH_STM32 in more generic fields is pretty o.k.

@sallevan

sallevan commented May 30, 2020 •

Copy link
Copy Markdown

Official core works fine with Fire2012 example while Roger's has issues with brightness support.

Hmm...

More portions of patching brings core-independent hardware pins support for STM32, but does not change leds behaviour -- using Roger Clarke's core ends with antsy leds. :(

UPD: Downshifting MCU speed to 48 kHz resolves issue, but...

@sl1pkn07

Copy link
Copy Markdown

Hi. any update about this PR?

greetings

@ajkeeton

Copy link
Copy Markdown

Bumping. Needed this PR to get FastLED to compile for Generic STM32F1 / BluePill F103CB

@zackees

zackees commented Sep 19, 2024

Copy link
Copy Markdown
Member

BluePill boards are now supported. Will be rolled out to the public with 3.7.8

@zackees zackees closed this Sep 19, 2024
@zackees zackees reopened this Sep 19, 2024
@zackees

zackees commented Sep 19, 2024

Copy link
Copy Markdown
Member

Sorry, i thought this was an issue with the pins. It looks like this is an issue with F_CPU. Which I haven't investigated.

@zackees
zackees force-pushed the master branch 6 times, most recently from 6fdf45c to f18be6e Compare September 24, 2024 20:55
@zackees

zackees commented Oct 12, 2024

Copy link
Copy Markdown
Member

Everything looks supported now. We have the option for real time instead of F_CPU time timings for the clockless.

Bluepill seems to be working too.

I don't know even if this bug is still relevant. But I'm closing it and it can be re-opened if needed.

@zackees zackees closed this Oct 12, 2024
@lmancini

Copy link
Copy Markdown
Contributor

@zackees I think that this should be re-opened. I'm still having trouble getting the Blink example just to compile for a STM32 F103C8T6. I'm using 2.9.0 version of the core and 3.9.7 of FastLED:

Core: https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.9.0
FastLED: https://github.com/FastLED/FastLED/releases/tag/3.9.7

This gist contains the compilation error for Blink. Most errors are about SystemCoreClock not being usable in a constant expression:

error: the value of 'SystemCoreClock' is not usable in a constant expression

https://gist.github.com/lmancini/d64649624b106faf7f32c7218b424695

@lmancini

Copy link
Copy Markdown
Contributor

@zackees you pointed out that STM32 support entered in 3.7.8, so I downgraded FastLED to that, and Core to 2.8.1 which is the version which existed at the time, to check if this is a regression, but I'm still getting the same errors.

I'd be happy to provide more details to fix this!

With FastLED at @GianniDPC's PR I'm able at least to compile and get one of the LEDs of my strip to light up. I didn't do extensive testing on it but there's definitely still some value in this PR!

@zackees zackees reopened this Dec 24, 2024
@zackees

zackees commented Dec 24, 2024

Copy link
Copy Markdown
Member

Thanks, i'll check it out

@zackees

zackees commented Jan 13, 2025

Copy link
Copy Markdown
Member

Hey wanted to follow up and see if any user with the STm32 can rebase this change. I do not use this chipset and can't do any dev work on it.

@frysztak

Copy link
Copy Markdown

@lmancini are you using PlatformIO or Arduino IDE? I have used mainline FastLED (^3.7.3) just fine with PlatformIO, but Arduino IDE would give me compile errors (as far as I remember, similar to yours)

@lmancini

lmancini commented Jan 13, 2025 •

Copy link
Copy Markdown
Contributor

@zackees I quickly checked on my STM32 test board (using STM32duino core) that with FastLED 3.9.11 I can compile and run a small test program of mine, the same one which I couldn't compile before FastLED 3.9.11 . The new version works on both the Arduino IDE and PlatformIO.

Whatever changed between these two versions restored compatibility. Thanks for unknowingly fixing it! 🙂

@zackees zackees closed this Jan 13, 2025
@zackees

zackees commented Jan 13, 2025

Copy link
Copy Markdown
Member

yeah a bunch fixes went in.

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.

10 participants