-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[eppp]: Support for transport via Ethernet (phy or emac) #622
base: master
Are you sure you want to change the base?
Conversation
150f1b3
to
001855e
Compare
|
||
- Internal EMAC with real PHY chip | ||
* TCP - 5Mbits/s | ||
* UDP - 8Mbits/s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite surprised with such poor performance. Do you have idea what could be the bottle neck and why it isn't at least as good as SDIO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would probably get similar performance as SDIO, after some optimizations; tested just briefly with all defaults.
I'm planning on looking into it at some point.
components/eppp_link/eppp_eth.c
Outdated
}; | ||
gpio_config(&gpio_sink_cfg); | ||
gpio_set_level(CONFIG_EPPP_LINK_ETHERNET_SINK_READY_GPIO, 0); | ||
vTaskDelay(pdMS_TO_TICKS(STARTUP_DELAY_MS)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm the author of the simple EMAC 2 EMAC example but I'm not sure about this delay now :) I need to revisit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a good workaround but doesn't really fit into component definition. Thinking of dissecting that and moving to example(s)
components/eppp_link/eppp_eth.c
Outdated
|
||
static esp_err_t eth_init(void) | ||
{ | ||
#if CONFIG_EPPP_LINK_ETHERNET_CLK_SOURCE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to clearly distinguish that this is only ESP32 workaround. I'll try to come up with something. I'm currently thinking to wrap all this workaround code to specific functions with prefix like esp32_gpio0_workaround
. Users then can easily remove them if they don't need them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agree, I'll also think about it.
components/eppp_link/eppp_eth.c
Outdated
ESP_RETURN_ON_ERROR(esp_eth_driver_install(&config, &s_eth_handles[0]), TAG, "Ethernet driver install failed"); | ||
#endif // CONFIG_EPPP_LINK_ETHERNET_CLK_SINK | ||
return ESP_OK; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esp_restart();
of CLK source is missing when sink is restart. That could cause the sink may not boot correctly when restarted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. In case of wifi_remote
would could leave this logic on the host (master) side and let this side control the slave. But this is a generic component (on level lower than wifi-remote) and each node (server/client) is more or less generic too (peer nodes).
Cannot wait in this task (could be user's task or eppp-task), would have to create a small task to handle this case...
components/eppp_link/eppp_eth.c
Outdated
s_eth_handles = NULL; | ||
} | ||
|
||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding a comment that here we use PHY chip
to make it clearer to users? And also add comment at the start of #ifdef CONFIG_EPPP_LINK_ETHERNET_USE_DUMMY_PHY
. Or rename it to EMAC to EMAC
?
SLAVE micro HOST micro | ||
\|/ +----------------+ +----------------+ | ||
| | | (serial) line | | | ||
+---+ WiFi NAT PPPoS |=== UART / SPI / SDIO / ETH ===| PPPoS client | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to improve the README with instruction how to use EMAC to EMAC. Or at least provide link to the component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll improve the docs and add sections for each transport.
001855e
to
da05de2
Compare
@kostaond Thanks taking a look at the emac2emac option. I must say that I concur with your assessment and think that this option is probably not a viable transport option for My suggestion is that we drop the emac2emac option in this PR, but allow the Ethernet init/start functionality to be extended (with callbacks or |
Agree, if you need to move forward, drop the emac2emac. It's currently too much polluted with the GPIO0 workaround. Presence or non presence of the workaround must be super clear to users because the most probable use case is to use ESP32 with WiFi connected to some other chip without WiFi. |
da05de2
to
35f9579
Compare
Removed the emac2emac from the component and added it as an extra example with the specific configuration, so the GPIO0 workaround is in the app code only. (Moreover It demonstrates using any custom Ethernet driver) |
return ESP_FAIL; | ||
} | ||
|
||
__attribute__((weak)) esp_err_t eppp_transport_ethernet_init(esp_eth_handle_t *handle_array[]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case here for having the init function as a customization point?
sscanf(CONFIG_EPPP_LINK_ETHERNET_THEIR_ADDRESS, "%2" PRIu8 ":%2" PRIu8 ":%2" PRIi8 ":%2" PRIu8 ":%2" PRIu8 ":%2" PRIu8, | ||
&s_their_mac[0], &s_their_mac[1], &s_their_mac[2], &s_their_mac[3], &s_their_mac[4], &s_their_mac[5]); | ||
esp_eth_ioctl(s_eth_handles[0], ETH_CMD_S_MAC_ADDR, s_our_mac); | ||
ESP_RETURN_ON_ERROR(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL), TAG, "Failed to register Ethernet handlers"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we open space for a custom event handler?
esp_err_t eppp_transport_tx(void *h, void *buffer, size_t len) | ||
{ | ||
if (!s_is_connected) { | ||
return ESP_OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a failure?
|
||
## How to use this example | ||
|
||
* Choose `CONFIG_EXAMPLE_NODE_SERVER` for the device connected as **RMII CLK Source Device** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add some advice here regarding clk source.
@kostaond the conditions for clk generation if Wi-Fi is used in the device applies here as well, right?
|
||
esp_err_t eppp_transport_ethernet_init(esp_eth_handle_t *handle[]) | ||
{ | ||
*handle = malloc(sizeof(esp_eth_handle_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't esp_eth_handle_t
a type alias for void*
? Do we need to allocate here?
TaskHandle_t task_handle = xTaskGetHandle(pcTaskGetName(NULL)); | ||
gpio_isr_handler_add(CONFIG_EXAMPLE_RMII_CLK_READY_GPIO, gpio_isr_handler, task_handle); | ||
ESP_LOGW(TAG, "waiting for RMII CLK sink device interrupt"); | ||
ESP_LOGW(TAG, "if RMII CLK sink device is already running, reset it by `EN` button"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make it part of the source device to automatically reset the device if the user enables it?
Using a dummy phy, by means of EMAC to EMAC connection