espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.84k stars 7.32k forks source link

Ethernet Link Down--ESP32S3 with W5500 to establish an Ethernet connection (IDFGH-13341) #14257

Open Chillimeat opened 4 months ago

Chillimeat commented 4 months ago

Answers checklist.

General issue report

I am currently using ESP32S3 with W5500 to establish an Ethernet connection, using version V5.3. The current issue I'm facing is that the network card repeatedly restarts and shuts down. Even when it starts up normally, it fails to communicate with other hosts

The log information is as follows:

I (301) main_task: Started on CPU0 I (311) main_task: Calling app_main() I (311) eth_example: GPIO ISR service installed I (311) eth_example: esp-netif initialized I (321) eth_example: Event loop created I (321) eth_example: SPI bus initialized E (431) w5500.mac: W5500 version mismatched, expected 0x04, got 0xa0 E (431) w5500.mac: emac_w5500_init(826): verify chip ID failed I (431) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 E (441) esp_eth: esp_eth_driver_install(228): init mac failed ESP_ERROR_CHECK failed: esp_err_t 0x10a (ESP_ERR_INVALID_VERSION) at 0x4200a752 0x4200a752: app_main at /Users/11/Documents/code/tools/w5-s3/main/main.c:205 (discriminator 1)

file: "./main/main.c" line 205 func: app_main expression: esp_eth_driver_install(&config, &handle)

abort() was called at PC 0x4037b4ef on core 0 0x4037b4ef: _esp_error_check_failed at /Users/11/esp/v5.3/esp-idf/components/esp_system/esp_err.c:49

Backtrace: 0x40375b16:0x3fc9c670 0x4037b4f9:0x3fc9c690 0x40382c1d:0x3fc9c6b0 0x4037b4ef:0x3fc9c720 0x4200a752:0x3fc9c750 0x42035973:0x3fc9c880 0x4037bf8d:0x3fc9c8b0 0x40375b16: panic_abort at /Users/11/esp/v5.3/esp-idf/components/esp_system/panic.c:463 0x4037b4f9: esp_system_abort at /Users/11/esp/v5.3/esp-idf/components/esp_system/port/esp_system_chip.c:92 0x40382c1d: abort at /Users/11/esp/v5.3/esp-idf/components/newlib/abort.c:38 0x4037b4ef: _esp_error_check_failed at /Users/11/esp/v5.3/esp-idf/components/esp_system/esp_err.c:49 0x4200a752: app_main at /Users/11/Documents/code/tools/w5-s3/main/main.c:205 (discriminator 1) 0x42035973: main_task at /Users/11/esp/v5.3/esp-idf/components/freertos/app_startup.c:208 0x4037bf8d: vPortTaskWrapper at /Users/11/esp/v5.3/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134

ELF file SHA256: d27500b09

Rebooting... ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x28 (SPI_FAST_FLASH_BOOT) Saved PC:0x40375a50 0x40375a50: esp_restart_noos at /Users/11/esp/v5.3/esp-idf/components/esp_system/port/soc/esp32s3/system_internal.c:158

