Can't get LAN8720 fully working

Jami17
Posts: 20
Joined: Wed Jul 12, 2017 10:55 pm

Can't get LAN8720 fully working

Postby Jami17 » Fri Jan 19, 2018 11:09 pm

I am using LAN8720A along with ESP-WROOM-32 on our custom PCB.
Clock is generated by GPIO17 and connected to GPIO0 and XTAL1.

I'm using the ethernet_example source with the current version of ESP-IDF

LAN8720A works fine when using the serial management commands.
But TCP/IP does not work at all.
I am not sure whether it's a h/w or s/w problem.

The lines RXDx / TXDx / CRS / show no activity (viewed with scope) when the transformer is connected to an ethernet line that carries some traffic to other tcp/ip-devices.
Shouldn't RXD0 / 1 at least show some activity then ?

The clock signal amplitude is 1.2Vpp. Is that perhaps too small for GPIO0 ?
I expected it to be near 3.3Vp since GPIO17 is powerful enough.
At least it's large enough for LAN8720A

This is the verbose log:
  • I (415) eth_example: ---starting
    D (415) emac: EMAC 50MHz inverted clock output on GPIO17
    I (415) eth_example: ---eth_gpio_config_rmii
    I (415) emac: mac version 1137a
    I (415) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
    V (425) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
    V (435) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
    D (445) intr_alloc: Connected src 38 to int 13 (cpu 0)
    I (445) emac: emac start !!!

    I (445) emac: emac reset done
    D (455) lan8720: phy_lan8720_init()
    D (455) lan8720: LAN8720 Registers:
    D (455) lan8720: BCR 0x3000
    D (465) lan8720: BSR 0x7809
    D (465) lan8720: PHY1 0x0007
    D (465) lan8720: PHY2 0xc0f1
    D (465) lan8720: ANAR 0x01e1
    D (475) lan8720: ANLPAR 0x0001
    D (475) lan8720: ANER 0x0000
    D (475) lan8720: MCSR 0x0000
    D (485) lan8720: SM 0xffff
    D (485) lan8720: SECR 0x0000
    D (485) lan8720: CSIR 0xffff
    D (485) lan8720: ISR 0xffff
    D (495) lan8720: IMR 0x0040
    D (495) lan8720: PSCSR 0x0002
    D (505) event: SYSTEM_EVENT_ETH_START
    V (505) event: enter default callback
    I (505) emac: emac start success !!!
    I (505) eth_example: ---esp_eth_enable
    D (505) tcpip_adapter: check: local, if=2 fn=0x400f2208

    D (515) tcpip_adapter: call api in lwip: ret=0x0, give sem
    D (525) tcpip_adapter: check: remote, if=2 fn=0x400f2208

    V (525) event: exit default callback

    D (2505) phy_common: phy_mii_check_link_status(DOWN)

    D (4505) phy_common: p
    hy_mii_check_link_status(UP)
    D (4505) lan8720: LAN8720 Registers:
    D (4505) lan8720: BCR 0x3100
    D (4505) lan8720: BSR 0x782d
    D (4505) lan8720: PHY1 0x0007
    D (4505) lan8720: PHY2 0xc0f1
    D (4505) lan8720: ANAR 0x0de1
    D (4515) lan8720: ANLPAR 0xcde1
    D (4515) lan8720: ANER 0x000b
    D (4515) lan8720: MCSR 0x0000
    D (4515) lan8720: SM 0xffff
    I (4525) eth_example: ~~~~~~~~~~~
    D (4525) lan8720: SECR 0x0009
    D (4525) lan8720: CSIR 0xffff
    I (4535) eth_example: ETHIP:0.0.0.0
    D (4535) lan8720: ISR 0xffff
    D (4535) lan8720: IMR 0x0040
    D (4545) lan8720: PSCSR 0x0002
    I (4545) eth_example: ETHPMASK:0.0.0.0
    D (4545) lan8720: phy_lan8720_get_duplex_mode(FULL)
    I (4555) eth_example: ETHPGW:0.0.0.0
    D (4555) lan8720: phy_lan8720_get_speed_mode(100)
    D (4555) phy_common: phy_mii_get_partner_pause_enable(TRUE)
    I (4565) eth_example: ~~~~~~~~~~~
    D (4565) lan8720: phy_lan8720_get_duplex_mode(FULL)
    I (4575) emac: eth link_up!!!
    D (4575) lan8720: LAN8720 Registers:
    D (4575) lan8720: BCR 0x3100
    D (4585) lan8720: BSR 0x782d
    D (4585) lan8720: PHY1 0x0007
    D (4585) lan8720: PHY2 0xc0f1
    D (4585) lan8720: ANAR 0x0de1
    D (4595) lan8720: ANLPAR 0xcde1
    D (4595) lan8720: ANER 0x0009
    D (4595) lan8720: MCSR 0x0000
    D (4605) lan8720: SM 0xffff
    D (4605) lan8720: SECR 0x0009
    D (4605) lan8720: CSIR 0xffff
    D (4605) lan8720: ISR 0xffff
    D (4615) lan8720: IMR 0x0040
    D (4615) lan8720: PSCSR 0x0002
    D (4615) lan8720: phy_lan8720_get_duplex_mode(FULL)
    D (4625) lan8720: phy_lan8720_get_speed_mode(100)
    D (4625) phy_common: phy_mii_get_partner_pause_enable(TRUE)
    D (4635) lan8720: phy_lan8720_get_duplex_mode(FULL)

    [...]

    D (4765) lan8720: LAN8720 Registers:
    D (4765) lan8720: BCR 0x3100
    D (4765) lan8720: BSR 0x782d
    D (4775) lan8720: PHY1 0x0007
    D (4775) lan8720: PHY2 0xc0f1
    D (4775) lan8720: ANAR 0x0de1
    D (4775) lan8720: ANLPAR 0xcde1
    D (4785) lan8720: ANER 0x0009
    D (4785) lan8720: MCSR 0x0000
    D (4785) lan8720: SM 0xffff
    D (4795) lan8720: SECR 0x0009
    D (4795) lan8720: CSIR 0xffff
    D (4795) lan8720: ISR 0xffff
    D (4795) lan8720: IMR 0x0040
    D (4805) lan8720: PSCSR 0x0002
    D (4805) lan8720: phy_lan8720_get_duplex_mode(FULL)
    D (4805) lan8720: phy_lan8720_get_speed_mode(100)
    D (4815) phy_common: phy_mii_get_partner_pause_enable(TRUE)
    D (4815) lan8720: phy_lan8720_get_duplex_mode(FULL)
    D (4825) lan8720: LAN8720 Registers:
    D (4825) lan8720: BCR 0x3100
    D (4835) lan8720: BSR 0x782d
    D (4835) lan8720: PHY1 0x0007
    D (4835) lan8720: PHY2 0xc0f1
    D (4835) lan8720: ANAR 0x0de1
    D (4845) lan8720: ANLPAR 0xcde1
    D (4845) lan8720: ANER 0x0009
    D (4845) lan8720: MCSR 0x0000
    D (4855) lan8720: SM 0xffff
    D (4855) lan8720: SECR 0x0009
    D (4855) lan8720: CSIR 0xffff
    D (4855) lan8720: ISR 0xffff
    D (4865) lan8720: IMR 0x0040
    D (4865) lan8720: PSCSR 0x0002
    D (4865) lan8720: phy_lan8720_get_duplex_mode(FULL)
    D (4875) lan8720: phy_lan8720_get_speed_mode(100)
    D (4875) phy_common: phy_mii_get_partner_pause_enable(TRUE)
    D (4885) lan8720: phy_lan8720_get_duplex_mode(FULL)
    D (4885) event: SYSTEM_EVENT_ETH_CONNECETED
    V (4895) event: enter default callback
    D (4895) tcpip_adapter: check: local, if=2 fn=0x400f2420

    D (4895) tcpip_adapter: call api in lwip: ret=0x0, give sem
    D (4905) tcpip_adapter: check: remote, if=2 fn=0x400f2420

    D (4905) tcpip_adapter: check: local, if=2 fn=0x400f2798

    D (4915) tcpip_adapter: dhcp client init ip/mask/gw to all-0
    D (4925) tcpip_adapter: if2 start ip lost tmr: enter
    D (4925) tcpip_adapter: if2 start ip lost tmr: only sta support ip lost timer
    D (4935) tcpip_adapter: dhcp client start successfully
    D (4935) tcpip_adapter: call api in lwip: ret=0x0, give sem
    D (4945) tcpip_adapter: check: remote, if=2 fn=0x400f2798

    V (4945) event: exit default callback

    D (6505) phy_common: phy_mii_check_link_status(UP)

    I (6575) eth_example: ~~~~~~~~~~~
    I (6575) eth_example: ETHIP:0.0.0.0
    I (6575) eth_example: ETHPMASK:0.0.0.0
    I (6575) eth_example: ETHPGW:0.0.0.0
    I (6575) eth_example: ~~~~~~~~~~~
