Fastled: Support ATmega4809 (Arduino Uno Wifi Rev. 2, Arduino Nano Every)

Created on 9 Jan 2019  Â·  34Comments  Â·  Source: FastLED/FastLED

Hi,
I have used one of the examples from the library and tried to compile it to my new Arduino wifi rev. 2 board,but I get the following error message:


Arduino: 1.8.8 (Windows 10), Board: "Arduino Uno WiFi Rev2, ATMEGA328"

In file included from C:\Arduino Projects\libraries\FastLED\examples\ColorPalette\ColorPalette.ino:1:0:

C:\Arduino Projects\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.002.001

# pragma message "FastLED version 3.002.001"

                 ^

In file included from C:\Arduino Projects\libraries\FastLED/FastLED.h:65:0,

             from C:\Arduino Projects\libraries\FastLED\examples\ColorPalette\ColorPalette.ino:1:

C:\Arduino Projects\libraries\FastLED/fastspi.h:110:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output

# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"

                   ^

In file included from C:\Arduino Projects\libraries\FastLED/FastLED.h:48:0,

             from C:\Arduino Projects\libraries\FastLED\examples\ColorPalette\ColorPalette.ino:1:

C:\Arduino Projects\libraries\FastLED/fastpin.h: In instantiation of 'class FastPin<5u>':

C:\Arduino Projects\libraries\FastLED/platforms/avr/clockless_trinket.h:96:49: required from 'class ClocklessController<5u, 6, 8, 6, (EOrder)66u, 0, false, 10>'

C:\Arduino Projects\libraries\FastLED/chipsets.h:385:7: required from 'class WS2811Controller800Khz<5u, (EOrder)66u>'

C:\Arduino Projects\libraries\FastLED/FastLED.h:108:52: required from 'class WS2811<5u, (EOrder)66u>'

C:\Arduino Projects\libraries\FastLED/FastLED.h:295:39: required from 'static CLEDController& CFastLED::addLeds(CRGB*, int, int) [with CHIPSET = WS2811; unsigned char DATA_PIN = 5u; EOrder RGB_ORDER = (EOrder)66u]'

C:\Arduino Projects\libraries\FastLED\examples\ColorPalette\ColorPalette.ino:40:67: required from here

C:\Arduino Projects\libraries\FastLED/fastpin.h:207:2: error: static assertion failed: Invalid pin specified

static_assert(validpin(), "Invalid pin specified");

^

exit status 1

Error compiling for board Arduino Uno WiFi Rev2.

I understand that the new Wifi Rev. 2 board uses a different chip hence the pinout may not have been defined in the library yet.

Are there any simple workarrounds for this issue?

MCUs

Most helpful comment

Thank you guys for all you've done over the years.
Could you also let us know if there is a fund we can donate to, again we'd love to give back to Dan and his family since he gave us so much.

All 34 comments

Nothing simple, no - at the very least there need to be pin definitions setup in fastpin_avr.h - and that’s assuming there’s no major differences between the atmega4809 and the 32u4/328.

OK, that is beyond my skills, so I am hoping for an update to the library soon.
Thanks

I've got the same problem. I hope you'll update the library soon.
Thanks

Does someone fix this problem for himself?
At the moment I cannot use my Wifi Rev2. anymore because I need this library :)

Hi all, I've hit the same issue as well. Well, pin definitions are beyond my skills. Hopefully someone can help to update the library soon.

Same happens on the new Nano Every Board which is aswell Atmega4809.

Any news here? Sadly i can't fix that myself.

Same for me with the Arduino Nano Every. Are there plans on supporting Atmega4809?

I'm willing to contribute, but this is new ground for me.

I have a nano every board on order and will be adding support for that soon, depending on when I have time. Once I have that running I might be able to get support for the WiFi uno rev 2 without having to buy a board.

Hello Daniel, any updates on this issue? Just discovered this issue after I bought a uno wifi v2 for a project for which the code was tested OK on an older uno... Would like to help but not enough knowledge of this level of coding for Arduino.

Hi @FDelporte. I'm sorry to bring the sad news, but Dan passed away just about a month ago. As you can imagine, that's slowed everything down.
FastLED will continue, but I'm taking a bit of a break first. In the meantime, the FastLED community on Reddit is full of helpful people to assist with general questions -- although that probably doesn't help with the Uno Wifi v2 right now. Sorry to be the bearer of bad news.
-Mark

