Skip to content

Add RP2040 platform (Arduino IDE) - #1261

Merged
kriegsman merged 4 commits into
FastLED:masterfrom
somewhatlurker:rp2040
Nov 25, 2022
Merged

kriegsman merged 4 commits into
FastLED:masterfrom
somewhatlurker:rp2040

Conversation

@somewhatlurker

@somewhatlurker somewhatlurker commented Jul 22, 2021 •

Copy link
Copy Markdown
Contributor

As the title implies, this PR adds some level of support for the RP2040 platform (Raspbetty Pi Pico, etc).
Currently, I've ported fastpin for software SPI and created a version of clockless output using the platform's PIO feature (programmable state machines that let us create non-blocking output with very little overhead).

Apologies for any problems with this. I'm honestly not much of an embedded dev at all, and so far I've just been testing with a logic analyser. (don't have any spare LEDs at the moment, but that should change soon)

I'm interested in hearing any comments and feedback you may have, as well as the results of testing.

About the clockless PIO implementation:

The SDK-provided claims system is used so that resources can used without interfering with other code that behaves well and uses claims.

Resource usage per instance of ClocklessController:

  • A memory buffer equal to the size of total output bits
  • 4 instructions of program memory on the first PIO instance with an unclaimed state machine
  • Said unclaimed PIO state machine
  • One DMA channel

Additionally, one interrupt handler for DMA_IRQ_0 (configurable as shared or exclusive via FASTLED_RP2040_CLOCKLESS_IRQ_SHARED) is used regardless of how many instances are created.

Known Limitations (updated 2021-08-07 to reflect changes)

Most of these are pretty minor in my opinion, but there's no point hiding them away.

  • Only Arduino IDE (possibly only official Mbed-based core) is supported
    • There shouldn't be any actual limitation -- I just didn't have any luck trying to find a usable architecture #define created by pico-sdk (someone who knows what they're doing might have more luck).
  • Reset time between shows is longer than necessary
    • This is due to time taken to prepare and send LED data, which is spent after waiting for the previous show to end (~72us/50 LEDs + 20us/string).
  • Output is padded to 32 bits with trailing zeroes
    • While it's possible to configure PIO machines to use only 24 bits per word sent (which would avoid this for 8 bit LEDs at least), I don't see this causing much harm and it does help keep things simple.
  • There is potential to exhaust resources
    • The DMA handler may conflict with other code (can be avoided relatively easily by users adopting DMA_IRQ_1 and/or using shared IRQ handlers, but it's understandable if you'd like to avoid the chance for this to happen by default).
    • Only 8 PIO state machines exist, which means a maximum of 8 clockless strips (fewer if other code uses PIO) can run in non-blocking mode. Defining FASTLED_RP2040_CLOCKLESS_PIO as 0 will force fallback to a regular blocking implementation (m0clockless). It might also be worth looking into adding parallel output (a version of FlexibleInlineBlockClocklessController?) to reduce state machines required for multiple strings (there's an sdk example for this), but I think that might be okay to leave until a later time.
  • PIO output doesn't really run at CLOCKLESS_FREQUENCY
    • Instead it scales timings so that the largest time period is no greater than 32 cycles, and derives an appropriate internal frequency based on that. This should cause no issues, because one should still expect an output frequency in the 10s of megahertz (20~50 typical).
  • FLIP is unimplemented
    • (seems to not be unique to this platform though?)

@somewhatlurker

Copy link
Copy Markdown
Contributor Author

Admittedly, I'm not really sure how I should be using some of the defines in led_sysdefs (FASTLED_ALLOW_INTERRUPTS, FASTLED_ACCURATE_CLOCK) on a platform where they aren't really applicable. A maintainer may wish to clean them up if necessary.

@somewhatlurker

Copy link
Copy Markdown
Contributor Author

Ah, I should've realised this earlier, but the naive fastpin implementation may cause data races when performing multiple simultaneous writes.
I will update functions that rely on writing directly to the port to function similarly to pico-sdk's gpio_put_masked when I get a chance, and advise not merging until after that.

…d accidental use of wrong reg for hival,loval)
@somewhatlurker

Copy link
Copy Markdown
Contributor Author

Okay, I've had more time to look at the code and think, and my conclusion is that the root cause of the data race issue is actually no different to that which FAST_SPI_INTERRUPTS_WRITE_PINS is intended for.
My testing shows that enabling this results in little-to-no performance degradation, so I simply force enabled it for now. Masked set and fastset may be considered as a future optimisation for these cases and not essential to this PR.

Of course, there's still the matter of proper hardware SPI support, which for now is not a priority for me as I don't have a good way to check the output of it at high rates and the software implementation is at least functional.

PIO-based/M0 generic implementation is controlled by FASTLED_RP2040_CLOCKLESS_PIO
it *should* be able to automatically fall back to m0clockless from PIO automatically,
but for some reason I'm having trouble getting that to work (requires more investigation, but at least this isn't a regression)

