EMAC receive not working
EMAC receive not working
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?
Re: EMAC receive not working
hi robin
do you have snippet of your example code on github or other place or is taken from here with modifikation ?
how looks your packet send, have you first try a simple ping, does it fire the tx isr, too?
best wishes
rudi
do you have snippet of your example code on github or other place or is taken from here with modifikation ?
how looks your packet send, have you first try a simple ping, does it fire the tx isr, too?
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: EMAC receive not working
Hi Rudi. You cannot ping until you have an IP address. The code above is taken directly from the example from the distribution on github.
Re: EMAC receive not working
Hi Robin
thanks for feedback, ok I understand.
I wanted to exclude that you have not yet got ip.
So, then it depends on another place.
I do not know if you know it.
Olimex has released an ESP32-EVB RevA Board with Ethernet. The thing is opensource.
I have recently received one and are currently studying the circuit.
There are still a few things open but I think the approach is already good.
Where it is now exactly, will presumably write to the register.
Let's see what can be done. Will follow the thread and hold you up2date what happend and go on with this board this week.
best wishes
rudi
thanks for feedback, ok I understand.
I wanted to exclude that you have not yet got ip.
So, then it depends on another place.
I do not know if you know it.
Olimex has released an ESP32-EVB RevA Board with Ethernet. The thing is opensource.
I have recently received one and are currently studying the circuit.
There are still a few things open but I think the approach is already good.
Where it is now exactly, will presumably write to the register.
Let's see what can be done. Will follow the thread and hold you up2date what happend and go on with this board this week.
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: EMAC receive not working
Thanks Rudy. That is very interesting.
Re: EMAC receive not working
Rudi, I looked at the olimex schematics (available on github) and they did some interesting things with function routing. Some of the choices they made are not per the pin/function specs of the ESP32. Have you tried the ethernet on your new board? It looks like CR1 is not populated and they are providing the RMII clock from the ESP32 GPIO16.
It looks like these boards are out of stock. I'm eager to get one when they are available.
Did they provide firmware that you can download into the board? I don't see the project firmware up on github so you might want to dump the flash to a file before you try to program it (if you haven't already done that).
It looks like these boards are out of stock. I'm eager to get one when they are available.
Did they provide firmware that you can download into the board? I don't see the project firmware up on github so you might want to dump the flash to a file before you try to program it (if you haven't already done that).
Re: EMAC receive not working
hi robin,
the basic idea to the board is damn promising.
let some time pass and a little play until the weekend.
i'm just about to test the REV A board, therefore write a small firmware for this and will upload it to github in the coming days, too.
best wishes
rudi
the basic idea to the board is damn promising.
let some time pass and a little play until the weekend.
i'm just about to test the REV A board, therefore write a small firmware for this and will upload it to github in the coming days, too.
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: EMAC receive not working
Hi Robin,
I am also working on this exact setup (esp32 and LAN8720). I'm trying to follow the same example on github but I'm not able to setup an ip address to ping the esp32. I was wondering if you had made any more progress on your end?
I am also working on this exact setup (esp32 and LAN8720). I'm trying to follow the same example on github but I'm not able to setup an ip address to ping the esp32. I was wondering if you had made any more progress on your end?
Re: EMAC receive not working
Hi Joey. There have been some changes to the pins used for EMAC in the git repository. I'm going to try those even though the only material change was to add a GPIO to shut down the PHY power so GPIO0 would work at boot.
I also have a TLK110 eval board that I'm going to modify for 50MHz rmii and try the stock git code. I'll post progress. I think Rudy is posting progress with his project as well. To bad we can't get any feedback from Espressif. We will probably just have to wait until they give more details or tell us the EMAC doesn't work.
I also have a TLK110 eval board that I'm going to modify for 50MHz rmii and try the stock git code. I'll post progress. I think Rudy is posting progress with his project as well. To bad we can't get any feedback from Espressif. We will probably just have to wait until they give more details or tell us the EMAC doesn't work.
Re: EMAC receive not working
hi robin,
have found more small crazy "hang up" point without a return message...
one step it can be help for init the phy:
https://github.com/espressif/esp-idf/bl ... ain.c#L104
https://github.com/espressif/esp-idf/bl ... 0_phy.h#L5
can you check/test this:
get you the message "phy not found?"
i have more "debug lines inserted, cause we get on more steps no return, ( bad ethernet example code that does not run! )
which eval board you have from tlk110?
i use this tlk110:
btw: if you use the same, how you connect it, over pinheader or MII adpater?
we must change the xtal to 50 MHz for RMII Mode,
and hope you know this too:
just in time try the LAN8720
and try the LAN8710 ( olimex ESP32 EVB )
( here posted in the thread )
how you connect your pins from the board to the esp?
do you use pullups / pulldown on the lines?
on which?
how looks your header file for the LAN8720?
do you have short lines! ( under 10 cm )
cause it is hi speed!
btw, from where/what you use the 50MHz ( tlk110 ) board?
best wishes
rudi
have found more small crazy "hang up" point without a return message...
one step it can be help for init the phy:
https://github.com/espressif/esp-idf/bl ... ain.c#L104
https://github.com/espressif/esp-idf/bl ... 0_phy.h#L5
Code: Select all
while (esp_eth_smi_read(PHY_IDENTIFIER_REG) != OUI_MSB_21TO6_DEF) { }
Code: Select all
#define PHY_IDENTIFIER_REG (0x2)
#define OUI_MSB_21TO6_DEF 0x2000
can you check/test this:
get you the message "phy not found?"
Code: Select all
void phy_tlk110_init(void)
{
uint32_t registrat = 0;
ESP_LOGI(TAG, "phy_tlk110_init: [%d]", __LINE__);
esp_eth_smi_write(PHY_RESET_CONTROL_REG, SOFTWARE_RESET);
/*
/*
#define PHY_IDENTIFIER_REG (0x2)
#define OUI_MSB_21TO6_DEF 0x2000
8192 !!! ;-))))))
*/
while (esp_eth_smi_read(PHY_IDENTIFIER_REG) != OUI_MSB_21TO6_DEF) {
ESP_LOGI(TAG, "hang here: [%d]:[%s]", __LINE__, __FILE__);
printf("Ethernet Phy Not Found: 0x%5x\n\r", esp_eth_smi_read(registrat) );
// vTaskDelay(5000 / portTICK_PERIOD_MS);
if(registrat >= OUI_MSB_21TO6_DEF) {
ESP_LOGI(TAG, "nothing found 0..0x2000");
ESP_LOGI(TAG, "hang here now: [%d]:[%s]", __LINE__, __FILE__);
while(-1);
}
++registrat;
}
esp_eth_smi_write(SOFTWARE_STRAP_CONTROL_REG, DEFAULT_PHY_CONFIG |SW_STRAP_CONFIG_DONE);
ets_delay_us(300);
//if config.flow_ctrl_enable == true ,enable this
phy_enable_flow_ctrl();
}
i have more "debug lines inserted, cause we get on more steps no return, ( bad ethernet example code that does not run! )
which eval board you have from tlk110?
i use this tlk110:
btw: if you use the same, how you connect it, over pinheader or MII adpater?
we must change the xtal to 50 MHz for RMII Mode,
and hope you know this too:
added the note to the LAN8270.. Requesta note on tlk110
In the datasheet of the TLK110 under the description of "CLKOUT" it is written: "In RMII mode, this pin provides a 50MHz clock output. This feature allows other devices to use the reference clock from TLK110 without requiring additional clock sources."
be "warned"
CLKOUT on the TLK110 is simply a 50 MHz reference clock that doesn't have any timing relationship to the RMII signals. Therefore, it can not be used as the 50MHz RMII reference clock
it is tlk110 specification.
btw:
This issue has been highlighted ... errata will be updated with this item to ensure that customers understand that they should not use TLK110 50MHz output as RMII_REFCLK.
just in time try the LAN8720
and try the LAN8710 ( olimex ESP32 EVB )
( here posted in the thread )
how you connect your pins from the board to the esp?
do you use pullups / pulldown on the lines?
on which?
how looks your header file for the LAN8720?
do you have short lines! ( under 10 cm )
cause it is hi speed!
btw, from where/what you use the 50MHz ( tlk110 ) board?
best wishes
rudi
Last edited by rudi ;-) on Sat Feb 25, 2017 1:42 pm, edited 1 time in total.
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Who is online
Users browsing this forum: Bing [Bot] and 184 guests