W5500 Resets Chip without error if anything in the SPI connection is faulty.
Posted: Fri Nov 08, 2024 11:29 am
CHIP: ESP32S3
ESP-IDF
Hi, I know this probably would have been better off in the issue page, but at this point im not aware if maybe there is a good reason for it.
When initializing the W5500 it works fine, as long as the SPI communication is stable. The moment the SPI communication does not work, (Bus not initialized, Wrong impedance etc.) the code crashes, and the chip restarts.
This is not ideal. I would prefer a normal error, so that if the module fails, we can just take the error and react.
Right now i would have to set a flag before trying the initialization and check wether this has failed in the last run.
This is maybe possible, but i would prefer a normal error so i can react to that error and do not have to suffer a restart to see if it is working.
The error happens here:
precisely here:
Here the esp_eth_driver_install(ð_config_spi, &w5500_eth_handle) is called. This function never returns if SPI is not available or the comm line is cut.
This is the output in the Terminal:
As you can see, it informs us, that the Watchdogtimer on both CPUs has been triggered.
Is this known?
Can you update your software to not trigger the Watchdog and return an error, for a broken SPI Interface?
I hope this Format is fine.
Thanks in advance for taking the time to deal with my problem.
Greetings
ESP-IDF
Hi, I know this probably would have been better off in the issue page, but at this point im not aware if maybe there is a good reason for it.
When initializing the W5500 it works fine, as long as the SPI communication is stable. The moment the SPI communication does not work, (Bus not initialized, Wrong impedance etc.) the code crashes, and the chip restarts.
This is not ideal. I would prefer a normal error, so that if the module fails, we can just take the error and react.
Right now i would have to set a flag before trying the initialization and check wether this has failed in the last run.
This is maybe possible, but i would prefer a normal error so i can react to that error and do not have to suffer a restart to see if it is working.
The error happens here:
- /**
- * @brief Ethernet SPI modules initialization
- * @pre
- * @param[in] eth_driver_config specific SPI Ethernet module configuration
- * @param[out] mac_out optionally returns Ethernet MAC object
- * @param[out] phy_out optionally returns Ethernet PHY object
- * @return
- * || esp_eth_handle_t if init succeeded
- * || NULL if init failed
- */
- static esp_eth_handle_t eth_cnct_install_w5500_driver(eth_cnct_driver_config_t *eth_driver_config, esp_eth_mac_t **mac_out, esp_eth_phy_t **phy_out)
- {
- esp_eth_handle_t ret = NULL;
- // Init common MAC and PHY configs to default
- eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
- eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
- // Update PHY config based on board specific configuration
- phy_config.phy_addr = eth_driver_config->phy_addr;
- phy_config.reset_gpio_num = eth_driver_config->phy_reset_gpio;
- // Configure SPI interface for specific SPI module
- spi_device_interface_config_t spi_devcfg
- = { .mode = 0, .clock_speed_hz = ETH_CNCT_SPI_CLOCK_MHZ * 1000 * 1000, .queue_size = 20, .spics_io_num = eth_driver_config->spi_cs_gpio };
- // Init vendor specific MAC config to default, and create new SPI Ethernet MAC
- // instance and new PHY instance based on board configuration
- eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(ETH_CNCT_SPI_HOST, &spi_devcfg);
- w5500_config.int_gpio_num = eth_driver_config->int_gpio;
- esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
- esp_eth_phy_t *phy = esp_eth_phy_new_w5500(&phy_config);
- // Init Ethernet driver to default and install it
- esp_eth_handle_t w5500_eth_handle = NULL;
- esp_eth_config_t eth_config_spi = ETH_DEFAULT_CONFIG(mac, phy);
- #if 1 // debug
- ESP_LOGI("DEBUG", "We reach this point (before esp_eth_driver_install)");
- vTaskDelay(100 / portTICK_PERIOD_MS); // Delay to make sure the UART Queue has time to be emptied into the Serial Monitor
- #endif
- ESP_GOTO_ON_FALSE(ESP_OK == esp_eth_driver_install(ð_config_spi, &w5500_eth_handle), NULL, err, TAG, "SPI Ethernet driver install failed");
- #if 1 // debug
- ESP_LOGI("DEBUG", "We never reach this point (After esp_eth_driver_install)");
- #endif
- // The SPI Ethernet module does not have a burned factory MAC address, we can
- // set it manually.
- if (eth_driver_config->mac_addr != NULL)
- {
- ESP_GOTO_ON_FALSE(ESP_OK == esp_eth_ioctl(w5500_eth_handle, ETH_CMD_S_MAC_ADDR, eth_driver_config->mac_addr),
- NULL,
- err,
- TAG,
- "SPI Ethernet MAC address config failed");
- }
- if (mac_out != NULL) { *mac_out = mac; }
- if (phy_out != NULL) { *phy_out = phy; }
- return w5500_eth_handle;
- err:
- if (w5500_eth_handle != NULL) { esp_eth_driver_uninstall(w5500_eth_handle); }
- if (mac != NULL) { mac->del(mac); }
- if (phy != NULL) { phy->del(phy); }
- return ret;
- #if 1 // debug
- ESP_LOGI("DEBUG", "We reach this point (before esp_eth_driver_install)");
- vTaskDelay(100 / portTICK_PERIOD_MS); // Delay to make sure the UART Queue has time to be emptied into the Serial Monitor
- #endif
- ESP_GOTO_ON_FALSE(ESP_OK == esp_eth_driver_install(ð_config_spi, &w5500_eth_handle), NULL, err, TAG, "SPI Ethernet driver install failed");
- #if 1 // debug
- ESP_LOGI("DEBUG", "We never reach this point (After esp_eth_driver_install)");
- #endif
This is the output in the Terminal:
- Executing action: monitor
- Serial port /dev/ttyUSB0
- Connecting...
- [...]
- --- esp-idf-monitor 1.5.0 on /dev/ttyUSB0 115200
- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
- ESP-ROM:esp32s3-20210327
- Build:Mar 27 2021
- I (33) boot: ESP-IDF v5.3.1 2nd stage bootloader
- I (33) boot: compile time Nov 7 2024 15:29:31
- I (33) boot: Multicore bootloader
- I (36) boot: chip revision: v0.1
- I (40) boot.esp32s3: Boot SPI Speed : 80MHz
- I (45) boot.esp32s3: SPI Mode : SLOW READ
- I (50) boot.esp32s3: SPI Flash Size : 8MB
- [...]
- I (525) main_task: Started on CPU0
- I (535) main_task: Calling app_main()
- [...]
- I (695) MAIN: Starting network with following settings:
- Ethernet [1]
- Wifi [0]
- Access Point [1]
- Static IP [1]
- I (695) NetworkInterfaceControl: Initializing network with static IP
- I (705) NetworkInterfaceControl: ESP_WIFI_MODE_AP
- I (715) pp: pp rom version: e7ae62f
- I (715) net80211: net80211 rom version: e7ae62f
- I (735) wifi:wifi driver task: 3fcaf484, prio:23, stack:6656, core=0
- I (735) wifi:wifi firmware version: ccaebfa
- I (735) wifi:wifi certification version: v7.0
- I (735) wifi:config NVS flash: enabled
- I (735) wifi:config nano formating: disabled
- I (745) wifi:Init data frame dynamic rx buffer num: 32
- I (745) wifi:Init static rx mgmt buffer num: 5
- I (755) wifi:Init management short buffer num: 32
- I (755) wifi:Init dynamic tx buffer num: 32
- I (765) wifi:Init static tx FG buffer num: 2
- I (765) wifi:Init static rx buffer size: 1600
- I (765) wifi:Init static rx buffer num: 10
- I (775) wifi:Init dynamic rx buffer num: 32
- I (775) wifi_init: rx ba win: 6
- I (775) wifi_init: accept mbox: 6
- I (785) wifi_init: tcpip mbox: 32
- I (785) wifi_init: udp mbox: 6
- I (795) wifi_init: tcp mbox: 6
- I (795) wifi_init: tcp tx win: 5744
- I (795) wifi_init: tcp rx win: 5744
- I (805) wifi_init: tcp mss: 1440
- I (805) wifi_init: WiFi IRAM OP enabled
- I (815) wifi_init: WiFi RX IRAM OP enabled
- I (815) phy_init: phy_version 680,a6008b2,Jun 4 2024,16:41:10
- I (855) wifi:mode : softAP (34:85:18:a1:bb:b9)
- I (855) wifi:Total power save buffer number: 16
- I (855) wifi:Init max length of beacon: 752/752
- I (855) wifi:Init max length of beacon: 752/752
- I (865) wifi softAP: ap_cnct_initialize finished. SSID:ESP32 password: channel:0
- I (865) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.4.1
- I (885) NetworkInterfaceControl: Connecting to Ethernet. Opening eth_cnct_initialize
- I (885) Ethernet Connect Module: esp_event_loop_create_default already initialized, skipping initization
- eth_netif: 0x3fcb65ec
- I (905) Ethernet Connect Module: Success to set static ip: 5100a8c0, netmask: 00ffffff, gateway: 0100a8c0
- I (915) Ethernet Connect Module: DNS Server: 0100a8c0
- eth_netif: somethings not working and it is here eth_cnct_init_w5500
- I (1915) DEBUG: We reach this point (before eth_cnct_install_w5500_driver)
- I (2015) DEBUG: We reach this point (before esp_eth_driver_install)
- ESP-ROM:esp32s3-20210327
- Build:Mar 27 2021
- rst:0x8 (TG1WDT_SYS_RST),boot:0xa (SPI_FAST_FLASH_BOOT)
- Saved PC:0x4037935a
- --- 0x4037935a: _xt_panic at /root/esp/esp-idf/components/esp_system/port/arch/xtensa/panic_handler_asm.S:32
- SPIWP:0xee
- Octal Flash Mode Enabled
- For OPI Flash, Use Default Flash Boot Mode
- mode:SLOW_RD, clock div:1
- load:0x3fce2810,len:0x178c
- load:0x403c8700,len:0x4
- load:0x403c8704,len:0xcb8
- load:0x403cb700,len:0x2dcc
- entry 0x403c8914
- I (37) boot: ESP-IDF v5.3.1 2nd stage bootloader
- I (38) boot: compile time Nov 7 2024 15:29:31
- I (38) boot: Multicore bootloader
- I (41) boot: chip revision: v0.1
- I (45) boot.esp32s3: Boot SPI Speed : 80MHz
- I (49) boot.esp32s3: SPI Mode : SLOW READ
- I (55) boot.esp32s3: SPI Flash Size : 8MB
- W (59) boot.esp32s3: PRO CPU has been reset by WDT.
- W (65) boot.esp32s3: APP CPU has been reset by WDT.
Is this known?
Can you update your software to not trigger the Watchdog and return an error, for a broken SPI Interface?
I hope this Format is fine.
Thanks in advance for taking the time to deal with my problem.
Greetings