SPIWP:0xee mode:DIO, clock div:1 load:0x3fce2810,len:0x178c load:0x403c8700,len:0x4 load:0x403c8704,len:0xcb8 load:0x403cb700,len:0x2db0 entry 0x403c8914 I (26) boot: ESP-IDF v5.3-dirty 2nd stage bootloader I (26) boot: compile time Jul 27 2024 17:30:30 I (26) boot: Multicore bootloader I (30) boot: chip revision: v0.2 I (33) boot.esp32s3: Boot SPI Speed : 80MHz I (38) boot.esp32s3: SPI Mode : DIO I (43) boot.esp32s3: SPI Flash Size : 16MB I (48) boot: Enabling RNG early entropy source... I (53) boot: Partition Table: I (57) boot: ## Label Usage Type ST Offset Length I (64) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (71) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (79) boot: 2 factory factory app 00 00 00010000 00100000 I (86) boot: End of partition table I (91) esp_image: segment 0: paddr=00010020 vaddr=3c040020 size=13e90h ( 81552) map I (114) esp_image: segment 1: paddr=00023eb8 vaddr=3fc94e00 size=02b58h ( 11096) load I (116) esp_image: segment 2: paddr=00026a18 vaddr=40374000 size=09600h ( 38400) load I (128) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=36724h (223012) map I (168) esp_image: segment 4: paddr=0006674c vaddr=4037d600 size=07714h ( 30484) load I (182) boot: Loaded app from partition at offset 0x10000 I (183) boot: Disabling RNG early entropy source... I (194) cpu_start: Multicore app I (203) cpu_start: Pro cpu start user code I (204) cpu_start: cpu freq: 160000000 Hz I (204) app_init: Application information: I (206) app_init: Project name: w5-s3 I (211) app_init: App version: 1 I (215) app_init: Compile time: Jul 27 2024 17:30:25 I (221) app_init: ELF file SHA256: d27500b09... I (227) app_init: ESP-IDF: v5.3-dirty I (232) efuse_init: Min chip rev: v0.0 I (237) efuse_init: Max chip rev: v0.99 I (242) efuse_init: Chip rev: v0.2 I (246) heap_init: Initializing. RAM available for dynamic allocation: I (254) heap_init: At 3FC98C18 len 00050AF8 (322 KiB): RAM I (260) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM I (266) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (272) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM I (279) spi_flash: detected chip: generic I (283) spi_flash: flash io: dio I (287) sleep: Configure to isolate all GPIO pins in sleep state I (294) sleep: Enable automatic switching of GPIO sleep configuration I (301) main_task: Started on CPU0 I (311) main_task: Calling app_main() I (311) eth_example: GPIO ISR service installed I (311) eth_example: esp-netif initialized I (321) eth_example: Event loop created I (321) eth_example: SPI bus initialized E (431) w5500.mac: W5500 version mismatched, expected 0x04, got 0x00 E (431) w5500.mac: emac_w5500_init(826): verify chip ID failed I (431) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 E (441) esp_eth: esp_eth_driver_install(228): init mac failed ESP_ERROR_CHECK failed: esp_err_t 0x10a (ESP_ERR_INVALID_VERSION) at 0x4200a752

file: "./main/main.c" line 205 func: app_main expression: esp_eth_driver_install(&config, &handle)

abort() was called at PC 0x4037b4ef on core 0 0x4037b4ef: _esp_error_check_failed at /Users/11/esp/v5.3/esp-idf/components/esp_system/esp_err.c:49

Backtrace: 0x40375b16:0x3fc9c670 0x4037b4f9:0x3fc9c690 0x40382c1d:0x3fc9c6b0 0x4037b4ef:0x3fc9c720 0x4200a752:0x3fc9c750 0x42035973:0x3fc9c880 0x4037bf8d:0x3fc9c8b0

ELF file SHA256: d27500b09

Rebooting... ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x28 (SPI_FAST_FLASH_BOOT) Saved PC:0x40375a50 0x40375a50: esp_restart_noos at /Users/11/esp/v5.3/esp-idf/components/esp_system/port/soc/esp32s3/system_internal.c:158