Could a nice soul compare the LAN8720 Registers with his version?
Perhaps there's a difference?

Or are there any other issues that I may have overlooked?

pumpkin_pie
Posts: 5
Joined: Wed Oct 25, 2017 9:32 pm

Re: Can't get LAN8720 fully working

Postby pumpkin_pie » Tue Jan 23, 2018 9:52 pm

I have a similar problem with the lan8720. Everything appears to working from the hardware standpoint, and I get notifications when I plug an ethernet cable into the device, but I never get assigned an IP address and if I give it a static IP address it cannot be pinged. This is using the ethernet example file.

aekalman
Posts: 7
Joined: Fri Oct 27, 2017 10:34 pm

Re: Can't get LAN8720 fully working

Postby aekalman » Thu Jan 25, 2018 9:23 am

I'm having the same problem :-(

aekalman
Posts: 7
Joined: Fri Oct 27, 2017 10:34 pm

Re: Can't get LAN8720 fully working

Postby aekalman » Tue Jan 30, 2018 10:05 am

Here's a verbose dump of my system ... it's the ethernet example, with verbose logging and the appropriate Example Config for my hardware. Also, I'm calling phy_lan8720_dump_registers() from inside eth_task().

Code: Select all

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2018.01.30 01:59:22 =~=~=~=~=~=~=~=~=~=~=~=
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5696
ho 0 tail 12 room 4
load:0x40078000,len:0
load:0x40078000,len:13760
entry 0x40079020
I (55) boot: Detected ESP32
I (34) boot: ESP-IDF v3.0-dev-1117-gabacf8d2-dirty 2nd stage bootloader
I (34) boot: compile time 01:36:32
I (44) boot: Enabling RNG early entropy source...
I (44) boot: SPI Speed      : 40MHz
I (44) boot: SPI Mode       : DIO
I (48) boot: SPI Flash Size : 4MB
I (52) boot: Partition Table:
I (56) boot: ## Label            Usage          Type ST Offset   Length
I (63) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (71) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (78) boot:  2 factory          factory app      00 00 00010000 00100000
I (86) boot: End of partition table
I (90) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x0b0a8 ( 45224) map
I (115) esp_image: segment 1: paddr=0x0001b0d0 vaddr=0x3ffb0000 size=0x02164 (  8548) load
I (118) esp_image: segment 2: paddr=0x0001d23c vaddr=0x40080000 size=0x00400 (  1024) load
I (122) esp_image: segment 3: paddr=0x0001d644 vaddr=0x40080400 size=0x029cc ( 10700) load
I (135) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x2458c (148876) map
I (191) esp_image: segment 5: paddr=0x000445ac vaddr=0x40082dcc size=0x05994 ( 22932) load
I (200) esp_image: segment 6: paddr=0x00049f48 vaddr=0x400c0000 size=0x00000 (     0) load
I (206) boot: Loaded app from partition at offset 0x10000
I (206) boot: Disabling RNG early entropy source...
I (211) cpu_start: Pro cpu up.
I (215) cpu_start: Starting app cpu, entry point is 0x40080e18
I (0) cpu_start: App cpu up.
I (226) heap_init: Initializing. RAM available for dynamic allocation:
D (232) heap_init: New heap initialised at 0x3ffae6e0
I (237) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
D (243) heap_init: New heap initialised at 0x3ffbb9c8
I (249) heap_init: At 3FFBB9C8 len 00024638 (145 KiB): DRAM
I (255) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (261) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
D (268) heap_init: New heap initialised at 0x40088760
I (273) heap_init: At 40088760 len 000178A0 (94 KiB): IRAM
I (279) cpu_start: Pro cpu start user code
D (291) clk: RTC_SLOW_CLK calibration value: 3501548
V (300) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (300) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (305) intr_alloc: Connected src 46 to int 2 (cpu 0)
V (311) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (317) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xC0E
D (325) intr_alloc: Connected src 57 to int 3 (cpu 0)
V (330) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (336) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (344) intr_alloc: Connected src 16 to int 9 (cpu 0)
V (349) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (356) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0x40E
D (364) intr_alloc: Connected src 24 to int 12 (cpu 0)
I (369) cpu_start: Starting scheduler on PRO CPU.
V (0) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): checking args
V (0) intr_alloc: esp_intr_alloc_intrstatus (cpu 1): Args okay. Resulting flags 0x40E
D (10) intr_alloc: Connected src 25 to int 2 (cpu 1)
I (10) cpu_start: Starting scheduler on APP CPU.
D (419) heap_init: New heap initialised at 0x3ffe0440
D (419) heap_init: New heap initialised at 0x3ffe4350
D (429) eth_example: phy_device_power_enable(TRUE)
I (439) emac: mac version 1137a
V (439) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (439) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (449) intr_alloc: Connected src 38 to int 13 (cpu 0)
I (459) emac: emac start !!!

