Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APA102 don´t work with LAN8720 (WT32-ETH01) #2542

Closed
1 task done
AVRnet opened this issue Feb 12, 2022 · 39 comments
Closed
1 task done

APA102 don´t work with LAN8720 (WT32-ETH01) #2542

AVRnet opened this issue Feb 12, 2022 · 39 comments
Labels

Comments

@AVRnet
Copy link

AVRnet commented Feb 12, 2022

What happened?

With actual build 2112080 i have a problem to bring WT32-ETH01 LAN Interface work together with APA102 LEDs.

To Reproduce Bug

Configured LAN Interface (W32-ETH01) and selection of APA102 with save, the Modul run into bootloop and AccessPoint go up.

Expected Behavior

LAN Interface is configured and works amazing with WS281x and SK6812 LEDs.

Install Method

Binary from WLED.me

What version of WLED?

2112080

Which microcontroller/board are you seeing the problem on?

ESP8266, ESP32

Relevant log/trace output

No response

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@AVRnet AVRnet added the bug label Feb 12, 2022
@blazoncek
Copy link
Collaborator

Use GPIO pins that do not conflict.

@AVRnet
Copy link
Author

AVRnet commented Feb 15, 2022

I have tested all kinds of GPIO combinations.
Only WLAN works flawless with APA102 Chips.
I couldn´t have done with W32-ETH01 and APA102 to use the LAN port.

Setup with WS281x and SK6812 LEDs works however perfect.

@blazoncek
Copy link
Collaborator

Try lowering SPI speed by changing DotStarSpiHzMethod; in bus_wrapper.h

@lechk82
Copy link

lechk82 commented Mar 21, 2022

I'm having the same issue. lowering SPI speed does not help. Did you solve the problem?

@AVRnet
Copy link
Author

AVRnet commented Mar 22, 2022

I'm afraid not. I haven´t got any idea to solve the problem.

@lucasheld
Copy link

I also have the same problem.
I am using WS2801 LED strips with an ESP32 dev board and a LAN8720 module. The GPIO pins were connected as on a WT32-EHT01, so WLED works without adjustment with the provided binary.
All LED strips that require only one pin can be selected without any problems. As soon as a LED strip is selected that needs clock and data pins, Ethernet does not work anymore and the access point is started. Only after selecting another LED strip Ethernet works again.
No possible GPOI combination works. Also reducing the SPI speed does not change anything.
To reproduce the behavior the LED strip does not have to be present and connected, the selection in the web interface is sufficient.

@blazoncek
Copy link
Collaborator

SPI is used exclusively for driving APA102 (or other SPI) LEDs.
No other SPI device can currently coexist with SPI LEDs.

@lucasheld
Copy link

As far as I know, the LAN8720 module does not use SPI at all, but RMII. Accordingly SPI should be available for the LEDs right?

@d3473r
Copy link

d3473r commented Jun 29, 2022

I bought a WT32-EHT01 to run a WS2801 strip and I'm now facing the same issue, ethernet not working as soon as WS2801 is selected in WLED.

The datasheet mentions RMII not SPI as @lucasheld mentioned.
Maybe someone who speakes chinese can help with the datasheet?
WT32-ETH01规格书V1.2.pdf

@lucasheld
Copy link

@d3473r
The datasheet is also available in english.
WT32-ETH01_datasheet_V1.1- en.pdf

@ywwg
Copy link

ywwg commented Aug 22, 2022

image

@ywwg
Copy link

ywwg commented Sep 17, 2022

Can confirm, as soon as I set LED type to APA102 ethernet stops working. Also I am using software SPI, because I can change the GPIO pins at will

@BlackBird77
Copy link

BlackBird77 commented Sep 30, 2022

Hi All..

i can confirm it too but on the Olimex POE Boards..

If you use SPI LEDs and Ethernet it is not working..

Here are the modes:
DotStarMethod: OK but Software only
DotStarEsp32DmaVspiMethod: OK but to fast
DotStarEsp32DmaVspi1MhzMethod: OK perfect
DotStarSpiMethod: NotOK should work, but it did not...
DotStarVspiMethod: NotOK should work, but it did not...
DotStarEsp32DmaHspiMethod: NotOK because it conflicts with ethernet port
DotStarHspiMethod: NotOK because it conflicts with ethernet port

Happy lights
André

@blazoncek
Copy link
Collaborator

WLED uses HSPI for driving LEDs as VSPI may be used by other devices.

@BlackBird77
Copy link

WLED uses HSPI for driving LEDs as VSPI may be used by other devices.