Wow @kriegsman what a very bad news! I'm working on a book and am using this library as an integration library between arduino, java and raspberry pi. Was going to try to get in contact with Dan to thank him for this fantastic piece of work. Unfortunately I'm too late for that... My condolences to his family, friends and colleagues!!!
Never mind the v2 support right now!

Thank you. It’s great to hear that you’re using FastLED in your book. I’ll let the family know that it was yet another way that Dan was helping people — and still is.

Hi @kriegsman,
I'm sure this is a difficult time and I'd like to add my voice to the chorus of the miriad of makers that loved Dan's work and felt the vacuum left by his absence.

With that in mind I think if you could tell us briefly what to do and what files to edit the community would be more than happy to help adding support to future boards.

I think we would all like to chip in to help keep his legacy alive, we just need to know what steps to take to add support to new boards, we can split the workload and figure it out on our own leaving you and your team the time to grieve without leaving many students ( like mine ) that were allured by the arduino nano every price-point stranded.

Cordially,
Jacopo

Hi and thank you for reaching out. We have family matters that are taking up a lot of our time and hearts, but FastLED is prominent in my thoughts as well. I hope to have a plan for going forward by the end of the year, at latest.
Thanks again-
-Mark

Thank you guys for all you've done over the years.
Could you also let us know if there is a fund we can donate to, again we'd love to give back to Dan and his family since he gave us so much.

I noticed that version 3.3.3 has been released. Does it work with the UNO Wifi Rev 2 now?

To the best of my knowledge, support for the Atmega4809 is still on the to-do list.
I'm going to rename this ticket to "Support for Atmega4809", and let's use this thread as a place to start gathering the information we need about this new chip so that we can support it. I suspect that once we have all the relevant Pin/Port info collected, it'll be relatively quick. So: please feel free to add links to comments on this Issue with specific info about the ATmega4809's Pin/Port mappings and such.

-> If someone else who actually has one of these boards available, and who has information about the pin/Port situation were to propose a Pull Request, I'd happily merge it.

Collecting some info here:
https://hackaday.io/project/134831-atmega4809-developing-board-project/log/143959-evolution-of-my-struggling-with-atmega4809

As a proof of AVR, it has Fuse bit!, but indeed ATmega4809 is more similar to ATXmega, not general AVR like Mega328 or Tiny series in the programming manner. (You will see if you touch this chip., like DDRB is not accepted by ATMega4809 but PORTB.DIRSET)..

  | Mega,Tiny | ATMega4809
-- | -- | --
Port direction | DDRB | PORTB.DIRSET
Value definition | PORTB | PORTB.OUTSET

Thank you for supporting this.

Hi @kriegsman,
Not sure if it helps but the datasheet is pretty extensive:
https://www.microchip.com/wwwproducts/en/ATMEGA4809

could you point us to the right section of the library documentation to learn how to help?

I'd be willing to test it with my arduino nano every but I'm not too sure where to start altering the library to add support for this specific hardware.

If such a documentation does not already exist it might be a good time investment as it would allow the community at large to jump in and contribute more.

as always thanks for all you do,
Best,
Jacopo

Is there any news on the support for ATmega4809? I got some old nano's laying around as well, but i rather use the every for my project :).

Any news on this? I am also hoping to use this on an Arduino Nano Every

maybe information on this page help with port/pin mapping
https://tomalmy.com/gpio-on-arduino-nano-every/

or have a look in file ..\packages\arduino\hardware\megaavr1.8.6cores\arduino\NANO_compat.h

/*
  ARDUINO PIN  ATMEGA 328  ATMEGA 4809
  D0           PD0         PC4 (TX1)
  D1           PD1         PC5 (RX1)
  D2           PD2         PA0
  D3           PD3         PF5
  D4           PD4         PC6
  D5           PD5         PB2
  D6           PD6         PF4
  D7           PD7         PA1
  D8           PB0         PE3
  D9           PB1         PB0
  D10          PB2         PB1
  D11          PB3         PE0 (MOSI)
  D12          PB4         PE1 (MISO)
  D13          PB5         PE2 (SCK)
  A0           PC0         PD3
  A1           PC1         PD2
  A2           PC2         PD1
  A3           PC3         PD0
  A4           PC4         PA2 (SDA)
  A5           PC5         PA3 (SCL)
  A6           ADC6        PD4
  A7           ADC7        PD5
*/

add following code to fastpin_avr.h

#elif defined(__AVR_ATmega4809__)