CPU frequency should be set in F_CPU or VARIANT_MCK before including FastLED if overclocking (for m0clockless only)
(becuase we need to know frequency at compile time, but pico sets it at runtime -- it might make sense to write a custom bitbang output to work around this)

PIO timing and clock divider is now automatically scaled from input CLOCKLESS_FREQUENCY to the fastest rate possible with the PIO program's delay slots
(this simplifies timing of m0clockless by having it use CPU frequency directly)
@somewhatlurker

Copy link
Copy Markdown
Contributor Author

I decided to go ahead and add m0clockless output driver as an option for the platform. Details in latest commit message.
I've also done some testing of the PIO-based clockless implementation with some SK6812 LEDs and can confirm that it appears to be working fine. Still waiting for some buffers to arrive for testing SPI LEDs.

avoiding sideset means that we double the max instruction delay, which should increase our timing resolution
it also means that there's no longer a separately-licensed block of code included
@ATLTVHEAD

Copy link
Copy Markdown

Need any help with coding or testing? I've also been looking to use the rp2040 with FastLED.

@somewhatlurker

Copy link
Copy Markdown
Contributor Author

Help is always welcome!
I think the biggest thing left is probably still to add hardware SPI support (probably as another PIO program to allow use of any pin). Just haven't really gotten around to hooking it all up because I've been a bit busy with other stuff.
Testing the clockless implementation with all kinds of different settings wouldn't hurt though.

@ATLTVHEAD

ATLTVHEAD commented Aug 30, 2021 •

Copy link
Copy Markdown

Sounds good! I am brushing up on the PIO documentation and will be forking soon. Definitely understand being busy, haha.

I'll also go ahead and test with some LEDs, I have some neopixels, apa102's, and some sk2812s.

@LivingSynthesis

Copy link
Copy Markdown

I tried deleting my fastLED library and replacing it with the zip I got from your PR. When I try to "#include <FastLED.h>" and compile for my Raspberry pi pico it still gives the "This platform isn't recognized by FastLED... yet" error. I'm a little lost, am I doing something incorrectly?

@somewhatlurker

Copy link
Copy Markdown
Contributor Author

@LivingSynthesis That does sound correct, so I'm not entirely sure what's going on.
The error you're seeing is thrown by led_sysdefs.h, but should be avoided by the presence of the #elif defined(ARDUINO_ARCH_RP2040) line.

You might want to check that you didn't accidentally download the master branch (zip file should be named FastLED-rp2040.zip and contain src/platforms/arm/rp2040 directory), and that you don't somehow have two copies of the library installed in different locations causing a conflict.

Additionally, this PR was only tested with the official Arduino core (Arduino Mbed OS RP2040 Boards in boards manager). If you're using arduino-pico, it appears to use the same define to check arch, but I guess it might be handled differently somehow.

Could you please check these things and let us know if you get it working?

@LivingSynthesis

Copy link
Copy Markdown

@somewhatlurker So I finally got around to messing around with it some more and when I try to use your branch(correctly this time, thanks) with the official Arduino Mbed OS board it compiles correctly without error. However I haven't been using the official Arduino pico board, instead I'm using the ones contributed by Earle F. Philhower because with the official one the board goes into some weird state and I could never get it to work correctly or run any code, even blink.

