EMAC receive not working

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

EMAC receive not working

Postby RobinC » 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?

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: EMAC receive not working

Postby rudi ;-) » Tue Feb 14, 2017 12:07 pm

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 ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

Re: EMAC receive not working

Postby RobinC » Tue Feb 14, 2017 2:17 pm

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.

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: EMAC receive not working

Postby rudi ;-) » Tue Feb 14, 2017 8:10 pm

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.
ESP32-EVB_Rev_A.pdf
(310.33 KiB) Downloaded 824 times
The thing is opensource.

I have recently received one and are currently studying the circuit.
IMG_5954_s3.jpg
IMG_5954_s3.jpg (248.39 KiB) Viewed 16285 times

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.
-------------------------------------
問候飛出去的朋友遍全球魯迪

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

Re: EMAC receive not working

Postby RobinC » Tue Feb 14, 2017 9:42 pm

Thanks Rudy. That is very interesting.

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

Re: EMAC receive not working

Postby RobinC » Tue Feb 14, 2017 11:33 pm

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).

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: EMAC receive not working

Postby rudi ;-) » Wed Feb 15, 2017 1:40 am

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 ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

joeyc73
Posts: 1
Joined: Thu Feb 23, 2017 3:40 am

Re: EMAC receive not working

Postby joeyc73 » Thu Feb 23, 2017 3:43 am

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?

RobinC
Posts: 45
Joined: Sat Feb 04, 2017 5:29 pm

Re: EMAC receive not working

Postby RobinC » Fri Feb 24, 2017 1:49 am

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.

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: EMAC receive not working

Postby rudi ;-) » Sat Feb 25, 2017 10:34 am

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

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();
}

phy_not_found.png
phy_not_found.png (24.79 KiB) Viewed 16094 times

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?
IMG_6005_s.jpg
IMG_6005_s.jpg (187.89 KiB) Viewed 16094 times

we must change the xtal to 50 MHz for RMII Mode,
and hope you know this too:
a 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.
added the note to the LAN8270.. Request



just in time try the LAN8720
IMG_6004_s.jpg
IMG_6004_s.jpg (186.84 KiB) Viewed 16094 times
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.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: No registered users and 60 guests