Closed rony91jp closed 3 years ago
RMII clock output mode is not always work on esp32, we have two GPIO (16 and 17, they're inverted), in my experience, if GPIO17 can't work, then GPIO16 could work. Many causes can lead to such issues, like PCB trace (remember RMII clock is 50MHz) length. I can't reproduce your issue with my LAN8720 breakout board and some wire jumpers. Maybe you should go to the forum to ask for help.
we're seeing a similar issue with a custom board + LAN8710, the MAC comes up, connect / disconnect events work, and data is received / transmitted, but, we never receive an IP.
setting the debug level to VERBOSE
shows incoming ICMP packets that appear to be corrupt (MAC addresses that do not exist on the network etc.) so we're working on the basis this is an RMII / clock signal integrity issue. do y'all have any advice for further diagnosing this?
Hello,
Regarding the above issue, I was able to get the static IP address using the Arduino ethernet example. I used the below command to assign my static IP. ETH.begin();
ETH.config(IPAddress(192, 168, 1, 101),IPAddress(192, 168, 1, 1),IPAddress(255, 255, 255, 0),IPAddress(192, 168, 1, 1), IPAddress(192, 168, 1, 1));
Output: image
My question is, I want to disable the DHCP and want to assign the static IP above the same way in the esp-idf example. Where should I change in the esp-idf ethernet basic example program?
Thank you
@rony-91
To set static IP address, firstly you need to stop the dhcpc by esp_netif_dhcpc_stop
, then set IP into by esp_netif_set_ip_info
More info, please refer to https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_netif.html
@suda-morris
I need your little help. Why i did not get the static ip from below program?
static EventGroupHandle_t s_connect_event_group; static esp_ip4_addr_t s_ip_addr; static const char s_connection_name; static esp_netif_t s_example_esp_netif = NULL;
static const char *TAG = "online_connection"; static void start(void); static void stop(void);
static void on_got_ip(void arg, esp_event_base_t event_base, int32_t event_id, void event_data) {
ESP_LOGI(TAG, "Got IP event!");
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
memcpy(&s_ip_addr, &event->ip_info.ip, sizeof(s_ip_addr));
xEventGroupSetBits(s_connect_event_group, GOT_IPV4_BIT);
}
esp_err_t example_connect(void) { if (s_connect_event_group != NULL) { return ESP_ERR_INVALID_STATE; }
s_connect_event_group = xEventGroupCreate();
start();
ESP_ERROR_CHECK(esp_register_shutdown_handler(&stop));
ESP_LOGI(TAG, "Waiting for IP");
ESP_LOGI(TAG, "Connected to %s", s_connection_name);
ESP_LOGI(TAG, "IPv4 address: " IPSTR, IP2STR(&s_ip_addr));
xEventGroupWaitBits(s_connect_event_group, CONNECTED_BITS, true, true, portMAX_DELAY);
ESP_LOGI(TAG, "IPv4 address: " IPSTR, IP2STR(&s_ip_addr));
return ESP_OK;
}
esp_err_t example_disconnect(void) { if (s_connect_event_group == NULL) { return ESP_ERR_INVALID_STATE; } vEventGroupDelete(s_connect_event_group); s_connect_event_group = NULL; stop(); ESP_LOGI(TAG, "Disconnected from %s", s_connection_name); s_connection_name = NULL; return ESP_OK; }
static esp_eth_handle_t eth_handle = NULL; static esp_eth_mac_t s_mac = NULL; static esp_eth_phy_t s_phy = NULL; static void *s_eth_glue = NULL;
static void start(void) { esp_netif_config_t cfg = ESP_NETIF_DEFAULT_ETH(); esp_netif_t *eth_netif = esp_netif_new(&cfg); assert(eth_netif); s_example_esp_netif = eth_netif;
// Set default handlers to process TCP/IP stuffs
ESP_ERROR_CHECK(esp_eth_set_default_handlers(eth_netif));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip, NULL));
//Configuration using LAN8720
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
phy_config.phy_addr = CONFIG_EXAMPLE_ETH_PHY_ADDR;
phy_config.reset_gpio_num = CONFIG_EXAMPLE_ETH_PHY_RST_GPIO;
mac_config.smi_mdc_gpio_num = CONFIG_EXAMPLE_ETH_MDC_GPIO;
mac_config.smi_mdio_gpio_num = CONFIG_EXAMPLE_ETH_MDIO_GPIO;
s_mac = esp_eth_mac_new_esp32(&mac_config);
s_phy = esp_eth_phy_new_lan8720(&phy_config);
esp_eth_config_t config = ETH_DEFAULT_CONFIG(s_mac, s_phy);
ESP_ERROR_CHECK(esp_eth_driver_install(&config, ð_handle));
ESP_ERROR_CHECK(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(eth_handle)));
ESP_ERROR_CHECK(esp_eth_start(eth_handle));
s_connection_name = "ETH";
}
static void stop(void) { ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, &on_got_ip)); ESP_ERROR_CHECK(esp_eth_stop(eth_handle)); ESP_ERROR_CHECK(esp_eth_del_netif_glue(s_eth_glue)); ESP_ERROR_CHECK(esp_eth_clear_default_handlers(s_example_esp_netif)); ESP_ERROR_CHECK(esp_eth_driver_uninstall(eth_handle)); ESP_ERROR_CHECK(s_phy->del(s_phy)); ESP_ERROR_CHECK(s_mac->del(s_mac));
esp_netif_destroy(s_example_esp_netif);
s_example_esp_netif = NULL;
}
esp_netif_t *get_example_netif(void) { return s_example_esp_netif; }
[Ethernet_connect.h] Here i wrote the static ip address. / Common functions for protocol examples, to establish Wi-Fi or Ethernet connection. This example code is in the Public Domain (or CC0 licensed, at your option.) Unless required by applicable law or agreed to in writing, this software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /
extern "C" {
//#define EXAMPLE_INTERFACE get_example_netif()
//#define EXAMPLE_INTERFACE get_example_netif()
// #define CONFIG_EXAMPLE_CONNECT_IPV6
/**
/**
}
[Output is below]
The above problem has solved. Thank you all for your support.
Hello,
I am currently using ESP32-POE board and tried to build an Ethernet Connection. Following is the result. Below is the example configuration& ethernet configuration
Thank you