Can't get IP address using ethernet/basic example with Olimex ESP32-PoE (Rev. B)

Dejv99
Posts: 3
Joined: Sun Mar 28, 2021 9:00 am

Can't get IP address using ethernet/basic example with Olimex ESP32-PoE (Rev. B)

Postby Dejv99 » Wed Apr 07, 2021 9:13 am

Hi,
I am using OS Win10, VS Code EPS-IDF extension (all actually updated versions) and Olimex ESP32-PoE (Rev. B) board, and I am struggling with getting IP address using ethernet/basic example.

I configured the project as follows:

sdkconfig: (Example and Ethernet Config)
#
# Example Configuration
#
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
# CONFIG_EXAMPLE_USE_DM9051 is not set
# CONFIG_EXAMPLE_USE_W5500 is not set
# CONFIG_EXAMPLE_ETH_PHY_IP101 is not set
# CONFIG_EXAMPLE_ETH_PHY_RTL8201 is not set
CONFIG_EXAMPLE_ETH_PHY_LAN8720=y
# CONFIG_EXAMPLE_ETH_PHY_DP83848 is not set
# CONFIG_EXAMPLE_ETH_PHY_KSZ8041 is not set
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=-1
CONFIG_EXAMPLE_ETH_PHY_ADDR=0
# end of Example Configuration

#
# Ethernet
#
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
# CONFIG_ETH_PHY_INTERFACE_MII is not set
# CONFIG_ETH_RMII_CLK_INPUT is not set
CONFIG_ETH_RMII_CLK_OUTPUT=y
# CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0 is not set
CONFIG_ETH_RMII_CLK_OUT_GPIO=17
CONFIG_ETH_DMA_BUFFER_SIZE=512
CONFIG_ETH_DMA_RX_BUFFER_NUM=10
CONFIG_ETH_DMA_TX_BUFFER_NUM=10
CONFIG_ETH_USE_SPI_ETHERNET=y
# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set
# CONFIG_ETH_SPI_ETHERNET_W5500 is not set
# CONFIG_ETH_USE_OPENETH is not set
# end of Ethernet

In addition, I had to add following (from Olimex Ethernet example):
#define ETH_PHY_POWER_PIN (12)

// before creating PHY instance
gpio_pad_select_gpio(ETH_PHY_POWER_PIN);
gpio_set_direction(ETH_PHY_POWER_PIN,GPIO_MODE_OUTPUT);
gpio_set_level(ETH_PHY_POWER_PIN, 1);
vTaskDelay(pdMS_TO_TICKS(10));

Here is the log from ESP-IDF PowerShell after succesfull build, then `flash monitor`:

Executing action: monitor
Serial port COM3
Connecting........_
Detecting chip type... ESP32
Running idf_monitor in directory c:\users\xstejs30\esp\esp-idf\projects\eth_test
Executing "C:\Users\xstejs30\esp\esp-idf\tools\python_env\idf4.4_py3.8_env\Scripts\python.exe C:\Users\xstejs30\esp\esp-idf\tools/idf_monitor.py -p COM3 -b 115200 --toolchain-prefix xtensa-esp32-elf- c:\users\xstejs30\esp\esp-idf\projects\eth_test\build\eth_test.elf -m 'C:\Users\xstejs30\esp\esp-idf\tools\python_env\idf4.4_py3.8_env\Scripts\python.exe' 'C:\Users\xstejs30\esp\esp-idf\tools\idf.py'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM3 instead...
--- idf_monitor on \\.\COM3 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
eׁJun 8 2016 00'&&��SH�
rst:0x1B�=WERON_RESET),���0x1b (SPI_FA*�e1M!} ==Q�
c�˥gsip: 0, SPIWP'•�5
clk_drv:0x�b�}����0x00,d_d.����0,cs0_drv:0�0,hd_drv:0x00,w}�rv:0x00
!�+��0x3fff0030,���6716
ho 0 taZ�� room 4
loa����0078000,len:L���
load:0x400����,len:3688
e��� 0x40080678
I (28) boot: ESP-IDF v4.4-dev-744-g1cb31e509-dirty 2nd stage bootloader
I (28) boot: compile time 14:49:46
I (29) boot: chip revision: 1
I (33) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (40) boot.esp32: SPI Speed : 40MHz
I (45) boot.esp32: SPI Mode : DIO
I (49) boot.esp32: SPI Flash Size : 4MB
I (54) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (63) boot: ## Label Usage Type ST Offset Length
I (70) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (78) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (85) boot: 2 factory factory app 00 00 00010000 00100000
I (93) boot: End of partition table
I (97) boot_comm: chip revision: 1, min. application chip revision: 0
I (104) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0f4dch ( 62684) map
I (136) esp_image: segment 1: paddr=0001f504 vaddr=3ffb0000 size=00b14h ( 2836) load
I (137) esp_image: segment 2: paddr=00020020 vaddr=400d0020 size=30590h (198032) map
I (217) esp_image: segment 3: paddr=000505b8 vaddr=3ffb0b14 size=01fa4h ( 8100) load
I (220) esp_image: segment 4: paddr=00052564 vaddr=40080000 size=0bfe0h ( 49120) load
I (243) esp_image: segment 5: paddr=0005e54c vaddr=50000000 size=00010h ( 16) load
I (250) boot: Loaded app from partition at offset 0x10000
I (250) boot: Disabling RNG early entropy source...
I (263) cpu_start: Pro cpu up.
I (264) cpu_start: Starting app cpu, entry point is 0x40081240
0x40081240: call_start_cpu1 at C:/Users/xstejs30/esp/esp-idf/components/esp_system/port/cpu_start.c:158

I (0) cpu_start: App cpu up.
I (278) cpu_start: Pro cpu start user code
I (278) cpu_start: cpu freq: 160000000
I (278) cpu_start: Application information:
I (282) cpu_start: Project name: eth_test
I (287) cpu_start: App version: v4.4-dev-744-g1cb31e509-dirty
I (294) cpu_start: Compile time: Apr 6 2021 14:49:34
I (300) cpu_start: ELF file SHA256: 16a2e17787da1c12...
I (306) cpu_start: ESP-IDF: v4.4-dev-744-g1cb31e509-dirty
I (313) heap_init: Initializing. RAM available for dynamic allocation:
I (320) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (326) heap_init: At 3FFB4388 len 0002BC78 (175 KiB): DRAM
I (333) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (339) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (345) heap_init: At 4008BFE0 len 00014020 (80 KiB): IRAM
I (353) spi_flash: detected chip: gd
I (356) spi_flash: flash io: dio
I (361) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (386) system_api: Base MAC address is not set
I (386) system_api: read default base MAC address from EFUSE
I (416) esp_eth.netif.glue: 24:0a:c4:9f:00:37
I (416) esp_eth.netif.glue: ethernet attached to netif
I (426) eth_test: Ethernet Started
I (4426) eth_test: Ethernet Link Up
I (4426) eth_test: Ethernet HW Addr 24:0a:c4:9f:00:37

I don't understand, why Ethernet started correctly, Link is Up too, got HW address, but not IP addres, Mask and GW...

I will be very grateful for any advice.
Have a nice day.

phatpaul
Posts: 110
Joined: Fri Aug 24, 2018 1:14 pm

Re: Can't get IP address using ethernet/basic example with Olimex ESP32-PoE (Rev. B)

Postby phatpaul » Fri Apr 09, 2021 1:19 am

Do you have the Ethernet port connected to a network where there is there a DHCP server?
If not, you can enable LWIP_AUTOIP in menuconfig to auto-generate an IP.

Dejv99
Posts: 3
Joined: Sun Mar 28, 2021 9:00 am

Re: Can't get IP address using ethernet/basic example with Olimex ESP32-PoE (Rev. B)

Postby Dejv99 » Fri Apr 16, 2021 3:22 pm

Ehmmm, I feel so embarrassed, beginner's mistake... I had a board connected to the laptop - not to the router. :D
Thank you for your reply. :)

dtaylor
Posts: 8
Joined: Tue Aug 24, 2021 5:27 pm

Re: Can't get IP address using ethernet/basic example with Olimex ESP32-PoE (Rev. B)

Postby dtaylor » Tue Aug 24, 2021 6:02 pm

Wow, Thanks so much for this! Helped me out.

In case it's not clear to people using esp-idf and the basic ethernet example and the Olimex ESP32-POE. (In my case board rev. E)

Change configurations in terminal:
idf.py menuconfig

Go to:
Example configuration---> set PHY Reset GPIO number to -1 to disable.
Example configuration---> set PHY address to 0 to use Internal
Go to:
Example configuration--->Ethernet PHY Device (IP101)---> then select to LAN8720

If using the other examples you will also need to change these config values:
Ethernet--->Support ESP32 internal EMAC controller--->RMII clock mode ---> (X) Output RMII clock from internal
(17)RMII clock GPIO number

Quit and save the configurations.

Then in ethernet_example_main.c add some lines.

//define for the power pin
#define PIN_PHY_POWER 12

And in app_main()
Add 3 lines after this line.
phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO;

//These are added enable to power of the LAN8720 of OLIMEX esp32 POE board
gpio_pad_select_gpio(PIN_PHY_POWER);
gpio_set_direction(PIN_PHY_POWER,GPIO_MODE_OUTPUT);
gpio_set_level(PIN_PHY_POWER, 1);

Who is online

Users browsing this forum: No registered users and 92 guests