I (459) emac: emac reset done
I (469) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
D (469) lan8720: phy_lan8720_init()
D (479) lan8720: LAN8720 Registers:
D (479) lan8720: BCR    0x3000
D (479) lan8720: BSR    0x7809
D (489) lan8720: PHY1   0x0007
D (489) lan8720: PHY2   0xc0f1
D (489) lan8720: ANAR   0x01e1
D (499) lan8720: ANLPAR 0x0001
D (499) lan8720: ANER   0x0000
D (499) lan8720: MCSR   0x0000
D (509) lan8720: SM     0xffff
D (509) lan8720: SECR   0x0000
D (509) lan8720: CSIR   0xffff
D (519) lan8720: ISR    0xffff
D (519) lan8720: IMR    0x0040
D (519) lan8720: PSCSR  0x0002
D (539) event: SYSTEM_EVENT_ETH_START
V (539) event: enter default callback
D (539) tcpip_adapter: check: local, if=2 fn=0x400ee5ec

I (539) emac: emac start success !!!
D (539) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (549) tcpip_adapter: check: remote, if=2 fn=0x400ee5ec

V (549) event: exit default callback
D (2539) phy_common: phy_mii_check_link_status(DOWN)
I (4539) eth_example: ~~~~~~~~~~~
I (4539) eth_example: ETHIP:0.0.0.0
I (4539) eth_example: ETHPMASK:0.0.0.0
I (4539) eth_example: ETHPGW:0.0.0.0
I (4539) eth_example: ~~~~~~~~~~~
D (4539) lan8720: LAN8720 Registers:
D (4549) lan8720: BCR    0x3100
D (4549) lan8720: BSR    0x782d
D (4549) lan8720: PHY1   0x0007
D (4559) lan8720: PHY2   0xc0f1
D (8539) phy_common: phy_mii_check_link_status(UP)
I (8639) eth_example: ~~~~~~~~~~~
I (8639) eth_example: ETHIP:0.0.0.0
I (8639) eth_example: ETHPMASK:0.0.0.0
I (8639) eth_example: ETHPGW:0.0.0.0
I (8639) eth_example: ~~~~~~~~~~~
D (8639) lan8720: LAN8720 Registers:
D (8649) lan8720: BCR    0x3100
D (8649) lan8720: BSR    0x782d
D (8649) lan8720: PHY1   0x0007
D (8659) lan8720: PHY2   0xc0f1
D (8659) lan8720: ANAR   0x0de1
D (8659) lan8720: ANLPAR 0xcde1
D (8669) lan8720: ANER   0x0009
D (8669) lan8720: MCSR   0x0000
D (8669) lan8720: SM     0xffff
D (8679) lan8720: SECR   0x0009
D (8679) lan8720: CSIR   0xffff
D (8679) lan8720: ISR    0xffff
D (8689) lan8720: IMR    0x0040
D (8689) lan8720: PSCSR  0x0002
D (10539) phy_common: phy_mii_check_link_status(UP)
I (10689) eth_example: ~~~~~~~~~~~
I (10689) eth_example: ETHIP:0.0.0.0
I (10689) eth_example: ETHPMASK:0.0.0.0
I (10689) eth_example: ETHPGW:0.0.0.0
I (10689) eth_example: ~~~~~~~~~~~
D (10699) lan8720: LAN8720 Registers:
D (10699) lan8720: BCR    0x3100
D (10699) lan8720: BSR    0x782d
D (10709) lan8720: PHY1   0x0007
D (10709) lan8720: PHY2   0xc0f1
D (10709) lan8720: ANAR   0x0de1
D (10719) lan8720: ANLPAR 0xcde1
D (10719) lan8720: ANER   0x0009
D (10719) lan8720: MCSR   0x0000
D (10729) lan8720: SM     0xffff
D (10729) lan8720: SECR   0x0009
D (10729) lan8720: CSIR   0xffff
D (10739) lan8720: ISR    0xffff
D (10739) lan8720: IMR    0x0040
D (10739) lan8720: PSCSR  0x0002
D (12539) phy_common: phy_mii_check_link_status(UP)
I see plenty of activity on the RXD0 and RXD1 pins, but TXD0 and TXD1 go low when the application starts, and they remain low for the duration.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Can't get LAN8720 fully working