So I'm a bit stuck, I can't use the library with the official board because that one doesn't work at all for me, and I can't use the library with the working board because for some reason they're not being recognized the same way! Here's the error info I get when using the Earle Board if that's helpful at all!

Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB In file included from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:14:21: note: '#pragma message: FastLED version 3.004.000' 14 | # pragma message "FastLED version 3.004.000" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:48, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:120:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 120 | inline void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:121:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 121 | inline void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:122:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 122 | inline void set(register port_t val) __attribute__ ((always_inline)) { *mPort = val; } | ^~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:124:42: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 124 | inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:124:64: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 124 | inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } | ^~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:228:44: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 228 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:229:44: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 229 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:230:41: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 230 | inline static void set(register port_t val) __attribute__ ((always_inline)) { } | ^~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:232:49: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 232 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastpin.h:232:71: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 232 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { } | ^~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:49, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi_types.h:22:82: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 22 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data) { return data; } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi_types.h:23:82: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 23 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data, register uint8_t scale) { return scale8(data, scale); } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi_types.h:23:105: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 23 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data, register uint8_t scale) { return scale8(data, scale); } | ^~~~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastled_arm_rp2040.h:5, from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms.h:35, from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:52, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:28:42: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 28 | inline static void set(register port_t val) __attribute__ ((always_inline)) { sio_hw->gpio_out = val; } | ^~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:34:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 34 | inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:35:45: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 35 | inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:36:50: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 36 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastpin_arm_rp2040.h:36:72: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 36 | inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; } | ^~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/clockless_arm_rp2040.h:5, from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms/arm/rp2040/fastled_arm_rp2040.h:6, from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/platforms.h:35, from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:52, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h: In function 'int showLedData(volatile uint32_t*, uint32_t, const uint8_t*, uint32_t, M0ClocklessData*)': c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:16:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 16 | register uint32_t scratch=0; | ^~~~~~~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:17:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 17 | register struct M0ClocklessData *base = pData; | ^~~~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:18:31: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 18 | register volatile uint32_t *port = _port; | ^~~~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:19:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 19 | register uint32_t d=0; | ^ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:20:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 20 | register uint32_t counter=num_leds; | ^~~~~~~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:21:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 21 | register uint32_t bn=0; | ^~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:22:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 22 | register uint32_t b=0; | ^ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:23:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 23 | register uint32_t bitmask = _bitmask; | ^~~~~~~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:26:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 26 | register const uint8_t *leds = _leds; | ^~~~ c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:316:40: error: 'SysTick' was not declared in this scope 316 | uint32_t ticksBeforeInterrupts = SysTick->VAL; | ^~~~~~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi.h:9, from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:65, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi_bitbang.h: At global scope: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi_bitbang.h:262:55: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 262 | template <class D> void writeBytes(register uint8_t *data, int len) { | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi_bitbang.h:307:36: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 307 | void writeBytes(register uint8_t *data, int len) { writeBytes<DATA_NOP>(data, len); } | ^~~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:65, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/fastspi.h:160:23: note: '#pragma message: Forcing software SPI - no hardware SPI for you!' 160 | # pragma message "Forcing software SPI - no hardware SPI for you!" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/FastLED.h:66, from C:\Users\Shane\AppData\Local\Temp\arduino_modified_sketch_844755\Blink.ino:1: C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/chipsets.h:88:80: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 88 | __attribute__((always_inline)) inline static uint8_t adjust(register uint8_t data) { return ((data>>1) | 0x80) + ((data && (data<254)) & 0x01); } | ^~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/chipsets.h: In member function 'virtual void LPD6803Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED>::showPixels(PixelController<RGB_ORDER>&)': C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/chipsets.h:175:31: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 175 | register uint16_t command; | ^~~~~~~ C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/chipsets.h: In member function 'void P9813Controller<DATA_PIN, CLOCK_PIN, RGB_ORDER, SPI_SPEED>::writeLed(uint8_t, uint8_t, uint8_t)': C:\Users\Shane\Documents\Arduino\libraries\FastLED-rp2040\src/chipsets.h:349:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 349 | register uint8_t top = 0xC0 | ((~b & 0xC0) >> 2) | ((~g & 0xC0) >> 4) | ((~r & 0xC0) >> 6); | ^~~ exit status 1 Error compiling for board Raspberry Pi Pico.

@somewhatlurker

Copy link
Copy Markdown
Contributor Author

Well that's some progress for sure.