On the Olimex Board is the ethernet controller on Hspi and the SD Card on Vspi.. If you don't use a external SD card you can drive the Leds on Vspi..

And if i read the code right, the Arduino default is also Vspi, but it initializes only some spi IO pins and not the QuadHD, QuadWP Pins of Vspi.

The Esp32 DMA SPI mode initializes all Vspi pins and deactivate the unused pins..

@zigomatichub
Copy link

zigomatichub commented Oct 26, 2022

I'm having issue with WT32-ETH01 too but not using the APA ledstrip (I don't have APA connected but only configured with GPIO 2 and 4).

It's only work at the configuration time. I have compiled some versions and doing a lot of testing and still searching how to solve the issue I'm facing. I'm interested into WledSR with I2S but I'm facing the same behavior in fact with native aircookie wled version.

Here the output at configuration time : (from wifi setup - experimental - ethernet : none to wt32-eth01 -> save)
image

  1. WLED without Lan configured starting in Wifi (cable removed as well , if not it's seems logicaly different)
lastReconnectAttempt == 0

Access point disabled (init).
Connecting to wifi...
Connected! IP address: 10.0.4.103

  1. I put the LAN cable -> no green/yellow LAN Led - no connectivity (as foreseen)

  2. WLED: change config and activate the LAN and save

initE: Attempting ETH config: 1
initC: *** Ethernet successfully configured! ***
ETH StartedWriting settings to /wsec.json...
Writing settings to /cfg.json...
Forcing reconnect.
WS client disconnected.
Access point disabled (init).
Connecting to wifi...
Connected! IP address: 10.0.4.103
Init STA interfaces
mDNS started
Not-Found HTTP call:
URI: /presets.json
FileRead: /presets.json
ETH ConnectedDisconnected!
Access point disabled (init).
Connecting to wifi...
Last reconnect too old.
Access point disabled (init).
Connecting to wifi...

Connected! IP address: 10.0.4.109

--> The WLED is now connected in LAN. Strange to see ETH ConnectedDisconnected! but you see the screenshot above and the IP adrress is moving from 103 (wifi) to 109 (Lan)

  1. If I power OFF, ON:
initC: *** Ethernet successfully configured! ***
Removing all.
lastReconnectAttempt == 0
Access point disabled (init).
Connecting to wifi...

Connected! IP address: 10.0.4.103
Init STA interfaces
mDNS started
ETH ConnectedDisconnected!
Access point disabled (init).
Connecting to wifi...
Last reconnect too old.
Access point disabled (init).
Connecting to wifi...
Last reconnect too old.
Access point disabled (init).
Connecting to wifi...

Connected! IP address: 10.0.4.103

I can't achieve to have LAN connection at this point.

During the process, I didn't modify any GPIO. So for me it's not really linked directly except may be at boot time where may be we need to have something initialized upfront. Can you provide some ideas for further investigation on this ?

PS: If I configure 2 output with ledstrip ws281x using GPIO 2 and 4 , I don't have the issue.
It's seems link with APA technology but also same with I2S using GPIO 12,14,15 with ws281x ledstrip. But this not explain why it's working at configuration time vs boot time not

@softhack007
Copy link
Collaborator

softhack007 commented Oct 27, 2022

Another idea - possibly related to flash speed?
We've seen random flickering in v0.13.2 and v0.14.0 that disappeared after adding these lines (platformio.ini):

board_build.f_flash = 80000000L
board_build.flash_mode = qio

It could also be the other way around: in case you already use firmware for 80Mhz, then maybe the flash on the WT32-ETH01 does not run reliably at 80mhz, and building for 40Mhz might help.

@zigomatichub
Copy link

zigomatichub commented Oct 28, 2022

The WT32-ETH01 use a chip WT32-S1 where in the datasheet, I found this: On-board clock 40 MHz crystal.
I don't think it's the ESP speed but may be it's a limitation.
I will continue some research on that with the 2 parameters mentionned and test multiple firmware. I will take some days.
But I'm still having a trouble here because I still don't know why at configuration time, it works for xx hours without issue. Then rebooting give direct issue !

@zigomatichub
Copy link

I tried with this compile option but same issue. Working fine at configuration time but not after the reboot.

[env:esp32_eth]
board = esp32-poe
platform = ${esp32.platform}
platform_packages = ${esp32.platform_packages}
upload_speed = 921600
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32_Ethernet -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1 -D WLED_DISABLE_BLYNK -D WLED_DISABLE_HUESYNC -D WLED_DISABLE_ALEXA -D WLED_DISABLE_INFRARED -D WLED_DEBUG -D USERMOD_MULTI_RELAY -D USERMOD_AUDIOREACTIVE
lib_deps = 
 ${esp32.lib_deps}
 https://github.com/blazoncek/arduinoFFT.git
board_build.partitions = ${esp32.default_partitions}
board_build.f_flash = 80000000L
board_build.flash_mode = qio

@zigomatichub
Copy link

Today I compiled again with the main branch (71d84fe) with same configuration but I erase completely the flash + esp32_bootloader_v4.bin.
I get very positive result now. With ws281x, it works. When I change to APA102, save button then it's nok. After a reboot, it never goes to LAN but use wifi instead.
In other to have again running with WS281x , I have to disconnect the cable , removed the Lan configuration, and then put back the Lan configuration.
Do you think writing APA config erase something on LAN config ?

@softhack007
Copy link
Collaborator

softhack007 commented Nov 9, 2022

When I change to APA102, save button then it's nok.

Could be a hardware conflict between APA102 and LAN driver, for example:

  • GPIO you selected for APA102 are needed also for the LAN interface.
  • conflicts in SPI driver, like vspi vs hspi

It could explain your observation that it's not working after reboot, if LED drivers are initialized before the LAN driver, so they can "steal" hardware ressources and the LAN driver is not able any more to initialize.

@zigomatichub
Copy link

zigomatichub commented Nov 9, 2022

But I tried with the same PIN with 2 data lines with WS281x (on IO2 and IO4 like for APA102 but which are used one for data -IO2 /CLK - IO4 )
2 data line are OK but one data + one clock is NOK. so strange no ?

Not the datasheet of the wt32-eth01 but it use the wt32-s1 ... I hope to have the same spec.

Conflict with HSPIHD and HSPIWP ? But this is used by LAN but don't explain why it works in ws2812 :) ???

image

OR it's because LAN use clock oscillator ?
image
that may be use into APA102 library ?

Here LAN datasheet where they show what is go IN/OUT from the RMII
image

Finally here the RMII
image

IO4 is TX_ER in this datasheet but it's not mentionned in wt32-eth01 datasheet... difficult to see on the pcb. But why it works in W281x ... That is funny :)

From a PCB research perspective, I don't see any TXER as pin from the chip. I guess there is no physical connection from the chip to IO4
image

@zigomatichub
Copy link

zigomatichub commented Nov 9, 2022

I tried reversing clk io2 / data io4 --> Nok as well.

APA102 code do something (HSPI related) that LAN don't like but I would not go into the direction of GPIO allocation issue because it's used by LAN :)