#define MAX_PIN 21
_FL_DEFPIN(0, 4, C); _FL_DEFPIN(1, 5, C); _FL_DEFPIN(2, 0, A); _FL_DEFPIN(3, 5, F);
_FL_DEFPIN(4, 6, C); _FL_DEFPIN(5, 2, B); _FL_DEFPIN(6, 4, F); _FL_DEFPIN(7, 1, A);
_FL_DEFPIN(8, 3, E); _FL_DEFPIN(9, 0, B); _FL_DEFPIN(10, 1, B); _FL_DEFPIN(11, 0, E);
_FL_DEFPIN(12, 1, E); _FL_DEFPIN(13, 2, E); _FL_DEFPIN(14, 3, D); _FL_DEFPIN(15, 2, D);
_FL_DEFPIN(16, 1, D); _FL_DEFPIN(17, 0, D); _FL_DEFPIN(18, 2, A); _FL_DEFPIN(19, 3, A);
_FL_DEFPIN(20, 4, D); _FL_DEFPIN(21, 5, D);

//#define SPI_DATA 11
//#define SPI_CLOCK 13
//#define SPI_SELECT 10
//#define AVR_HARDWARE_SPI 1
#define HAS_HARDWARE_PIN_SUPPORT 1

//#define SPI_UART0_DATA 1
//#define SPI_UART0_CLOCK 4

and change #define _FL_IO(L,C) and #define _FL_DEFPIN to

#if !defined(AVR_ATtinyxy7) && !defined(AVR_ATtinyxy6) && !defined(AVR_ATtinyxy4) && !defined(AVR_ATtinyxy2) && !defined(__AVR_ATmega4809__)

#define _FL_IO(L,C) _RD8(DDR ## L); _RD8(PORT ## L); _RD8(PIN ## L); _FL_DEFINE_PORT3(L, C, _R(PORT ## L));
#define _FL_DEFPIN(_PIN, BIT, L) template<> class FastPin<_PIN> : public _AVRPIN<_PIN, 1<<BIT, _R(PORT ## L), _R(DDR ## L), _R(PIN ## L)> {};

#else
// Register name equivalent (using flat names) DDRA as PORTA_DIR, PORTA as PORTA_OUT, PINA as PORTA_IN
#define _FL_IO(L,C) _RD8(PORT ## L ## _DIR); _RD8(PORT ## L ## _OUT); _RD8(PORT ## L ## _IN); _FL_DEFINE_PORT3(L, C, _R(PORT ## L ## _OUT));
#define _FL_DEFPIN(_PIN, BIT, L) template<> class FastPin<_PIN> : public _AVRPIN<_PIN, 1<<BIT, _R(PORT ## L ## _OUT), _R(PORT ## L ## _DIR), _R(PORT ## L ## _IN)> {};

#endif

also in file led_sysdefs.h change

#elif defined(__AVR__)
to
#elif defined(__AVR__) || defined(__AVR_ATmega4809__)

in clockless_trinket.h add

#if defined(__AVR_ATmega4809__)
#define ASM_VAR_PORT "r" (((PORT_t*)FastPin<DATA_PIN>::port())->OUT)
#else
#define ASM_VAR_PORT "M" (FastPin<DATA_PIN>::port() - 0x20)
#endif

and change

    [e2] "r" (e2),                      \
    [PORT] "M" (FastPin<DATA_PIN>::port()-0x20),        \
    [O0] "M" (RGB_BYTE0(RGB_ORDER)),            \

to

    [e2] "r" (e2),                  \
        [PORT] ASM_VAR_PORT,                        \
    [O0] "M" (RGB_BYTE0(RGB_ORDER)),        \

and in platform.cpp add

#if defined(__AVR_ATmega4809__)
    volatile unsigned long timer0_millis = 0;
#endif

then for me it's possible to compile and run the library with Arduino Nano Every without register emulation.
Maybe it doesn't fit in all concepts of the library, but it works. Let's call it a workaround.

SPI support is commented out, I don't have any test case to verify correct functionality.

It looks like you've figured it out Jueff, but I'm still having trouble. I haven't ever dealt with editing libraries before, and I don't understand where exactly to add the code you've given. Can you please tell me where to add the lines in fastpin_avr.h, clockless_trinket.h, and paltform.cpp?

The attached zip contains the four changed files mentioned above.

FastLED.zip

Install Release 3.3.3 and replace files with that ones in the zip.

read article https://www.arduino.cc/en/Guide/Libraries for details on libraries/locations. Chapter "Manual installation" describes where libraries are stored.

The attached zip contains the four changed files mentioned above.

FastLED.zip

Install Release 3.3.3 and replace files with that ones in the zip.

read article https://www.arduino.cc/en/Guide/Libraries for details on libraries/locations. Chapter "Manual installation" describes where libraries are stored.