SPIWP:0xee mode:DIO, clock div:1 load:0x3fce2810,len:0x178c load:0x403c8700,len:0x4 load:0x403c8704,len:0xcb8 load:0x403cb700,len:0x2db0 entry 0x403c8914 I (26) boot: ESP-IDF v5.3-dirty 2nd stage bootloader I (26) boot: compile time Jul 27 2024 17:30:30 I (27) boot: Multicore bootloader I (30) boot: chip revision: v0.2 I (33) boot.esp32s3: Boot SPI Speed : 80MHz I (38) boot.esp32s3: SPI Mode : DIO I (43) boot.esp32s3: SPI Flash Size : 16MB I (48) boot: Enabling RNG early entropy source... I (53) boot: Partition Table: I (57) boot: ## Label Usage Type ST Offset Length I (64) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (72) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (79) boot: 2 factory factory app 00 00 00010000 00100000 I (86) boot: End of partition table I (91) esp_image: segment 0: paddr=00010020 vaddr=3c040020 size=13e90h ( 81552) map I (114) esp_image: segment 1: paddr=00023eb8 vaddr=3fc94e00 size=02b58h ( 11096) load I (116) esp_image: segment 2: paddr=00026a18 vaddr=40374000 size=09600h ( 38400) load I (128) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=36724h (223012) map I (168) esp_image: segment 4: paddr=0006674c vaddr=4037d600 size=07714h ( 30484) load I (182) boot: Loaded app from partition at offset 0x10000 I (183) boot: Disabling RNG early entropy source... I (194) cpu_start: Multicore app I (203) cpu_start: Pro cpu start user code I (204) cpu_start: cpu freq: 160000000 Hz I (204) app_init: Application information: I (206) app_init: Project name: w5-s3 I (211) app_init: App version: 1 I (215) app_init: Compile time: Jul 27 2024 17:30:25 I (221) app_init: ELF file SHA256: d27500b09... I (227) app_init: ESP-IDF: v5.3-dirty I (232) efuse_init: Min chip rev: v0.0 I (237) efuse_init: Max chip rev: v0.99 I (242) efuse_init: Chip rev: v0.2 I (246) heap_init: Initializing. RAM available for dynamic allocation: I (254) heap_init: At 3FC98C18 len 00050AF8 (322 KiB): RAM I (260) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM I (266) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (272) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM I (279) spi_flash: detected chip: generic I (283) spi_flash: flash io: dio I (287) sleep: Configure to isolate all GPIO pins in sleep state I (294) sleep: Enable automatic switching of GPIO sleep configuration I (301) main_task: Started on CPU0 I (311) main_task: Calling app_main() I (311) eth_example: GPIO ISR service installed I (311) eth_example: esp-netif initialized I (321) eth_example: Event loop created I (321) eth_example: SPI bus initialized I (381) eth_example: Ethernet driver installed I (381) esp_eth.netif.netif_glue: 00:00:00:00:00:00 I (381) esp_eth.netif.netif_glue: ethernet attached to netif I (381) eth_example: esp-netif instance created I (391) eth_example: Ethernet driver started I (391) eth_example: Ethernet Started I (401) main_task: Returned from app_main() E (12391) w5500.mac: emac_w5500_transmit(578): free size (0) < send length (42) I (12391) eth_example: Ethernet Link Up I (12391) eth_example: Ethernet HW Addr 00:00:00:00:00:00 I (12401) esp_netif_handlers: eth ip: 192.168.4.101, mask: 255.255.255.0, gw: 192.168.4.1 I (12401) eth_example: Ethernet Got IP Address I (12411) eth_example: ~~~ I (12411) eth_example: ETHIP:192.168.4.101 I (12421) eth_example: ETHMASK:255.255.255.0 I (12421) eth_example: ETHGW:192.168.4.1 I (12431) eth_example: ~~~ I (14391) eth_example: Ethernet Link Down

Below is the code I am currently using:

#define CS_PIN    14
#define MISO_PIN  12
#define MOSI_PIN  11
#define SCK_PIN   13
#define RESET_PIN 9
#define INTR_PIN  10

#define DEFAULT_MAC_ADDR {0x02, 0x00, 0x00, 0x12, 0x34, 0x56}
static esp_eth_handle_t handle = NULL;
static esp_netif_t *eth_netif = NULL;

static const char *TAG = "eth_example";

static void IRAM_ATTR intr_handler(void* arg) {
    BaseType_t higher_priority_task_woken = pdFALSE;
    vTaskNotifyGiveFromISR((TaskHandle_t)arg, &higher_priority_task_woken);
    if (higher_priority_task_woken == pdTRUE) {
        portYIELD_FROM_ISR();
    }
}

static void reset_w5500(void) {
    gpio_set_level(RESET_PIN, 0);
    vTaskDelay(pdMS_TO_TICKS(100));
    gpio_set_level(RESET_PIN, 1);
    vTaskDelay(pdMS_TO_TICKS(100));
    ESP_LOGI(TAG, "W5500 reset done");
}

