Adding new Ethernet Phy to IDF v3

Bauteiltöter
Posts: 1
Joined: Fri Sep 06, 2024 4:41 pm

Adding new Ethernet Phy to IDF v3

Postby Bauteiltöter » Fri Sep 06, 2024 4:56 pm

Hi,

I'm currently struggling to add custom drivers for a KSZ8863RLL Ethernet-Phy to my Project using ESP-IDF v3.3.6.
Sadly I'm stuck on this old IDF version, otherwise it would be much easier.

The KSZ8863RLL is a three port ethernet switch. Two ports have normal phys, driving magnetics (port 1 and port 2). Port 3 of the switch is accessible with an RMII. I've connected an ESP32-WROVER-E module to this RMII interface.

IDF v5 has an example for the KSZ8863 already available. I've compiled this example and it's working fine so I know that my custom hardware is fine.

Now I'm trying to get it to run using the ESP-IDF v3.3.6 as mentioned above.
To do that I've started with the espressif example for ethernet and patched my own code into there. I cannot communicate with the Phy using SMI because it has too many registers, so I'm using I2C. The I2C interface is working, I can read the registers and they mach what I expect according to the datasheet.

I've started with a fresh eth_config_t structure and filled it with my custom functions.
Now the problem is: It doesn't communicate.

If I see through my logfile I can see this:

Code: Select all

I (465) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (465) KSZ: ksz_phy_init
W (475) KSZ: Except next write to fail because of SW reset
I (575) I2C: i2c_master_cmd_begin failed
E (575) I2C: I2C_read failed
I (575) KSZ: ChipID ok
I (575) emac: emac reset done
I (575) KSZ: Port 3 speed mode: 100M
I (575) eth_example: Ethernet Started
I (2575) eth_example: Port 1 Link good

I (2575) eth_example: Port 2 Link good

I (2585) KSZ: Port 3 speed mode: Full Duplex
I (2585) KSZ: Port 3 speed mode: 100M
I (2595) KSZ: Port 3 speed mode: Full Duplex
I (2595) KSZ: Port 3 speed mode: 100M
I (2605) KSZ: Port 3 speed mode: Full Duplex
I (2605) KSZ: Port 3 speed mode: 100M
I (2615) KSZ: Port 3 speed mode: Full Duplex
I (2615) KSZ: Port 3 speed mode: 100M
I (2625) KSZ: Port 3 speed mode: Full Duplex
I (2625) KSZ: Port 3 speed mode: 100M
I (2635) KSZ: Port 3 speed mode: Full Duplex
I (2635) KSZ: Port 3 speed mode: 100M
I (2635) eth_example: Ethernet Link Up
I (4575) eth_example: Port 1 Link good

I (4575) eth_example: Port 2 Link good
It's resting the phy, reseting the emac, then it will start to read the Port3 mode from the phy (100Mbps, Full Duplex).
The ethernet event handler gets the SYSTEM_EVENT_ETH_START event ("Ethernet Started"), followed by the SYSTEM_EVENT_ETH_CONNECTED ("Ethernet Link Up").

But it never receives the SYSTEM_EVENT_ETH_GOT_IP event.

I've looked onto the RMII pins with my oscilloscope. There I can see data communication from the PHY to the ESP32 (signals on RXD0, RXD1 and CRS_DV), but the signals in the other direction from ESP32 to PHY are not doing anything (TXD0, TXD1 and TX_EN).

I'm really stuck on this problem and a deadline is approaching soon so I would be very grateful if someone has an idea where to look for this problem.

I've attached the full example sourecode and a picture of the board (for curiosity)

Best Regards
Torben
Attachments
ethernet_example_main.c
(9.75 KiB) Downloaded 45 times
wled-board.jpg
wled-board.jpg (255.63 KiB) Viewed 698 times

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

Re: Adding new Ethernet Phy to IDF v3

Postby ESP_ondrej » Mon Sep 09, 2024 7:29 am

IDFv3 is super old and has completely different structure of the Ethernet driver. It would be probably easier to start writing the whole new driver for KS8863 rather than trying to modify the current one, I'm afraid... The only recommendation is to upgrade to higher IDF version. If you are developing a new product, you should do it anyway to have access to all new features.

Who is online

Users browsing this forum: No registered users and 120 guests