Can this be merged in the official library?
My students are novices and the easier the installation, the better.
Thanks <3

and in platform.cpp add

#if defined(__AVR_ATmega4809__)
    volatile unsigned long timer0_millis = 0;
#endif

The ATmega4809 uses timer_millis instead of timer0_millis, if you add that in the leds_sysdefs.h file then it is not necessary to make this modification.

Your modifications appear to work at 16MHz and 20MHz clock speeds, but not at 8MHz or below.

Might be more logical to create a separate megaavr directory under platforms for the modified files, that way you can remove the code that is not applicable to the megaavr architecture, and not have to modify the files every time FastLED updates. Only the #includes in platforms.h and led_sysdefs.h would need to be modified with each new release.

The attached zip contains the four changed files mentioned above.
FastLED.zip
Install Release 3.3.3 and replace files with that ones in the zip.
read article https://www.arduino.cc/en/Guide/Libraries for details on libraries/locations. Chapter "Manual installation" describes where libraries are stored.

Can this be merged in the official library?
My students are novices and the easier the installation, the better.
Thanks <3

@jacopomazzoni I've ported over @Jueff 's changes in my fork and created a pull request for these.
If still relevant, you can download the zip in my fork repo while waiting for the PR.
https://github.com/ngyl88-arduino/FastLED

I've been experiencing an issue when working with an Arduino Nano Every and a WS2813 LED strip. I initially posted about the issue on FastLED's subreddit. The issue was traced down to the relationship between the Nano Every board and the modified FastLED library files I got from here. I'm posting to make you aware of the issue and also see if anyone has any ideas on how to solve the problem.

Thanks in advance.

FastLED Reddit post: https://www.reddit.com/r/FastLED/comments/hq09js/ws2813_and_arduino_nano_every_two_leds_light_for/

I've been experiencing an issue when working with an Arduino Nano Every and a WS2813 LED strip. I initially posted about the issue on FastLED's subreddit. The issue was traced down to the relationship between the Nano Every board and the modified FastLED library files I got from here. I'm posting to make you aware of the issue and also see if anyone has any ideas on how to solve the problem.

Thanks in advance.

FastLED Reddit post: https://www.reddit.com/r/FastLED/comments/hq09js/ws2813_and_arduino_nano_every_two_leds_light_for/

Hi @CalebMcDowell, I think the pin def for Arduino every might be different and not yet included in the fastpin_avr.h file. Have you try with adding a definition block for the board? The pin def from below might be helpful. Let me know if it helps. Thanks!
https://github.com/FastLED/FastLED/blob/avrmega/platforms/avrmega/fastpin_avrmega.h

To add a data point, #1050 worked for me using a Nano Every and WS2811 chips. I developed my procedure on an Uno. Here is the error when compiling against a Nano Every.

.../Arduino/libraries/FastLED/fastpin.h:210:2: error: static assertion failed: Invalid pin specified
  static_assert(validpin(), "Invalid pin specified");

Then I checked out that branch (https://github.com/ngyl88-arduino/FastLED:master) and it worked. It warns about bit banging, but that's expected.

One caveat: It did not like WS2811 driver, so I had to change this line

FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);

to this

FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);

The WS2812 is the same serial interface, so its driver works just fine with WS2811 chips.

Thank you for that @ngyl88 and @Jueff!

First off, thank you @Jueff for the port - I verified it is working on my Arduino Wifi Rev 2 to control 350 WS2812B LEDs.

I also have an Arduino Uno Rev 3, chipset ATmega328P, which I was originally using, until I wanted something I could control with a mobile app through BT.

When comparing to the Uno, I noticed that FastLED.show() is less performant on the Wifi Rev 2 by a factor of about two.

Are there performance unit/integration tests that I can run to give more details/clarity?

I'm not really familiar with the performance expectations of these two when put against each other, but I figured it was something to bring up in this git discussion.

It may be that optimization is missing in the function FastLED.show() with regards to the Wifi Rev 2, or, it may just be that the Wifi/BLE module is consuming resources behind the scenes and this is the best performance we are going to get on that board.

Anyways, I wouldn't consider it a blocker, as the library works well on the Wifi Rev 2, and I'm happy to be able to move forward with my project!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcmerlin picture marcmerlin  Â·  3Comments

raymusmunt picture raymusmunt  Â·  5Comments

Aircoookie picture Aircoookie  Â·  4Comments

mike-belcher picture mike-belcher  Â·  5Comments

dimitre picture dimitre  Â·  5Comments