Skip to content
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

ESP-IDF 4.X on arduino platform breaks ETH PHY support (IDFGH-5356) #7107

Closed
rtu-dataframe opened this issue Jun 4, 2021 · 7 comments
Closed
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@rtu-dataframe
Copy link

Hi guys, as i've reported in the esp32-arduino repo, starting from the IDF 4.x version, there are in place a lot of changes that breaks Ethernet on most of third party boards (Like Olimex, etc...).

For example, the driver initialization doesn't have the CLK GPIO option selectable and nowhere is documented that.

This represent for the overall esp32-arduino users a big problem to face...: here there are all details, scope traces and informations: ISSUE HERE

@rtu-dataframe rtu-dataframe changed the title ESP-IDF 4.4 on arduino platform breaks ETH PHY support ESP-IDF 4.X on arduino platform breaks ETH PHY support Jun 4, 2021
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jun 4, 2021
@github-actions github-actions bot changed the title ESP-IDF 4.X on arduino platform breaks ETH PHY support ESP-IDF 4.X on arduino platform breaks ETH PHY support (IDFGH-5356) Jun 4, 2021
@negativekelvin
Copy link
Contributor

It's a compile time option so when libraries are precompiled for Arduino the choice is locked. I think it could be made configurable at runtime, there's not really any penalty. This could also benefit micropython and other platforms that need to support multiple hardware configurations. What do you think @suda-morris ?

#if CONFIG_ETH_RMII_CLK_INPUT
#if CONFIG_ETH_RMII_CLK_IN_GPIO == 0
/* RMII clock (50MHz) input to GPIO0 */
gpio_hal_iomux_func_sel(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_EMAC_TX_CLK);
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[0]);
#else
#error "ESP32 EMAC only support input RMII clock to GPIO0"
#endif
#endif
#if CONFIG_ETH_RMII_CLK_OUTPUT
#if CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0
/* APLL clock output to GPIO0 (must be configured to 50MHz!) */
gpio_hal_iomux_func_sel(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
PIN_INPUT_DISABLE(GPIO_PIN_MUX_REG[0]);
#elif CONFIG_ETH_RMII_CLK_OUT_GPIO == 16
/* RMII CLK (50MHz) output to GPIO16 */
gpio_hal_iomux_func_sel(PERIPHS_IO_MUX_GPIO16_U, FUNC_GPIO16_EMAC_CLK_OUT);
PIN_INPUT_DISABLE(GPIO_PIN_MUX_REG[16]);
#elif CONFIG_ETH_RMII_CLK_OUT_GPIO == 17
/* RMII CLK (50MHz) output to GPIO17 */
gpio_hal_iomux_func_sel(PERIPHS_IO_MUX_GPIO17_U, FUNC_GPIO17_EMAC_CLK_OUT_180);
PIN_INPUT_DISABLE(GPIO_PIN_MUX_REG[17]);
#endif
#endif // CONFIG_ETH_RMII_CLK_OUTPUT
/* Clock configuration */
#if CONFIG_ETH_PHY_INTERFACE_MII
hal->ext_regs->ex_phyinf_conf.phy_intf_sel = 0;
hal->ext_regs->ex_clk_ctrl.mii_clk_rx_en = 1;
hal->ext_regs->ex_clk_ctrl.mii_clk_tx_en = 1;
#elif CONFIG_ETH_PHY_INTERFACE_RMII
hal->ext_regs->ex_phyinf_conf.phy_intf_sel = 4;
#if CONFIG_ETH_RMII_CLK_INPUT
hal->ext_regs->ex_clk_ctrl.ext_en = 1;
hal->ext_regs->ex_clk_ctrl.int_en = 0;
hal->ext_regs->ex_oscclk_conf.clk_sel = 1;
#elif CONFIG_ETH_RMII_CLK_OUTPUT
hal->ext_regs->ex_clk_ctrl.ext_en = 0;
hal->ext_regs->ex_clk_ctrl.int_en = 1;
hal->ext_regs->ex_oscclk_conf.clk_sel = 0;
emac_config_apll_clock();
hal->ext_regs->ex_clkout_conf.div_num = 0;
hal->ext_regs->ex_clkout_conf.h_div_num = 0;
#if CONFIG_ETH_RMII_CLK_OUTPUT_GPIO0
/* Choose the APLL clock to output on GPIO */
REG_WRITE(PIN_CTRL, 6);
#endif // CONFIG_RMII_CLK_OUTPUT_GPIO0
#endif // CONFIG_ETH_RMII_CLK_INPUT

@atanisoft
Copy link

@negativekelvin in IDF v3.x it was runtime configurable.

@suda-morris
Copy link
Collaborator

Thanks for reporting, IDF will add that runtime "mac clock config" option back soon.

@rtu-dataframe
Copy link
Author

Thanks @suda-morris, we are waiting for that! :)

@rtu-dataframe
Copy link
Author

@suda-morris, any news about this issue?

@kostaond
Copy link
Collaborator

@Simonefardella It's going to be worked very soon. There is EMAC HAL code refactor update pending to be merged which needs to be finished first. It's been already review so we could start "mac clock config" soon. Thank you for your patience.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jun 23, 2021
@kostaond
Copy link
Collaborator

@Simonefardella just FYI, the update is in review.

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress labels Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

6 participants