xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

slandis
Posts: 2
Joined: Wed Feb 03, 2021 4:59 pm

xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

Postby slandis » Wed Feb 03, 2021 5:07 pm

Using IDF 4.3-dev with the debug compiler option from the menu I have a working example using an SPI-connected W5500 ethernet module wired to the default pins for SPI3 - the example starts up, configures the mac and phy and gets an IP address but only if I use an SPI bus speed of 32MHz. I can then send and receive without issue. If I move to any other of the compiler options I end up with WDT issues which I have tracked down to an xTakeSemaphore call in esp_eth_mac_w5500.c, called from w5500_read(). I did search around a bit and saw some discussion around making sure tasks get pinned to cores so I modified the example to pin everything to a single core and the issue persists. If I change the SPI bus speed I get reboot loop and/or SPI communication issues.

To be sure that there's no an issue in 4.3-dev I retro-graded to 4.2-release and the ethernet/basic example with a w5500 connected has issues with communication to the w5500 prior to the read call. I have tried all compiler options and I have tried various SPI speeds and can seem to find no winning combination.

Overall I'm okay with using 4.3-dev so I am more keen on inquiring if anybody has faced the issue with xTakeSemaphore and SPI ethernet modules and if so was there a resolution found for the issue?

Thanks!


slandis
Posts: 2
Joined: Wed Feb 03, 2021 4:59 pm

Re: xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

Postby slandis » Fri Feb 05, 2021 2:56 am

Thanks, that's definitely a similar issue. Interesting that I can compile under debug and not have the issue at all. The w5500 works perfectly and brings the link back up even with multiple cable unplugs. Hopefully they can look at this bug soon. Thanks again!

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

Postby rtborg » Wed Mar 23, 2022 2:02 pm

@slandis Could you post your code, please? I am having trouble getting W550 to work.

Thanks

ESP_ondrej
Posts: 181
Joined: Fri May 07, 2021 10:35 am

Re: xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

Postby ESP_ondrej » Wed Mar 23, 2022 2:56 pm

@rtborg,

could you please share what exact issue with W5500 you observe?

rtborg
Posts: 67
Joined: Wed Oct 23, 2019 6:15 am

Re: xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

Postby rtborg » Thu Mar 24, 2022 6:12 am

@ESP_ondrej,

I think I probably have identified the problem, it's that the interrupt pin of my board is not wired.

Is there a way to change the behavior of the library to not use the interrupt?

ESP_ondrej
Posts: 181
Joined: Fri May 07, 2021 10:35 am

Re: xTakeSemaphore and SPI Ethernet (w5500) in ethernet/basic example

Postby ESP_ondrej » Thu Mar 24, 2022 7:45 am

There would be a way of not using interrupt but not by default. You would need to update the MAC layer of W5500 driver (esp_eth_mac_w5500.c).
Basically it would include the following:
- remove ESP32 interrupt initialization (or making it optional) in emac_w5500_init()
- update emac_w5500_task() to not wait for interrupt but to periodically poll appropriate register with receive status.

You could also try quick and dirty solution as follows:
- remove ulTaskNotifyTake from emac_w5500_task()
- place vTaskDelay at the end of while loop in emac_w5500_task()

However, performance will be significantly crippled when not using interrupt.

Who is online

Users browsing this forum: Google [Bot], santa5679 and 97 guests