esp_err_t example_eth_init(esp_eth_handle_t **eth_handle) {
    ESP_ERROR_CHECK(gpio_install_isr_service(0));
    ESP_LOGI(TAG, "GPIO ISR service installed");

    gpio_config_t io_conf = {
        .pin_bit_mask = (1ULL << RESET_PIN),
        .mode = GPIO_MODE_OUTPUT,
        .pull_up_en = GPIO_PULLUP_DISABLE,
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .intr_type = GPIO_INTR_DISABLE
    };
    gpio_config(&io_conf);
    reset_w5500();

    io_conf.pin_bit_mask = (1ULL << INTR_PIN);
    io_conf.mode = GPIO_MODE_INPUT;
    io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
    io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
    io_conf.intr_type = GPIO_INTR_NEGEDGE;
    gpio_config(&io_conf);
    ESP_ERROR_CHECK(gpio_isr_handler_add(INTR_PIN, intr_handler, xTaskGetCurrentTaskHandle()));
    ESP_LOGI(TAG, "Interrupt GPIO configured");

    spi_bus_config_t buscfg = {
        .miso_io_num = MISO_PIN,
        .mosi_io_num = MOSI_PIN,
        .sclk_io_num = SCK_PIN,
        .quadwp_io_num = -1,
        .quadhd_io_num = -1,
        .max_transfer_sz = 4096,
    };
    ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO));
    ESP_LOGI(TAG, "SPI bus initialized");

    spi_device_interface_config_t devcfg = {
        .command_bits = 16,
        .address_bits = 8,
        .clock_speed_hz = 36 * 1000 * 1000,
        .mode = 0,
        .spics_io_num = CS_PIN,
        .queue_size = 20,
    };

    eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(SPI3_HOST, &devcfg);
    eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
    eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
    phy_config.phy_addr = 1;
    phy_config.reset_gpio_num = RESET_PIN;

    esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
    if (!mac) {
        ESP_LOGE(TAG, "Failed to create W5500 MAC");
        return ESP_FAIL;
    }

    esp_eth_phy_t *phy = esp_eth_phy_new_w5500(&phy_config);
    if (!phy) {
        ESP_LOGE(TAG, "Failed to create W5500 PHY");
        return ESP_FAIL;
    }

    esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
    ESP_ERROR_CHECK(esp_eth_driver_install(&config, &handle));
    ESP_LOGI(TAG, "Ethernet driver installed");

    uint8_t custom_mac[6] = DEFAULT_MAC_ADDR;
    ESP_ERROR_CHECK(esp_eth_ioctl(handle, ETH_CMD_S_MAC_ADDR, custom_mac));

    *eth_handle = handle;
    return ESP_OK;
}

static void eth_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
    uint8_t mac_addr[6] = {0};
    esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;

    switch (event_id) {
        case ETHERNET_EVENT_CONNECTED:
            esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr);
            ESP_LOGI(TAG, "Ethernet Link Up");
            ESP_LOGI(TAG, "Ethernet HW Addr %02x:%02x:%02x:%02x:%02x:%02x",
                     mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
            break;
        case ETHERNET_EVENT_DISCONNECTED:
            ESP_LOGI(TAG, "Ethernet Link Down");
            break;
        case ETHERNET_EVENT_START:
            ESP_LOGI(TAG, "Ethernet Started");
            break;
        case ETHERNET_EVENT_STOP:
            ESP_LOGI(TAG, "Ethernet Stopped");
            break;
        default:
            break;
    }
}

static void got_ip_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) {
    ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
    const esp_netif_ip_info_t *ip_info = &event->ip_info;

    ESP_LOGI(TAG, "Ethernet Got IP Address");
    ESP_LOGI(TAG, "~~~~~~~~~~~");
    ESP_LOGI(TAG, "ETHIP:" IPSTR, IP2STR(&ip_info->ip));
    ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
    ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw));
    ESP_LOGI(TAG, "~~~~~~~~~~~");
}

