Replies: 6 comments 3 replies
-
We have a safe Rust wrapper for the ethernet driver in |
Beta Was this translation helpful? Give feedback.
-
Thank you! I did not realize this wrapper was available. I tried using it and found that the EthDriver::new_rmii(...) constructor has strict type-level constraints that each RMII signal must be a specific GPIO pin, but some pins for the Wesp32 do not match. According to https://wesp32.com/files/wESP32-Product-Brief.pdf the SMI MDC is 16 and the SMI MDIO pin is 17: • Ethernet PHY type is RTL8201 from revision 7 boards onward and LAN8720 for older revisions Would you recommend copying the implementation of new_rmii into my program as something like new_rmii_wesp32, or should I fork the crate to remove the compile time pin restrictions? |
Beta Was this translation helpful? Give feedback.
-
I just looked at our driver source code, and it is actually not true that rmii_mdc and rmii_mdio are hard-coded. In fact, these two, and the optional RST pin are the only 3 configurable pins (putting aside the clk conf). They are configurable, so you can put your gpio 16 and 17 there. Perhaps the example was for another board where these were different.
But then why:
it should be Also: // No dedicated reset pin on wESP32:
// was None,
Some(pins.gpio5), This ^^^ ideally should be none, rather than gpio5, because you say:
|
Beta Was this translation helpful? Give feedback.
-
The changes you point out are actually how I tried using this the first time. This is what I tried:
This was the error cargo gave me:
|
Beta Was this translation helpful? Give feedback.
-
BTW, since Option::<gpio::AnyIOPin>::None |
Beta Was this translation helpful? Give feedback.
-
Oh! Thank you for pointing that out, somehow I mis-ordered those parameters. And your advice about turbofishing the None was right on the money, I was confused about that. Now my code compiles, and appears to be bringing up the Ethernet (testing on an actual link TBD...) |
Beta Was this translation helpful? Give feedback.
-
I hope this is the right forum!
Hardware and Environment:
Problem: I’m attempting to bring up the wired Ethernet interface on a WESP32 board in a Rust application. I am using the Rust crates esp-idf-sys and esp-idf-svc to call into the ESP-IDF APIs. I’ve followed the usual pattern (similar to the C examples):
However, esp_eth_new_netif_glue() keeps returning NULL.
Attempts So Far:
If I set stack_input: None in the esp_eth_config_t, the result is still NULL when I call esp_eth_new_netif_glue().
If I provide a manual bridging function that calls esp_netif_receive(), it also fails.
I have discovered that in my esp_idf_sys bindings, the esp_eth_config_t::stack_input expects a function signature of:
esp_err_t (*stack_input)(esp_eth_handle_t eth_handle, uint8_t *buffer, uint32_t length, void *priv);
But the netif function esp_netif_receive() has a different signature and expects a pointer to esp_netif_t. So simply forwarding directly to esp_netif_receive() is incorrect.
In C, the ETH_DEFAULT_CONFIG(mac, phy) macro automatically sets stack_input to _eth_default_input, but that macro is not exposed in my Rust bindings.
What I Suspect:
Questions
Here's my current initialization function. Thank you for any pointers or advice!
pub fn configure_ethernet() -> Result<EspNetif, anyhow::Error> {
}
Beta Was this translation helpful? Give feedback.
All reactions