Postby Vader_Mester » Tue Jan 30, 2018 10:49 am

You should maybe check the stuff on the link below.
https://sautter.com/blog/ethernet-on-es ... g-lan8720/

Are you using a pre-manufatured LAN8720 board, or custom PCB?

Regards,
Vader [BEN]

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

aekalman
Posts: 7
Joined: Fri Oct 27, 2017 10:34 pm

Re: Can't get LAN8720 fully working

Postby aekalman » Tue Jan 30, 2018 4:15 pm

On my system it’s custom, dunno about the others in this thread. Given that in two posts the 8720 registers are identical, and on two systems the TXD0 & TXD1 pins go low and remain that way for the duration, to me that suggests either a problem in the MAC, or a perpheral conflct in the ESP32 that affects the ESP32’s TXD0 and TXD1 pins. These are both software problems.

While I am no 8720 expert, it looks like the PHY is working correctly ...

Jami17
Posts: 20
Joined: Wed Jul 12, 2017 10:55 pm

Re: Can't get LAN8720 fully working

Postby Jami17 » Sat Feb 03, 2018 6:38 pm

When connecting another TCP/IP device in parallel to the LAN wires and pinging that one from a PC, I do see activity on Rxd0/1 lines. So that looks ok. So perhaps the ESP32 does not get the 50MHz clock? Therefore I inserted a buffer to get a better clock. But that did not help at all.
I also get the conclusion that there is a software problem in the current ESP-IDF.
Any help from Expressif ?

