ESP32 can't talk to LAN8270 <SOLVED>

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

ESP32 can't talk to LAN8270 <SOLVED>

Postby fly135 » Mon Apr 08, 2019 8:02 pm

Not sure why I'm having a problem with this board a friend made. I'm running the ethernet_example in the IDF. I've checked and double checked that MDIO and MDC are the correct assigned pins. Not control over PHY power. I've included a scope capture that seems to indicate properly data coming from the ESP32. But the LAN8270 is not responding. Just a bunch of timeouts with register reading 0xffff on init.
(296) emac: emac resetting ....
I (296) emac: emac reset done
D (296) lan8720: phy_lan8720_init()
D (306) lan8720: LAN8720 Registers:
D (306) lan8720: BCR 0xffff
D (306) lan8720: BSR 0xffff
D (316) lan8720: PHY1 0xffff
D (316) lan8720: PHY2 0xffff
D (316) lan8720: ANAR 0xffff
D (326) lan8720: ANLPAR 0xffff
D (326) lan8720: ANER 0xffff
D (326) lan8720: MCSR 0xffff
D (336) lan8720: SM 0xffff
D (336) lan8720: SECR 0xffff
D (336) lan8720: CSIR 0xffff
D (346) lan8720: ISR 0xffff
D (346) lan8720: IMR 0xffff
D (346) lan8720: PSCSR 0xffff
E (1356) emac: Timed out waiting for PHY register 0x2 to have value 0x0007 (mask 0xffff). Current value 0xffff
E (2356) emac: Timed out waiting for PHY register 0x3 to have value 0xc0f0 (mask 0xfff0). Current value 0xffff
The init procedure writes to reg 2 & 3. The scope capture appears to be addressing reg2. It appears to have 32 ones, then SOF 01, then OPCODE 10, then PHY addr all ones, then register addr 2. It seems to release the bus and the signal is pulled high. Doesn't seem to obey the turnaround of two zeros. But maybe that's because MDIO is being pulled high.

I'm not expecting that with this info someone can debug the board. But was hoping that maybe somebody knew about some "gotchas" that may be impeding my progress. It appears the next step is to examine the LAN8270 and see if something is wrong with it.

John A
Attachments
phy_mdio.jpg
phy_mdio.jpg (44.52 KiB) Viewed 908 times
ethernet_clock.jpg
ethernet_clock.jpg (849.38 KiB) Viewed 908 times
Last edited by fly135 on Mon Apr 08, 2019 8:15 pm, edited 1 time in total.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: ESP32 can't talk to LAN8270

Postby fly135 » Mon Apr 08, 2019 8:15 pm

Super simple fix. The PHY was address zero and I was using address 31. :D

John A

Deouss
Posts: 386
Joined: Tue Mar 20, 2018 11:36 am

Re: ESP32 can't talk to LAN8270 <SOLVED>

Postby Deouss » Fri Apr 12, 2019 1:45 am

I just got my long awaited LAN8720 module and wanted to make it work with my network.
Can you share the code or point to good example? Also any advices ?
Thanks

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: ESP32 can't talk to LAN8270 <SOLVED>

Postby fly135 » Fri Apr 12, 2019 7:17 pm

Deouss wrote:
Fri Apr 12, 2019 1:45 am
I just got my long awaited LAN8720 module and wanted to make it work with my network.
Can you share the code or point to good example? Also any advices ?
Thanks
I just used the IDF .../examples/ethernet/ethernet

The only thing that caused me a problem was the default PHY address was 31 and I figured that the default would work. The default PHY is the TLK110 and that apparently defaulted the PHY address to 31. Then when I switched to LAN8720 it stayed with the TLK110 default address. Other than that I confirmed the HW designer used the default pins for MDC and MDIO. His design did not include powering the PHY as low power operation is not an issue.

Just config and compile the same app. It should come up and get the DHCP address from your router. I haven't done anything else with the board. I just brought it up and confirmed it worked as a favor. The oscillator is on GPIO-00 and he didn't put any kind of mux on it. So I have to boot it multiple times because it wants to go into download mode. I caught that for him as a design flaw. It's his first ESP32 board, so he didn't really get the download mode thing.

John A

Who is online

Users browsing this forum: No registered users and 6 guests