@nwalke
Copy link

nwalke commented Nov 11, 2022

I'm running a QuinLED-ESP32 ethernet board and experiencing the same (guess I'm not sure if the chip that uses is LAN8720 or not) with APA102 strips breaking ethernet communication.

@BlackBird77
Copy link

BlackBird77 commented Nov 11, 2022 via email

@benkuper
Copy link

Same problem here, did anybody find a solution ?

@BlackBird77
Copy link

BlackBird77 commented Mar 11, 2023 via email

@blazoncek
Copy link
Collaborator

@BlackBird77 why don't you make a PR for your findings?
Please.

@benkuper
Copy link

DMA Driver for SPI, looked in few places and didn't find any clear way of doing it for WLED... any pointers on where to look ?
Thank you

@BlackBird77
Copy link

BlackBird77 commented Mar 11, 2023 via email

@blazoncek
Copy link
Collaborator

It is only configuration.. Nothing complicated. You have to disable the standard SPI driver and use the DMA SPI driver.

Not everyone knows everything. Please.

@benkuper
Copy link

benkuper commented Mar 11, 2023

Ok thanks, sorry if I was not clear by saying that searching led me to nothing, and as a developer for software that people keeping asking "dumb" questions about, I know how this will feel but still :
Would it be possible to give a bit more information, like file to modify and some lines of code ? Or a link to whoever would have already done that.

Looking for SPI, DMA in the code didn't lead as well to interesting or understandable enough content for me to be comfortable modifying, didn't find anything online of people successfully doing that.. is it on the arduino/pio side, or wled specific code, is it a compile option or some deeper things to comment, uncomment... ?

Thank you very much

@BlackBird77
Copy link

Replace bus_wrapper.h lines

//APA102
#define B_HS_DOT_3 NeoPixelBrightnessBus<DotStarBgrFeature, DotStarSpi5MhzMethod> //hardware SPI
#define B_SS_DOT_3 NeoPixelBrightnessBus<DotStarBgrFeature, DotStarMethod>    //soft SPI

