Open whc2001 opened 1 month ago
Supported IDF version is ESP-IDF v5.1.1
Supported IDF version is ESP-IDF v5.1.1
Unfortunately I tried with v5.1 and the result is the same. I have checked the migrating guide and it does not mention anything about peripheral from v5.1 to v5.2, only v4 to v5, which I already did but no good.
Ok so I must have broken something doing the upgrade to IDF v5 . I'll check as soon as I can. What you can try in the meantime is to find the original Ethernet Basic Example from IDF v5.1.1 and see if you can replace it in eth_interface. I took this example and adapted it to my needs but it is based on IDF v4.3 and that's probably the issue
I did a quick check and it seems they changed a few things in this example. So there's gonna be some more work to do on that end I guess
I attempted to port the newer example to this project, but interestingly it failed with the exact same problem. I am starting to think I got a broken environment, as I followed the suggestion exactly. I'll try again later with a fresh install of v5.1 in a Linux environment.
@whc2001 ok I am a bit lost here ...
#include "driver/gpio.h"
#include "esp_eth.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_netif.h"
The only inclusion which is found seems to be #include "esp_log.h"
but I don't know why it isn't.
I've tried adding esp_eth
to wifi_interface
component and also add #include "esp_eth.h"
and it is found without any issue.
The only difference in the Cmakelist file is the if else part which I also temporary removed without any luck.
Not sure if this is related but I found #define CONFIG_ETH_USE_SPI_ETHERNET 1
in sdkconfig.h but I selected the internal MAC. Maybe there is some problematic kconfig code?
Ok so it seems you'll need to replace Cmakefilelist.txt content of eth_interface component by this
idf_component_register(SRCS "eth_interface.c"
INCLUDE_DIRS "include"
REQUIRES driver esp_eth esp_netif)
To make those inclusion errors go away. You'll still need to port the code afterwards. Not sure why the if else isn't working as expected anymore...
Ok so it seems you'll need to replace Cmakefilelist.txt content of eth_interface component by this
idf_component_register(SRCS "eth_interface.c" INCLUDE_DIRS "include" REQUIRES driver esp_eth esp_netif)
To make those inclusion errors go away. You'll still need to port the code afterwards. Not sure why the if else isn't working as expected anymore...
I got a new Linux environment and tried this, still complaining about unable to find driver/gpio.h
. Not sure about what to do at this point...
I don't know what I did but the the driver/gpio.h
is now working, however the main.c
is still using WiFi. After some fiddling I found that the if
guard in the CMakeList.txt
of eth_interface
is not working somehow. I deleted everything only keeping the idf_component_register
line, and after fixing some careless error in .c
and .h
when porting it compiled without problem (I didn't plug in the module so it keeps crashing):
Can you please check this, seems like it's compiling for me. My ESP32 board does not have GPIO21 broken out so I need to get another one to test on hardware...
After some fiddling I found that the if guard in the CMakeList.txt of eth_interface is not working somehow. I deleted everything only keeping the idf_component_register line
That's what I meant with my comment above.
I'll try as soon as I can
Seems no good. Added some debug print:
[0;31mE (904) snapclient_eth_init: >>>>> init Ethernet - calloc[0m
[0;31mE (914) snapclient_eth_init: >>>>> init internal Ethernet - init_internal[0m
[0;31mE (922) snapclient_eth_init: >>>>> init internal Ethernet - new_esp32[0m
[0;31mE (929) snapclient_eth_init: >>>>> init internal Ethernet - new_esp32 done, x = 1073487700[0m
[0;31mE (938) snapclient_eth_init: >>>>> init internal Ethernet - new_lan87xx[0m
[0;31mE (945) snapclient_eth_init: >>>>> init internal Ethernet - new_lan87xx done, x = 1073495584[0m
[0;31mE (954) snapclient_eth_init: >>>>> init internal Ethernet - driver_install[0m
[0;31mE (1072) eth_phy_802_3: esp_eth_phy_802_3_pwrctl(250): power up timeout[0m
[0;31mE (1072) eth_phy_802_3: esp_eth_phy_802_3_basic_phy_init(433): power control failed[0m
[0;31mE (1076) lan87xx: lan87xx_init(341): failed to init PHY[0m
[0;31mE (1082) esp_eth: esp_eth_driver_install(229): init phy failed[0m
[0;31mE (1089) snapclient_eth_init: eth_init_internal(109): Ethernet driver install failed[0m
[0;31mE (1097) snapclient_eth_init: >>>>> init internal Ethernet done, x = 0[0m
[0;31mE (1104) snapclient_eth_init: original_eth_init(281): internal Ethernet init failed[0m
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x400daaa6
file: "./components/eth_interface/eth_interface.c" line 385
func: eth_init
expression: original_eth_init(ð_handles, ð_port_cnt)
abort() was called at PC 0x40089883 on core 0
Backtrace: 0x40081c89:0x3ffb84c0 0x4008988d:0x3ffb84e0 0x4008d0a1:0x3ffb8500 0x40089883:0x3ffb8570 0x400daaa6:0x3ffb85a0 0x400da6db:0x3ffb8620 0x4014b012:0x3ffb8680
Not sure if it's the driver or the knockoff Waveshare LAN8720A module. Gonna inspect further later...
I can't tell you @whc2001 how much I love the docker image. This IDF stuff is really annoying to install. So maybe use the docker image instead for getting your dev machine ready. I know that it's code related see this as a friendly suggestion;-)
@whc2001 OK i found the problem. First you forgot to enable this in main.c
#if CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET || \
CONFIG_SNAPCLIENT_USE_SPI_ETHERNET
Altough I am not sure if you'll need this as I don't know how you provide the clock to your LAN8720. This is specific to the my board design.
Another thing you need to add right after this line is
esp32_emac_config.clock_config.rmii.clock_mode = EMAC_CLK_EXT_IN;
esp32_emac_config.clock_config.rmii.clock_gpio = 0;
With these changes my Ethernet chip initializes and starts up correctly. I am looking forward to your pull request :)
I can't tell you @whc2001 how much I love the docker image. This IDF stuff is really annoying to install. So maybe use the docker image instead for getting your dev machine ready. I know that it's code related see this as a friendly suggestion;-)
Thanks, I already got the environment ready for now.
@whc2001 OK i found the problem. First you forgot to enable this in main.c
#if CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET || \ CONFIG_SNAPCLIENT_USE_SPI_ETHERNET
Altough I am not sure if you'll need this as I don't know how you provide the clock to your LAN8720. This is specific to the my board design.
Another thing you need to add right after this line is
esp32_emac_config.clock_config.rmii.clock_mode = EMAC_CLK_EXT_IN; esp32_emac_config.clock_config.rmii.clock_gpio = 0;
With these changes my Ethernet chip initializes and starts up correctly. I am looking forward to your pull request :)
I am using the WaveShare module where it contains the onboard active oscillator. I decided to ignore the GPIO5 clock inhibit signal for now (as we talked about making it a separate config in #79 before) and just reset multiple times until it boots.
I tried to set the clock_mode
and clock_gpio
but the error is the same. I tried to solder a wire to the resistor of nRST and connect it to GPIO17, still no go. There is a small detail that the green LED of the ethernet port lights up even if I don't plug in the cable.
Nvm, silly error ;)
The LAN8720 on the Waveshare board is bootstraped to use I²C address 1.
I'll do some test then generate a pull request for just migrating ethernet to IDF v5 for now. After that I'll look into splitting the clock inhibit signal into separate menuconfig.
Update: seems like the connection can be made, but once the snapserver starts send anything to the client, it would jam the connection (?) that Couldn't get PCM chunk
is output indefinitely and it can no longer be pinged (always getting timeout).
@whc2001 I've add a pull request at your repo, see whc2001/snapclient#1
Also the code seems to work perfectly for me even without the modifications above. I'd still prefer to wait for the connection to be established before going on. What do you think?
@whc2001 I've add a pull request at your repo, see whc2001#1
Also the code seems to work perfectly for me even without the modifications above. I'd still prefer to wait for the connection to be established before going on. What do you think?
I totally agree with this logic. After doing this the connection error -4
log spam disappeared.
However it does not seem to fix the issue. It still hangs just after connection for some reason. The green LED on the RJ45 does not blink often, and I cannot ping it. I am not sure what is happening and I might need to test this module with some other program to ensure that the module itself is working. I'll report back ASAP. Sorry for that.
Good news, the LAN8720A module works perfectly; Bad news, now I'm not even sure where is the problem ;) I don't know where it stucks, I'll try some debug print but I doubt it would help locating.
Which board are you using?
Did you enable sample insertion (still experimental) in menuconfig? If you did, try disabling it.
Which board are you using?
I am using a generic ESP32-WROVER dev module (I didn't enable PSRAM for now because seems like it creates more problems) and a WaveShare LAN8720A clone. I have tested with Arduino and ESPHome that this configuration could work (make connection, obtain info from DHCP, ping from another host, connect to icanhazip.com and print out public IP).
Did you enable sample insertion (still experimental) in menuconfig? If you did, try disabling it.
I did, I just tried to disable it and there is no change. After ethernet just connected it would sometimes ping once or twice, but as soon as SnapClient starts running it's lost.
Did you try using wifi to test if it works that way?
Did you try using wifi to test if it works that way?
If I use WiFi seems like the connection can be made, but it looks very unstable. I have used up all my dupont cables on hand and currently I don't have the PT8211 DAC attached. I have purchaed a MAX98357 and some cabled to simple things up, and it would take two or three days...
Firstly really sorry for taking your time, it turns out I was a total idiot. The following two images speak themselves.
I was gonna to wire up the MAX98357 just arrived, only when I realized I never change the default I2S pins which are occupied already by the ethernet MAC. After setting them to spare pins (there really aren't many since the LAN8720 already took a lot of pins) and recompiling again...
https://github.com/CarlosDerSeher/snapclient/assets/16266909/7c1c9759-becd-49f1-9361-896c63bb9b8d
Still two things to do, the first is the configurable clock inhibit GPIO which should be easy. Another is that if you pull the ethernet cable when it's working, the last audio frame would repeat indefinitely (if you ever experienced a bluescreen when there is audio playing you know how it sounds like) until it reconnected or reset is performed. It should somehow listen to the ETHERNET_EVENT_DISCONNECTED
event and shut up the DAC or even better kill the SnapClient until the connection recovers.
Unfortunately I will go on another trip which includes my graduation ceremony in June, so it might still take me some time...
Ok good to know it mostly works now.
Maybe we could do a sanity check regarding double use of gpios during cmake.
It should somehow listen to the ETHERNET_EVENT_DISCONNECTED event and shut up the DAC or even better kill the SnapClient until the connection recovers
Good thinking. I've never unplugged the cables since I installed my clients :)
which includes my graduation ceremony
Oh and congratulations 🎊
Clock enable GPIO is added to the menuconfig. Also I've added the functionality to opt for static IP instead of DHCP (although it would make more sense to configure a static lease in the DHCP server, but I needed a quick and dirty static IP when testing with direct ethernet connection to my computer w/o DHCP server, so why not).
Tested with hardware and seems like it's working. However pre-commit
glitched on the first commit and didn't perform formatting. I only realized that after making the second commit and hope that's fine.
As for the network connection/disconnection detection, I am thinking about creating a new component (something like net_events
) to manage events from both WiFi and wired. ETH_XXX_BIT
and WIFI_XXX_BIT
will be merged into this component and share the same EventGroupHandle_t
. It provides a single function to the main task to wait in OR logic for any type of connection. Would you think that'll make sense?
As for the network connection/disconnection detection, I am thinking about creating a new component (something like net_events) to manage events from both WiFi and wired.
I'd love to see this implemented. The improv component could benefit from this too. I always wanted to auto switch between ethernet and wifi depending which is available but never had time to do it.
Testing with
sync_with_sample_stuffing
branch underESP-IDF v5.2.1
:After adding
eth_interface
into thePRIV_REQUIRES
statement inmain/CMakeList.txt
:Tried to add
REQUIRES driver
orPRIV_REQUIRES driver
to theidf_component_register
statement incomponents/eth_interface/CMakeLists.txt
, still the same error.