EMAC receive not working
Posted: Tue Feb 14, 2017 12:37 am
I have the DevkitC board wired up to an ethernet phy (in this case a LAN8720) and have modified the example code to work with that phy. I can interact with the phy through MDC/MDIO and I'm seeing a good link status/speed/duplex when I plug into a switch. I'm doing a packet trace and see the transmitted DHCP request on the DHCP server (and I see the ISR receive the TX done interrupt) and I see the response going back from the DHCP server. Unfortunately, the ESP32 never receives the packet (no receive interrupt is received by the ISR). I've scoped the rxd0/1 and see packets coming in with the correct voltages.
I noticed that CRS_DV is not configured in the example code so I wired it up to GPIO27 as per the docs and added the appropriate PIN_FUNC_SELECT but that makes no difference.
From the example code:
//txd0 to gpio19 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, FUNC_GPIO19_EMAC_TXD0);
//tx_en to gpio21 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_EMAC_TX_EN);
//txd1 to gpio22 , can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, FUNC_GPIO22_EMAC_TXD1);
//rxd0 to gpio25 , can not change
gpio_set_direction(25, GPIO_MODE_INPUT);
//rxd1 to gpio26 ,can not change
gpio_set_direction(26, GPIO_MODE_INPUT);
//rmii clk ,can not change
gpio_set_direction(0, GPIO_MODE_INPUT);
//mdc to gpio4
gpio_matrix_out(4, EMAC_MDC_O_IDX, 0, 0);
//mdio to gpio2
gpio_matrix_out(2, EMAC_MDO_O_IDX, 0, 0);
gpio_matrix_in(2, EMAC_MDI_I_IDX, 0);
How does the EMAC know the source of the RX_CLK (i.e. it is in RMII mode vs MII)?
Why isn't PIN_FUNC_SELECT called for RX pins like:
//rxd0 to gpio25 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO25_U, FUNC_GPIO25_EMAC_RXD0);
//rxd1 to gpio26 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO26_U, FUNC_GPIO26_EMAC_RXD1);
Any pointers on where to look?
I noticed that CRS_DV is not configured in the example code so I wired it up to GPIO27 as per the docs and added the appropriate PIN_FUNC_SELECT but that makes no difference.
From the example code:
//txd0 to gpio19 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, FUNC_GPIO19_EMAC_TXD0);
//tx_en to gpio21 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_EMAC_TX_EN);
//txd1 to gpio22 , can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, FUNC_GPIO22_EMAC_TXD1);
//rxd0 to gpio25 , can not change
gpio_set_direction(25, GPIO_MODE_INPUT);
//rxd1 to gpio26 ,can not change
gpio_set_direction(26, GPIO_MODE_INPUT);
//rmii clk ,can not change
gpio_set_direction(0, GPIO_MODE_INPUT);
//mdc to gpio4
gpio_matrix_out(4, EMAC_MDC_O_IDX, 0, 0);
//mdio to gpio2
gpio_matrix_out(2, EMAC_MDO_O_IDX, 0, 0);
gpio_matrix_in(2, EMAC_MDI_I_IDX, 0);
How does the EMAC know the source of the RX_CLK (i.e. it is in RMII mode vs MII)?
Why isn't PIN_FUNC_SELECT called for RX pins like:
//rxd0 to gpio25 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO25_U, FUNC_GPIO25_EMAC_RXD0);
//rxd1 to gpio26 ,can not change
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO26_U, FUNC_GPIO26_EMAC_RXD1);
Any pointers on where to look?