with

//APA102
#define B_HS_DOT_3 NeoPixelBrightnessBus<DotStarBgrFeature, DotStarEsp32DmaVspi5MhzMethod> //hardware SPI with DMA
#define B_SS_DOT_3 NeoPixelBrightnessBus<DotStarBgrFeature, DotStarMethod>    //soft SPI

This change forces the NeoPixel library to NOT use the Arduino SPI implementation. I don't know why this makes a difference. I searched also all the code. And compared the difference in ARDUINO and ESP32 DMA SPI implementation. All i found was, Arduino do not initialize the QUAD SPI pins.. The DMA SPI Driver explicitly disables the QUAD SPI pins.. And i found the default QUAD SPI PINS are on ports where the Ethernet chip is connected.

I hope this helps.

Andre

@blazoncek
Copy link
Collaborator

Aha!
WLED is coded to use HSPI peripheral, not VSPI. Please check if other places are broken (usermods) when using VSPI for LEDs.

Thank you.

@blazoncek
Copy link
Collaborator

blazoncek commented Mar 11, 2023

Will add this to main when I have time to test it a bit:

#ifdef WLED_USE_ETHERNET
#define B_HS_DOT_3 NeoPixelBrightnessBus<DotStarBgrFeature, DotStarEsp32DmaHspi5MhzMethod> //hardware HSPI with DMA
#else
#define B_HS_DOT_3 NeoPixelBrightnessBus<DotStarBgrFeature, DotStarSpi5MhzMethod> //hardware HSPI
#endif

blazoncek added a commit that referenced this issue Mar 12, 2023
UI rebuild.
@blazoncek
Copy link
Collaborator

Please test recent commit. It works on my test system with @conradopoole Ethernet shield and @srg74 universal shield/controller.

@benkuper
Copy link

Tested and working on Olimex ESP32-POE-ISO, connecting SK9822 (APA102 clones) to pins 32 & 33 (same as ethernet), and using SD card MMC at the same time !

Thank you all very much !

@AVRnet
Copy link
Author

AVRnet commented Mar 12, 2023

Confirm that everything is fine now,
tested and working on WT32-ETH01 with 300 pieces of APA102 to DATA GPIO2 and CLOCK GPIO4.
(WLED v0.14.0-b2)

Thanks to all !!!

@blazoncek
Copy link
Collaborator

Please close rhen.

@AVRnet AVRnet closed this as completed Mar 12, 2023
softhack007 added a commit to atuline/WLED that referenced this issue Mar 12, 2023
imcmib added a commit to imcmib/WLED that referenced this issue Mar 20, 2023
* added klipper usermod

* enabled IP Change and updated the Readme

* Added spreading from center and fixed the enable

* fixing the PR conflict

* bugfixes

* xml.cpp: correct type for checkbox global led buffer" (was not shown correctly)
* fx.cpp: 2D floating blobs - correct swapped x/y coordinates (did not render correctly on non-square matrix)

* update build nr

and npm run build

* Delete wled00.ino.cpp

accident

* Whitespace.

* Art-Net transmit support for network LEDs

Like DDP, this allows WLED to address network systems using the Art-Net protocol.

Universe starts at zero, because that's the first universe in Art-Net.

Works with RGB. It's coded to also work with RGBW, but I couldn't find a great place to enable it without mucking with things I don't understand.

* whitespace cleanup

* PROGMEM for header

* Fix for Aircoookie#2542.
UI rebuild.

* workaround for issue Aircoookie#3128

* adding wled00.ino.cpp to gitignore

to avoid future accidents in GH Desktop

* Fix typing  to resolve build errors after installing the mpu6050_imu usermod.

* adding WLED_DISABLE_ADALIGHT (issue Aircoookie#3128

This flag disables reading commands from serial interface (RX = gpio 3)

Add -D WLED_DISABLE_ADALIGHT to your custom pio build environment.

* typo

* comment updated

Also "Serial JSON" is not possible when reading from RX pin is disabled.

---------

Co-authored-by: lost-hope <s.willrodt@yahoo.de>
Co-authored-by: Frank <frank.moehle@outlook.de>
Co-authored-by: Frank <91616163+softhack007@users.noreply.github.com>
Co-authored-by: Blaz Kristan <blaz@kristan-sp.si>
Co-authored-by: TroyHacks <5659019+troyhacks@users.noreply.github.com>
Co-authored-by: Ryan Horricks <ryan.horricks@gmail.com>
david-sawatzke added a commit to david-sawatzke/WLED that referenced this issue Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests