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

ESP32 MAC not reacting to received signals (IDFGH-11399) #12537

Closed
3 tasks done
MrGaintsquirrel opened this issue Nov 7, 2023 · 27 comments
Closed
3 tasks done

ESP32 MAC not reacting to received signals (IDFGH-11399) #12537

MrGaintsquirrel opened this issue Nov 7, 2023 · 27 comments
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@MrGaintsquirrel
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Hi,

For a project I am using the lan8671 phy for SPE 10base-T1S in point to point mode but, I have some issues. I am using the ESP32 devkitc V4 with ESP-IDF V5.1.1.
The issue is when I am trying to ping another board I can see the rmii TX signals with the oscilloscope and can see them arrive on the other board so it looks the phy is working but the ESP doesn't react to it. I think I configure the mac the correct way following the example from the esp-idf website. the signals look like arp request is it maybey possible that there are more configurations needed for point to point?

`
static eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
mac_config.flags = ETH_MAC_FLAG_PIN_TO_CORE;
static eth_esp32_emac_config_t esp32_emac_config = ETH_ESP32_EMAC_DEFAULT_CONFIG();
esp32_emac_config.smi_mdc_gpio_num = 4;
esp32_emac_config.smi_mdio_gpio_num = 5;
esp32_emac_config.interface = EMAC_DATA_INTERFACE_RMII;
esp32_emac_config.clock_config.rmii.clock_gpio = 0;
esp32_emac_config.clock_config.rmii.clock_mode = EMAC_CLK_EXT_IN;

mac->set_speed(mac, 0); //Configure mac speed to 10Mbit
mac->set_duplex(mac, 0); //Configure mac to half duplex

eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
phy_config.phy_addr = 0x00;
phy_config.reset_gpio_num = 15;

esp_eth_phy_t *phy = esp_eth_phy_new_lan867x(&phy_config);

esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);

static esp_eth_handle_t eth_handle = NULL;

esp_err_t err = esp_eth_driver_install(&config, &eth_handle);
ESP_LOGI(TAG, "Ethernet Driver install: %s", esp_err_to_name(err));

esp_event_loop_create_default();
esp_netif_init();
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH();
esp_netif_t *eth_netif = esp_netif_new(&cfg);

err = esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle));
ESP_LOGI(TAG, "esp_netif_attach: %s", esp_err_to_name(err));

esp_netif_ip_info_t ip;
const char* ip4 = "192.168.0.3";
const char* gw = "0.0.0.0";
const char* netmask = "255.255.255.0";
esp_netif_dhcpc_stop(eth_netif);
memset(&ip, 0, sizeof(esp_netif_ip_info_t));
ipaddr_aton((const char *)ip4, &ip.ip.addr);
ipaddr_aton((const char *)gw, &ip.gw);
ipaddr_aton((const char *)netmask, &ip.netmask);
esp_netif_set_ip_info(eth_netif, &ip);`

The event does trigger that it got an IP address.

Thanks in advance

@github-actions github-actions bot changed the title ESP32 MAC not reacting to received signals ESP32 MAC not reacting to received signals (IDFGH-11399) Nov 7, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 7, 2023
@kostaond
Copy link
Collaborator

kostaond commented Nov 8, 2023

What is the source of the REF RMII CLK for the PHY?

BTW: just a teaser, we are preparing a demo with 10base-T1S. It will be ready soon :)

@MrGaintsquirrel
Copy link
Author

Oh nice. but the only difference is the phy right?

I am using a external 50mhz clock source (https://www.we-online.com/components/products/datasheet/831056249.pdf).
I also desolderd it and tried to clock it from the esp itself but no difference. the MDIO lines are working and I can write and read to the registers.

@kostaond
Copy link
Collaborator

kostaond commented Nov 8, 2023

We use LAN8670 for the demo.

Regarding your issue, what is you test setup? Two ESP32's with LAN8671 - one ESP as DHCP server and the other one as DHCP Client? If so, you need to start DHCP server in ETHERNET_EVENT_CONNECTED event. I don't see the DHCP start in your code snipped.

@MrGaintsquirrel
Copy link
Author

I don't use DHCP. my test setup is indeed two esp's connected together one doing icmp and the other one programmed like above.

@kostaond
Copy link
Collaborator

kostaond commented Nov 8, 2023

Try to increase debug level or change this line to see if your device receives Ethernet frames.

@MrGaintsquirrel
Copy link
Author

MrGaintsquirrel commented Nov 8, 2023

So i changed that line to ESP_LOGI(TAG, "receive len= %d", recv_len); but it didn't print anything. So I added ESP_LOGI(TAG, "RX-task running"); to here and it also doens't print that so does that mean the whole rx task isn't running?

@kostaond
Copy link
Collaborator

kostaond commented Nov 8, 2023

The Rx task is blocked and it waits for interrupt from EMAC. The task is released once the EMAC receives a data. It indicates you that no data is received.

Unfortunately, I cannot help you without seeing your complete code. However, going over it would be duplication of work for me since we're working on the driver too. We're almost there, we're able to send/receive. We just need to polish it and prepare demo. Could you please wait a week?

@MrGaintsquirrel
Copy link
Author

Okay thanks for the help. I can wait a week could you please inform me or something when it is ready and how i can test it out?

@kostaond
Copy link
Collaborator

kostaond commented Nov 8, 2023

@ThijsvanBovene, I'll let you know once the driver is ready.

@MrGaintsquirrel
Copy link
Author

MrGaintsquirrel commented Nov 17, 2023

@kostaond Hi, Just want to ask how it is going with the driver. is there maybe a beta version?

@kostaond
Copy link
Collaborator

kostaond commented Nov 20, 2023

@ThijsvanBovene, please check https://github.com/bogdankolendovskyy/esp-eth-drivers/tree/lan867x/lan867x.

However, keep in mind that it's work in progress. If you have any questions or suggestions, they are very welcomed.

@adeepn
Copy link

adeepn commented Nov 22, 2023

@ThijsvanBovene, please check https://github.com/bogdankolendovskyy/esp-eth-drivers/tree/lan867x/lan867x.

However, keep in mind that it's work in progress. If you have any questions or suggestions, they are very welcomed.

bogdankolendovskyy/esp-eth-drivers#1

We already have devices on esp32 with lan8671 and can do any tests :)

@MrGaintsquirrel
Copy link
Author

@adeepn what silicon revision do you have?

@adeepn
Copy link

adeepn commented Nov 23, 2023

@adeepn what silicon revision do you have?

B1

@MrGaintsquirrel
Copy link
Author

So i used the server example for the lan867x but, when i upload it the got ip event doesn't trigger. But it does say ethernet attached to netif.

@kostaond
Copy link
Collaborator

So i used the server example for the lan867x but, when i upload it the got ip event doesn't trigger. But it does say ethernet attached to netif.

You wouldn't see IP event on server... It has static IP and it is not reported.

Once you connect the second device, the client, you should see:

I (402) esp_eth.netif.netif_glue: ethernet attached to netif
I (3102) ethernet_init: Ethernet(LAN867x[23,18]) Started
I (3102) ethernet_init: Ethernet(LAN867x[23,18]) Link Up
I (3102) ethernet_init: Ethernet(LAN867x[23,18]) HW Addr 08:3a:f2:31:20:f7
I (67852) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.1.2
I (67852) lan867x_example: Assigned ip 192.168.1.2 to a connected device.

@MrGaintsquirrel
Copy link
Author

ohh oke I will try that thank you

@adeepn
Copy link

adeepn commented Nov 23, 2023

So i used the server example for the lan867x but, when i upload it the got ip event doesn't trigger. But it does say ethernet attached to netif.

You wouldn't see IP event on server... It has static IP and it is not reported.

Once you connect the second device, the client, you should see:

I (402) esp_eth.netif.netif_glue: ethernet attached to netif
I (3102) ethernet_init: Ethernet(LAN867x[23,18]) Started
I (3102) ethernet_init: Ethernet(LAN867x[23,18]) Link Up
I (3102) ethernet_init: Ethernet(LAN867x[23,18]) HW Addr 08:3a:f2:31:20:f7
I (67852) esp_netif_lwip: DHCP server assigned IP to a client, IP is: 192.168.1.2
I (67852) lan867x_example: Assigned ip 192.168.1.2 to a connected device.

clients works: dhcp ip assigned and arp-ping and icmp pings shows no lost packets.

@MrGaintsquirrel
Copy link
Author

Hi,
So i have tried getting the examples to work but no success yet. I have a few questions.
when I run the server example I have added that it needs to blink a LED but, it doesn't do that so it doesn't come in the while loop. is that normal like is it waiting for a first client and than it continues to the while?
what K config settings are you using? I changed my mdio pins and it does come through the init so it looks like it is working but maybey there are other settings i need to change.
what version of ESP-IDF are you using? i am using 5.1.1

@MrGaintsquirrel
Copy link
Author

IT WORKSSSS!!!!
image

@kostaond
Copy link
Collaborator

@ThijsvanBovene what was the issue?

@MrGaintsquirrel
Copy link
Author

@kostaond I have 3 boards i think 1 is broken(it still doesn’t work). And i added a 100ohm resistor on both cable ends and uploaded and it started working.

Although i still have a question about the driver: i see that with custom_crtl it is should be possible to set plca and other registers but those register acording to the datasheet need to be controlled via MMD. But i don’t see that in the software.

@kostaond
Copy link
Collaborator

@hijsvanBovene very good point. I'll discuss with my colleague. We haven't tested PLCA yet because we also started with 3 boards and one is broken :D We're waiting for new one, it's slow process... Anyway, really appreciate your input!

@MrGaintsquirrel
Copy link
Author

@kostaond For my project I have to test PLCA so I already made some code. I will let you know if it works and is it okay if I post the MMD operations?

@kostaond
Copy link
Collaborator

@kostaond For my project I have to test PLCA so I already made some code. I will let you know if it works and is it okay if I post the MMD operations?

Yes, contributions are very much welcomed. However, please wait until Bogdan's fork is merged to https://github.com/espressif/esp-eth-drivers.

@kostaond
Copy link
Collaborator

kostaond commented Dec 6, 2023

@ThijsvanBovene, @adeepn, feel free to review - espressif/esp-eth-drivers#19

@kostaond
Copy link
Collaborator

The LAN867x is available at https://github.com/espressif/esp-eth-drivers

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Mar 22, 2024
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

4 participants