The main error here is that it looks like m0clockless (existing FastLED code that I reused for operating without enough PIO state machines available) depends on SysTick being defined (which is usually done by including CMSIS headers in the build, which isn't done in a barebones pico-sdk compilation but apparently is when using Mbed).
(c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:316:40: error: 'SysTick' was not declared in this scope 316 | uint32_t ticksBeforeInterrupts = SysTick->VAL;)

I'll have to look into the possibility of directly accessing the hardware registers for it, or add an alternate implementation.

@gsexton

gsexton commented Jan 28, 2022

Copy link
Copy Markdown

I manually merged this PR into 3.5.0 and tested it on this LED project:

https://www.instructables.com/Animated-Led-Star/

and it worked as expected on an AdaFruit ItsyBitsy RP2040.

@Spegs21

Spegs21 commented Jan 29, 2022

Copy link
Copy Markdown

@kriegsman What needs to happen to get this merged?

@sanjay900

Copy link
Copy Markdown

Well that's some progress for sure.

The main error here is that it looks like m0clockless (existing FastLED code that I reused for operating without enough PIO state machines available) depends on SysTick being defined (which is usually done by including CMSIS headers in the build, which isn't done in a barebones pico-sdk compilation but apparently is when using Mbed). (c:\users\shane\documents\arduino\libraries\fastled-rp2040\src\platforms\arm\common\m0clockless.h:316:40: error: 'SysTick' was not declared in this scope 316 | uint32_t ticksBeforeInterrupts = SysTick->VAL;)

I'll have to look into the possibility of directly accessing the hardware registers for it, or add an alternate implementation.

I am currently using this with platform.io, using https://github.com/Wiz-IO/wizio-pico (which is based on a barebones pico-sdk) and was missing the Systick.
I added the following to the it, and it was enough to fix this problem:

typedef struct
{
  io_rw_32 CTRL;                   /*!< Offset: 0x000 (R/W)  SysTick Control and Status Register */
  io_rw_32 LOAD;                   /*!< Offset: 0x004 (R/W)  SysTick Reload Value Register */
  io_rw_32 VAL;                    /*!< Offset: 0x008 (R/W)  SysTick Current Value Register */
  io_rw_32 CALIB;                  /*!< Offset: 0x00C (R/ )  SysTick Calibration Register */
} SysTick_Type;

#define SysTick ((SysTick_Type*)systick_hw)

However, my issue now is that it seems this framework makes F_CPU a variable, as the cpu frequency can be changed at runtime. This breaks the CMinWait macro, as it depends on F_CPU but in this case F_CPU isn't a constant. Not really sure what the best way to fix that is.

@nmaas87

nmaas87 commented May 10, 2022

Copy link
Copy Markdown

Just tested it, works for me 👍🏻

@Zitt

Zitt commented Jun 4, 2022 •

Copy link
Copy Markdown
Contributor

Also works fine for me. Demonstrated success with Pico 2040 zero which has built in WS2812 pixel.
I applied this patch then added workaround for the -Wregister warning under PR #1395

@kriegsman
kriegsman merged commit aee28fc into FastLED:master Nov 25, 2022
@Papa-DMan Papa-DMan mentioned this pull request Feb 6, 2023
5 of 11 tasks
@markbiasotti

Copy link
Copy Markdown

I've posted about this over on the FastLED forum - It seems that FastLED 3.6.0 is supported on the Adafruit RP2040 Scorpio board when running a single strip. (pin # 16) ...but seemingly when it comes to declaring multiple strips with FastLED.addleds as in the FastLED multiple examples (ArrayOfLedArrays, MultiArrays, MultipleStripsInOneArray) (using pins 16, 17,18) I get compile errors:

172 | # pragma message "Forcing software SPI - no hardware SPI for you!"

as shown here:

In file included from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/led_sysdefs.h:38,

from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/FastLED.h:51,

from C:\Users\mbiasotti\AppData\Local\Temp.arduinoIDE-unsaved2023116-31360-kpexyq.vccpc\ArrayOfLedArrays\ArrayOfLedArrays.ino:10:

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h:87: warning: "cli" redefined

87 | #define cli() (saved_interrupt_status = save_and_disable_interrupts())

|

In file included from C:\Users\mbiasotti\AppData\Local\Temp\arduino\sketches\591ADB0B896052DFAB30F0519F463C9D\sketch\ArrayOfLedArrays.ino.cpp:1:

C:\Users\mbiasotti\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.6.1\cores\rp2040/Arduino.h:74: note: this is the location of the previous definition

74 | #define cli() noInterrupts()

|

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h:88: warning: "sei" redefined

88 | #define sei() (restore_interrupts(saved_interrupt_status))

|

C:\Users\mbiasotti\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.6.1\cores\rp2040/Arduino.h:73: note: this is the location of the previous definition

73 | #define sei() interrupts()

|

In file included from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/FastLED.h:75:

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/fastspi.h:172:23: note: '#pragma message: Forcing software SPI - no hardware SPI for you!'

172 | # pragma message "Forcing software SPI - no hardware SPI for you!"

| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

{standard input}: Assembler messages:

{standard input}:1101: Error: invalid offset, value too big (0x00000494)

exit status 1

@markbiasotti

Copy link
Copy Markdown

I've posted about this over on the FastLED forum - It seems that FastLED 3.6.0 is supported on the Adafruit RP2040 Scorpio board when running a single strip. (pin # 16) ...but seemingly when it comes to declaring multiple strips with FastLED.addleds as in the FastLED multiple examples (ArrayOfLedArrays, MultiArrays, MultipleStripsInOneArray) (using pins 16, 17,18) I get compile errors:

172 | # pragma message "Forcing software SPI - no hardware SPI for you!"

as shown here:

In file included from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/led_sysdefs.h:38,

from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/FastLED.h:51,

from C:\Users\mbiasotti\AppData\Local\Temp.arduinoIDE-unsaved2023116-31360-kpexyq.vccpc\ArrayOfLedArrays\ArrayOfLedArrays.ino:10:

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h:87: warning: "cli" redefined

87 | #define cli() (saved_interrupt_status = save_and_disable_interrupts())

|

In file included from C:\Users\mbiasotti\AppData\Local\Temp\arduino\sketches\591ADB0B896052DFAB30F0519F463C9D\sketch\ArrayOfLedArrays.ino.cpp:1:

C:\Users\mbiasotti\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.6.1\cores\rp2040/Arduino.h:74: note: this is the location of the previous definition

74 | #define cli() noInterrupts()

|

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h:88: warning: "sei" redefined

88 | #define sei() (restore_interrupts(saved_interrupt_status))

|

C:\Users\mbiasotti\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.6.1\cores\rp2040/Arduino.h:73: note: this is the location of the previous definition

73 | #define sei() interrupts()

|

In file included from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/FastLED.h:75:

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/fastspi.h:172:23: note: '#pragma message: Forcing software SPI - no hardware SPI for you!'

172 | # pragma message "Forcing software SPI - no hardware SPI for you!"

| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

{standard input}: Assembler messages:

{standard input}:1101: Error: invalid offset, value too big (0x00000494)

exit status 1

@markbiasotti

Copy link
Copy Markdown

I've posted about this over on the FastLED forum - It seems that FastLED 3.6.0 is supported on the Adafruit RP2040 Scorpio board when running a single strip. (pin # 16) ...but seemingly when it comes to declaring multiple strips with FastLED.addleds as in the FastLED multiple examples (ArrayOfLedArrays, MultiArrays, MultipleStripsInOneArray) (using pins 16, 17,18) I get compile errors:

`172 | # pragma message "Forcing software SPI - no hardware SPI for you!"

as shown here:

In file included from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/led_sysdefs.h:38,

from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/FastLED.h:51,

from C:\Users\mbiasotti\AppData\Local\Temp.arduinoIDE-unsaved2023116-31360-kpexyq.vccpc\ArrayOfLedArrays\ArrayOfLedArrays.ino:10:

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h:87: warning: "cli" redefined

87 | #define cli() (saved_interrupt_status = save_and_disable_interrupts())

|

In file included from C:\Users\mbiasotti\AppData\Local\Temp\arduino\sketches\591ADB0B896052DFAB30F0519F463C9D\sketch\ArrayOfLedArrays.ino.cpp:1:

C:\Users\mbiasotti\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.6.1\cores\rp2040/Arduino.h:74: note: this is the location of the previous definition

74 | #define cli() noInterrupts()

|

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/platforms/arm/rp2040/led_sysdefs_arm_rp2040.h:88: warning: "sei" redefined

88 | #define sei() (restore_interrupts(saved_interrupt_status))

|

C:\Users\mbiasotti\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\3.6.1\cores\rp2040/Arduino.h:73: note: this is the location of the previous definition

73 | #define sei() interrupts()

|

In file included from c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/FastLED.h:75:

c:\Users\mbiasotti\Documents\Arduino\libraries\FastLED\src/fastspi.h:172:23: note: '#pragma message: Forcing software SPI - no hardware SPI for you!'

172 | # pragma message "Forcing software SPI - no hardware SPI for you!"

| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

{standard input}: Assembler messages:

{standard input}:1101: Error: invalid offset, value too big (0x00000494)

exit status 1`

@samguyer

samguyer commented Dec 7, 2023

Copy link
Copy Markdown
Contributor

It looks to me like the only real error is the one at the end, about an invalid offset in the assembly code. Very weird.

@markbiasotti

Copy link
Copy Markdown

UPDATE: I was over on Earle Philhowers's Github and took the advice to use the Arduino MBED RP2040 core and it corrects this problem. I'm now able to run multiple strips with my Adafruit RP2040 Scorpio using FastLED.

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.