void app_main(void) {
    ESP_ERROR_CHECK(gpio_install_isr_service(0));
    ESP_LOGI(TAG, "GPIO ISR service installed");

    ESP_ERROR_CHECK(esp_netif_init());
    ESP_LOGI(TAG, "esp-netif initialized");

    ESP_ERROR_CHECK(esp_event_loop_create_default());
    ESP_LOGI(TAG, "Event loop created");

    spi_bus_config_t buscfg = {
        .miso_io_num = MISO_PIN,
        .mosi_io_num = MOSI_PIN,
        .sclk_io_num = SCK_PIN,
        .quadwp_io_num = -1,
        .quadhd_io_num = -1,
        .max_transfer_sz = 4096,
    };
    ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO));
    ESP_LOGI(TAG, "SPI bus initialized");

    spi_device_interface_config_t devcfg = {
        .command_bits = 16,
        .address_bits = 8,
        .clock_speed_hz = 2 * 1000 * 1000,
        .mode = 0,
        .spics_io_num = CS_PIN,
        .queue_size = 20,
    };

    eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
    eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
    eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(SPI3_HOST, &devcfg);

    phy_config.phy_addr = 1;  // PHY Address
    phy_config.reset_gpio_num = RESET_PIN;

    esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
    if (!mac) {
        ESP_LOGE(TAG, "Failed to create W5500 MAC");
        return;
    }

    esp_eth_phy_t *phy = esp_eth_phy_new_w5500(&phy_config);
    if (!phy) {
        ESP_LOGE(TAG, "Failed to create W5500 PHY");
        return;
    }

    esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
    ESP_ERROR_CHECK(esp_eth_driver_install(&config, &handle));
    ESP_LOGI(TAG, "Ethernet driver installed");

    // Create instance of esp-netif for Ethernet
    esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_ETH();
    esp_netif_config_t cfg = {
        .base = &esp_netif_config,
        .stack = ESP_NETIF_NETSTACK_DEFAULT_ETH
    };
    eth_netif = esp_netif_new(&cfg);
    ESP_ERROR_CHECK(esp_netif_attach(eth_netif, esp_eth_new_netif_glue(handle)));
    ESP_LOGI(TAG, "esp-netif instance created");
    esp_netif_ip_info_t ip_info;
    IP4_ADDR(&ip_info.ip, 192, 168, 4, 101);
    IP4_ADDR(&ip_info.gw, 192, 168, 4, 1);
    IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0);

    ESP_ERROR_CHECK(esp_netif_dhcpc_stop(eth_netif));
    ESP_ERROR_CHECK(esp_netif_set_ip_info(eth_netif, &ip_info));

    ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, &eth_event_handler, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL));

    ESP_ERROR_CHECK(esp_eth_start(handle));
    ESP_LOGI(TAG, "Ethernet driver started");
}
Chillimeat commented 4 months ago

The device’s logs indicate that the Ethernet link repeatedly goes up and down, as shown below: E (1776391) w5500.mac: emac_w5500_transmit(578): free size (0) < send length (42) I (1776391) eth_example: Ethernet Link Up I (1776391) eth_example: Ethernet HW Addr 00:00:00:00:00:00 I (1776401) esp_netif_handlers: eth ip: 192.168.4.101, mask: 255.255.255.0, gw: 192.168.4.1 I (1776411) eth_example: Ethernet Got IP Address I (1776411) eth_example: ~~~ I (1776411) eth_example: ETHIP:192.168.4.101 I (1776421) eth_example: ETHMASK:255.255.255.0 I (1776421) eth_example: ETHGW:192.168.4.1 I (1776431) eth_example: ~~~ I (1778391) eth_example: Ethernet Link Down E (1808391) w5500.mac: emac_w5500_transmit(578): free size (0) < send length (42) I (1808391) eth_example: Ethernet Link Up I (1808391) eth_example: Ethernet HW Addr 00:00:00:00:00:00 I (1808401) esp_netif_handlers: eth ip: 192.168.4.101, mask: 255.255.255.0, gw: 192.168.4.1 I (1808411) eth_example: Ethernet Got IP Address I (1808411) eth_example: ~~~ I (1808411) eth_example: ETHIP:192.168.4.101 I (1808421) eth_example: ETHMASK:255.255.255.0 I (1808421) eth_example: ETHGW:192.168.4.1 I (1808431) eth_example: ~~~ I (1810391) eth_example: Ethernet Link Down

