Hi.
I'm planning to connect an ESP32 to two Ethernet PHYs, but only the SMI (MDC+MDIO) and reset pins, not the data plane (see docs). For the data plane, both PHYs are cross-connected. I don't need the `netif` parts of esp-idf for this.
I need to configure those PHYs, i.e. read and write registers. The idea was to use ESP32's internal EMAC (and esp-idf) because it can already speak the SMI protocol. If that proves too complicated, I'm prepared to bitbang the protocol or implement it with the I/O facilities of the ESP32.
How should I approach this?
I don't have hardware to test on yet, but I do have an ESP32 Ethernet Kit, so I can try some things for now. The intended hardware will involve PHYs similar to IP101 so I can fork and modify that driver.
In the basic Ethernet example, I saw `esp_eth_phy_new_ip101`, which populates some structures with convenient methods, but doesn't actually talk to (init) the PHY yet...
The methods of the `esp_eth_phy_t` object provide some setters on the PHY but no way to access registers. I guess the interface isn't intended for that.
`esp_eth_driver_install` does a lot of work... specifically, the `esp_eth_config_t` object contains fields that relate to transferring actual Ethernet data, which I don't intend the ESP32 to be aware of at all.
I think I can skip the `esp_netif_attach`, `esp_event_handler_register`, and `esp_eth_start` but I'm not quite sure.
I also don't know yet what functions/methods to use to read/write each PHY's registers explicitly. Code in the `ip101` specific driver calls `eth->phy_reg_read()`, going through an `esp_eth_mediator_t` object, which gets set sometime during setup via `ip101_set_mediator` or `set_mediator` in `esp_eth_driver_install`...
Hoping for guidance and suggestions. Thank you!
ethernet: need to configure two PHYs over internal MAC, but send no data
-
- Posts: 211
- Joined: Fri May 07, 2021 10:35 am
Re: ethernet: need to configure two PHYs over internal MAC, but send no data
Check `emac_esp32_write_phy_reg` and `emac_esp32_read_phy_reg` functions. You will also need to bring up EMAC, so some basic init would be required => check `emac_esp32_init`. Last, but not least, you would need to source CLK to the EMAC to be even operational.
Re: ethernet: need to configure two PHYs over internal MAC, but send no data
Thanks!
I've got it working. Not as clean as I'd hoped, and a bit of an adventure in the innards of IDF/HAL/LL, but simple in the end
I've got it working. Not as clean as I'd hoped, and a bit of an adventure in the innards of IDF/HAL/LL, but simple in the end
Re: ethernet: need to configure two PHYs over internal MAC, but send no data
What transfer rates can you get using this setup? I have an application where I need to pass 32Mbps stream from one ethernet port to another. Also, what PHY chip did you use?
Re: ethernet: need to configure two PHYs over internal MAC, but send no data
We're talking about SMI here. That's for control, getting/setting registers in the PHYs. It's not for sending data. If you want to send data, you'd want to use the regular Ethernet stack, which sends data to and from the PHY via some MII.
PHYs can talk about 2.5 MBit/s or even 25 Mbit/s on SMI.
With ESP32, the IDF setup configures the ESP32's SMI to run at about 1.9 Mbit/s.
I never benchmarked the effective throughput on that bus. It's good enough to wrangle the PHYs we have.
PHYs used: IP101 (see ESP32 Ethernet Kit), IP1001, an Automotive Ethernet PHY that shall remain unnamed.
The firmware brings up the (emac and) IP101 through esp-idf, then uses the emac handle to talk directly on the bus to the other PHYs. In another topic, I asked about how to coordinate SMI access between esp-idf network stack and my own task. Turned out to be easy.
The extra PHYs are Gigabit Ethernet, their *MII connected to each other, and they reach theoretical maxima (940 MBit/s and 95 Mbit/s).
PHYs can talk about 2.5 MBit/s or even 25 Mbit/s on SMI.
With ESP32, the IDF setup configures the ESP32's SMI to run at about 1.9 Mbit/s.
I never benchmarked the effective throughput on that bus. It's good enough to wrangle the PHYs we have.
PHYs used: IP101 (see ESP32 Ethernet Kit), IP1001, an Automotive Ethernet PHY that shall remain unnamed.
The firmware brings up the (emac and) IP101 through esp-idf, then uses the emac handle to talk directly on the bus to the other PHYs. In another topic, I asked about how to coordinate SMI access between esp-idf network stack and my own task. Turned out to be easy.
The extra PHYs are Gigabit Ethernet, their *MII connected to each other, and they reach theoretical maxima (940 MBit/s and 95 Mbit/s).
Last edited by crackwitz on Tue Dec 12, 2023 10:59 pm, edited 1 time in total.
Re: ethernet: need to configure two PHYs over internal MAC, but send no data
Thanks for your info. I don't see the IP101 as something available. I am now looking at the KSZ8863 part since I need two ports. Seems like pretty much the same thing. $6 price range is a little high, but per port still in the ball park. Performance seems to be limited by the ESP32 at that point but still in the over 80 Mbps range for one port to the other which is more than I need.crackwitz wrote: ↑Mon Dec 11, 2023 4:56 pmWe're talking about SMI here. That's for control, getting/setting registers in the PHYs. It's not for sending data. If you want to send data, you'd want to use the regular Ethernet stack, which sends data to and from the PHY via some MII.
PHYs can talk about 2.5 MBit/s or even 25 Mbit/s on SMI.
With ESP32, the IDF setup configures the ESP32's SMI to run at about 1.9 Mbit/s.
I never benchmarked the effective throughput on that bus. It's good enough to wrangle the PHYs we have.
PHYs used: IP101 (see ESP32 Ethernet Kit), IP1001, an Automotive Ethernet PHY that shall remain unnamed.
The firmware brings up the (emac and) IP101 through esp-idf, then uses the emac handle to talk directly on the bus to the other PHYs. In another topic, I asked about how to coordinate SMI access between esp-idf network stack and my own task. Turned out to be easy.
The extra PHYs are Gigabit Ethernet, their *MMI connected to each other, and they reach theoretical maxima (940 MBit/s and 95 Mbit/s).
I like the ESP32 S3 series much better but it doesn't have the EMAC which uses so many pins. This project only needs a few additional pins so that is okay. There is already a project that uses it so that is a good start:
https://github.com/espressif/esp-eth-dr ... /README.md
Who is online
Users browsing this forum: No registered users and 168 guests