---
I did not get an email alert when new replies were made. Is that normal?
A bit odd because it forces you to check this subject again & again.
Not very ergonomic !
I have enabled "Notify me when a reply is posted"

Volvox
Posts: 21
Joined: Sat Mar 18, 2017 7:54 pm

Re: Can't get LAN8720 fully working

Postby Volvox » Fri Jun 21, 2019 1:58 pm

I know it is a late reply, but I do not think that the problem is solved?
So I have also two layouts, both have an LAN8720 as PHY device.
Both of the Layouts have the same schematics, but the one works, the other does not work.
With exactly the same log output as you described (on both devices, the working and the not working one)
The only difference: there is no packet visible on the ethernet (Wireshark or similar).

First thing to try is to force a 10Mbit link. If this works -> your layout is not good enough to get 100Mbit working :)
So far my conclusion about this topic.
If you got it working now, please feel free to share, because I think it is a common problem when designing proper layouts with ethernet.

Jami17
Posts: 20
Joined: Wed Jul 12, 2017 10:55 pm

Re: Can't get LAN8720 fully working

Postby Jami17 » Fri Jun 21, 2019 11:27 pm

The problem I finally solved.
I used a second board and that worked fine. It seemed the first board had a LAN8720 solder problem, I could not find out in detail the reason, and gave up as it was a one time problem. So after all no s/w problem at all.

Volvox
Posts: 21
Joined: Sat Mar 18, 2017 7:54 pm

Re: Can't get LAN8720 fully working

Postby Volvox » Wed Jun 26, 2019 6:20 pm

I got it working now, too!
For everyone who has the same problem:

It seems the „no network“ problem is related to GPIO0 as clock output. I just manually connect GPIO16 or 17, changed the code to use this pin instead of IO0 and everything works as expected.
I do not know if the specifications of IO0 are different compared to the other pins, but it seems to be the reason..

Who is online

Users browsing this forum: No registered users and 114 guests