DarmorGamz commented 3 months ago

Please try esp_base_mac_addr_set() and esp_netif_set_mac() instead of esp_eth_ioctl.

I experienced this on v5.0 and the symptom was "Ethernet HW Addr 00:00:00:00:00:00"

I also experienced "w5500.mac: emac_w5500_transmit(n): free size (0) < send length (k)" when my pins were incorrectly connected. You'll need to verify tx & rx are correctly connected and your clock speed.

Change your clock speed to ".clock_speed_hz = SPI_MASTER_FREQ_8M;"

Add ".flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_SCLK | SPICOMMON_BUSFLAG_MISO | SPICOMMON_BUSFLAG_MOSI" to the spi_bus_config_t. Change transfer speed to ".max_transfer_sz = 0".

Remove the line "phy_config.phy_addr = 1;"

Chillimeat commented 3 months ago

@DarmorGamz Thank you for the help provided, but I found that I have been stuck in a loop of obtaining versions.

I (321) eth_example: GPIO ISR service installed
I (331) gpio: GPIO[43]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (541) eth_example: W5500 reset done
I (541) gpio: GPIO[41]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2 
I (541) eth_example: Interrupt GPIO configured
I (541) eth_example: SPI bus initialized
E (651) w5500.mac: W5500 version mismatched, expected 0x04, got 0x00
E (651) w5500.mac: emac_w5500_init(826): verify chip ID failed
I (651) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 
E (661) esp_eth: esp_eth_driver_install(228): init mac failed
ESP_ERROR_CHECK failed: esp_err_t 0x10a (ESP_ERR_INVALID_VERSION) at 0x4200a7e5
file: "./main/main.c" line 110
func: example_eth_init
expression: esp_eth_driver_install(&config, &handle)

abort() was called at PC 0x4037b50b on core 0

Backtrace: 0x40375b16:0x3fc9c600 0x4037b515:0x3fc9c620 0x40382c39:0x3fc9c640 0x4037b50b:0x3fc9c6b0 0x4200a7e5:0x3fc9c6e0 0x4200a923:0x3fc9c810 0x42035b2f:0x3fc9c880 0x4037bfa9:0x3fc9c8b0

ELF file SHA256: 15b08351e

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xb (SPI_FAST_FLASH_BOOT)
Saved PC:0x40375a50
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2810,len:0x178c
kostaond commented 3 months ago

Please try esp_base_mac_addr_set() and esp_netif_set_mac() instead of esp_eth_ioctl.

@DarmorGamz Could you please elaborate what is the issue? This exact scenario is tested in CI for all supported Ethernet SPI modules.

kostaond commented 3 months ago

@Chillimeat how is your W5500 connected to ESP32? Do you have custom board or is it connected just via jumper wires? What W5500 board do you use?

Chillimeat commented 3 months ago

@kostaond Thank you very much for your attention. I am using DuPont wires for connection, and I have attached the relevant pictures. image

Chillimeat commented 3 months ago

Please try esp_base_mac_addr_set() and esp_netif_set_mac() instead of esp_eth_ioctl.

@DarmorGamz Could you please elaborate what is the issue? This exact scenario is tested in CI for all supported Ethernet SPI modules.

I also used a separate 5V power supply for power.

kostaond commented 3 months ago

It seems you have some issues with SPI communication. Double check (or triple check :)) SPI configuration, that the connection is correct and use wires as short as possible (max 10cm) with matching length. You can also try to lower the SPI frequency to 8 MHz.

kostaond commented 2 months ago

@Chillimeat any update? Have you been able to resolve the issue?