MII instead of RMII: receiving is not possible

belinea123
Posts: 4
Joined: Tue Apr 17, 2018 4:13 pm

MII instead of RMII: receiving is not possible

Postby belinea123 » Thu May 03, 2018 6:02 pm

Hello,

my collegues and me have made a PCB that connects ESP32 with an ethernet switch. The interface is MII and it uses no PHY.

Image

I'm using an ESP32 from Pycom (W01). I made some small modifications to the esp_idf so that the ESP32 is configured to mii instead of rmii.

The sending direction is OK. I see DHCP packets at the other end of the ethernet switch. But the receiving direction does not work.

For mii, RXD0..3 are needed. MAC_RXD2 and UART0_TX are on the same pin though. That is why I set the loglevel to None and set CONFIG_CONSOLE_UART to CONFIG_CONSOLE_UART_NONE.

I measure at the pin MAC_RXD2 a constant voltage level of 2.2V.

Here are the functions I use for pin configuration:

Code: Select all

void phy_mii_configure_data_interface_pins(void)
{

    // RXDV to GPIO27
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO27_U, FUNC_GPIO27_EMAC_RX_DV);

    // TXD0 to GPIO19
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, FUNC_GPIO19_EMAC_TXD0);
    // TX_EN to GPIO21
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_EMAC_TX_EN);
    // TXD1 to GPIO22
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, FUNC_GPIO22_EMAC_TXD1);
	
	// TXD2 to GPIO14
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_MTMS_EMAC_TXD2);
	// TXD3 to GPIO12
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_MTDI_EMAC_TXD3);
	
	// TXER to GPIO04
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4_EMAC_TX_ER);
	
	
    // RXD0 to GPIO25
    gpio_set_direction(25, GPIO_MODE_INPUT);
    // RXD1 to GPIO26
    gpio_set_direction(26, GPIO_MODE_INPUT);
	// RXD2 to GPIO01
    gpio_set_direction(1, GPIO_MODE_INPUT);
    // RXD3 to GPIO15
    gpio_set_direction(15, GPIO_MODE_INPUT);
    // RMII TXCLK to GPIO0
    gpio_set_direction(0, GPIO_MODE_INPUT);
	// RMII RXCLK to GPIO5
    gpio_set_direction(5, GPIO_MODE_INPUT);
	// RXER to GPIO13
    gpio_set_direction(13, GPIO_MODE_INPUT);
}

void phy_rmii_smi_configure_pins(uint8_t mdc_gpio, uint8_t mdio_gpio)
{
    // setup SMI MDC pin
    gpio_set_direction(mdc_gpio, GPIO_MODE_OUTPUT);
    gpio_matrix_out(mdc_gpio, EMAC_MDC_O_IDX, 0, 0);
    PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[mdc_gpio], PIN_FUNC_GPIO);
    // setup SMI MDIO pin
    gpio_set_direction(mdio_gpio, GPIO_MODE_INPUT_OUTPUT);
    gpio_matrix_out(mdio_gpio, EMAC_MDO_O_IDX, 0, 0);
    gpio_matrix_in(mdio_gpio, EMAC_MDI_I_IDX, 0);
    PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[mdio_gpio], PIN_FUNC_GPIO);
}
Is there a mistake in the pin configuration for mii?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: MII instead of RMII: receiving is not possible

Postby WiFive » Fri May 04, 2018 2:00 am

Why you skip PIN_FUNC_SELECT for some pins?

belinea123
Posts: 4
Joined: Tue Apr 17, 2018 4:13 pm

Re: MII instead of RMII: receiving is not possible

Postby belinea123 » Wed May 09, 2018 1:50 pm

You are right. I reconfigured the functions of several mii rx pins. I made sure that mii rx err is on GND. Now the communication works in both directions. Thanks.

Here is my pin configuration function:

Code: Select all

void phy_mii_configure_data_interface_pins(void)
{
	esp_err_t status = 0;
	gpio_num_t gpio_num;

    // RXDV to GPIO27
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO27_U, FUNC_GPIO27_EMAC_RX_DV);

    // TXD0 to GPIO19
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO19_U, FUNC_GPIO19_EMAC_TXD0);
    // TX_EN to GPIO21
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO21_U, FUNC_GPIO21_EMAC_TX_EN);
    // TXD1 to GPIO22
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO22_U, FUNC_GPIO22_EMAC_TXD1);
	
	// TXD2 to GPIO14
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_MTMS_EMAC_TXD2);
	// TXD3 to GPIO12
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_MTDI_EMAC_TXD3);
	
	// TXER to GPIO04
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4_EMAC_TX_ER);
	
	
	
	// RXER to GPIO13
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_MTCK_EMAC_RX_ER);
	// RXD2 to GPIO01
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_EMAC_RXD2);
    
    // RXD0
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO25_U, FUNC_GPIO25_EMAC_RXD0);
    // RXD1
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO26_U, FUNC_GPIO26_EMAC_RXD1);
    // RXD3
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_MTDO_EMAC_RXD3);
    // RMII RXCLK
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5_EMAC_RX_CLK);
	
	
	
    // RXD0 to GPIO25
    gpio_set_direction(25, GPIO_MODE_INPUT);
    // RXD1 to GPIO26
    gpio_set_direction(26, GPIO_MODE_INPUT);
	// RXD2 to GPIO01
    gpio_set_direction(1, GPIO_MODE_INPUT);
    // RXD3 to GPIO15
    gpio_set_direction(15, GPIO_MODE_INPUT);
    // RMII TXCLK to GPIO0
    gpio_set_direction(0, GPIO_MODE_INPUT);
	// RMII RXCLK to GPIO5
    gpio_set_direction(5, GPIO_MODE_INPUT);
	// RXER to GPIO13
    gpio_set_direction(13, GPIO_MODE_INPUT);
}

Lukasz
Posts: 1
Joined: Tue Aug 30, 2022 5:50 am

Re: MII instead of RMII: receiving is not possible

Postby Lukasz » Tue Aug 30, 2022 7:09 am

Hello,
I'm trying to run a similar circuit (88E6185 + ESP32). Could you please provide some working code. Did you use ESP-IDF to write code? The documentation shows that ISP only supports the RMII interface: "ESP-IDF only supports the RMII interface (i.e. always select CONFIG_ETH_PHY_INTERFACE_RMII in Kconfig option CONFIG_ETH_PHY_INTERFACE)."

Who is online

Users browsing this forum: No registered users and 113 guests