Ethernet example for W5500 does not compile OK

Fredckx
Posts: 17
Joined: Mon Mar 29, 2021 8:55 pm

Ethernet example for W5500 does not compile OK

Postby Fredckx » Sun May 01, 2022 7:43 pm

Hi,

I recently updated from ESP-IDF 4.2 to 4.4

Now I want to compile the Ethernet basic example, but I have no succes. The code compiles without errors but at run-time it does not show the expected output.

The example contains a number of conditional compilation statements, such as e.g.: #if CONFIG_EXAMPLE_USE_SPI_ETHERNET

By placing some logs I notice that the code inside the conditional blocks does not compile. Only logs outside these blocks give the expected output.

I used menuconfig to configure the example, but apparently that action does not produce the correct macros.

Did I overlook some action that must be carried out to enable conditional compilation? Especially after a fresh install of ESP-IDF 4.4?

Thanks
Fred

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

Re: Ethernet example for W5500 does not compile OK

Postby ESP_ondrej » Mon May 02, 2022 5:59 am

Hi Fred,

thanks for posting to the forum however your issue description is to vague to provide any concrete help.

Could you please share some info about your environment? Like what chip you use, what is physical GPIO connection, what is output of ESP monitor...

For start, you can check if the example is correctly configured:
- is W5500 module selected?
- is your SPI GPIO properly configured?
Fredckx wrote: By placing some logs I notice that the code inside the conditional blocks does not compile. Only logs outside these blocks give the expected output.
If you wanted to check that configuration "defines" were properly generated, search for it in /build/config/sdkconfig.h

Ondrej

Fredckx
Posts: 17
Joined: Mon Mar 29, 2021 8:55 pm

Re: Ethernet example for W5500 does not compile OK

Postby Fredckx » Mon May 02, 2022 1:38 pm

Hi Ondrej, thanks for your response !

The last output from the original code that I get in the monitor is:

I (348) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.

I placed a number of logs inside the conditional code blocks. They do not appear, so apparently the compilation conditions are not met.
I placed a number of logs outside the conditional blocks to check if perhaps logging is not OK. These logs do appear.

I use a freshly installed ESP-IDF 4.4.1.
My board is a TTG TAudio V1.6 which is based on ESP32 WROVER-E.
I use a W5500 / SPI based ethernet module.

In menuconfig > example configuration, there are only two options:

( ) Internal EMAC
(X) DM9051 Module

As I want to use a module, I unchecked Internal EMAC. Is this OK?
As there is no option to choose for W5500, I checked DM9051


In menuconfig > Component config → Ethernet I have:

[ ] Support ESP32 internal EMAC controller ----
-*- Support SPI to Ethernet Module --->
[ ] Support OpenCores Ethernet MAC (for use with QEMU)

under Support SPI to Ethernet Module I have,

-*- Use DM9051
[*] Use W5500 (MAC RAW)
[ ] Use KSZ8851SNL

The strange thing to me here is that Use DM9051 is a fixed setting. I also selected USE W5500

When I look in sdconfig, I see that a number of definitions are missing. This explains why the required code blocks are not compiled.

I miss:

- CONFIG_EXAMPLE_USE_SPI_ETHERNET NOT SET ! and not in sdkcofig
- CONFIG_EXAMPLE_ETH_SPI_CS
- CONFIG_EXAMPLE_ETH_SPI_INT
- CONFIG_EXAMPLE_ETH_SPI_PHY_RST
- CONFIG_EXAMPLE_ETH_SPI_PHY_ADDR

CONFIG_EXAMPLE_USE_DM9051=y although I want to use W5500. This is probably due to my own choice. But there is no other choice in the example config (?).

both DM9051 and w5500 selected in:

CONFIG_ETH_SPI_ETHERNET_DM9051=y
CONFIG_ETH_SPI_ETHERNET_W5500=y



Here is the contents of my sdconfig for the relevant parts:

//-------------start of sdconfig
#
# Example Configuration
#
# CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET is not set
CONFIG_EXAMPLE_USE_DM9051=y
CONFIG_EXAMPLE_DM9051_SPI_HOST=1
CONFIG_EXAMPLE_DM9051_SCLK_GPIO=19
CONFIG_EXAMPLE_DM9051_MOSI_GPIO=23
CONFIG_EXAMPLE_DM9051_MISO_GPIO=25
CONFIG_EXAMPLE_DM9051_CS_GPIO=22
CONFIG_EXAMPLE_DM9051_SPI_CLOCK_MHZ=25
CONFIG_EXAMPLE_DM9051_INT_GPIO=4
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=-1
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
# end of Example Configuration

#
# Ethernet
#
CONFIG_ETH_ENABLED=y
# CONFIG_ETH_USE_ESP32_EMAC is not set
CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ETH_SPI_ETHERNET_DM9051=y
CONFIG_ETH_SPI_ETHERNET_W5500=y
# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set
# CONFIG_ETH_USE_OPENETH is not set
# end of Ethernet
//-------------end of sdconfig

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

Re: Ethernet example for W5500 does not compile OK

Postby ESP_ondrej » Wed May 04, 2022 6:56 am

Hi Fred,

thanks for detailed issue description.

It seems you somehow mixed up IDF v4.2 example with IDF v4.4 components. Since the below comes from v4.2 (there was no support for W5500).
In menuconfig > example configuration, there are only two options:

( ) Internal EMAC
(X) DM9051 Module
Please make sure that you are trying to compile the example in correct folder and please make sure that you run `export.sh` from right folder too.

Ondrej

Who is online

Users browsing this forum: MicroController and 245 guests