Page 1 of 1
Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Thu Dec 05, 2024 12:53 am
by igormoo
On Esp32-S3 I'm trying to initialize a second SPI (the first one is used for a TFT display) to run Ethernet module W5500 (similar to
https://a.co/d/hL5TRAN)
The module is wired like this:
MOSI - gpio 35
MISO - gpio 37
CLK - gpio 36
SS/CS - gpio 38
when the `spi_bus_initialize` is executed - the module just crashes and reboots without any error. Any suggestions of what am I missing?
EspIDF v5.1.5
#include "esp_eth.h"
#include "esp_mac.h"
#include "esp_netif.h"
// Define GPIO pins for Ethernet SPI
#define ETHERNET_SPI_MOSI_GPIO 35 // Example GPIO for MOSI
#define ETHERNET_SPI_MISO_GPIO 37 // Example GPIO for MISO
#define ETHERNET_SPI_CLK_GPIO 36 // Example GPIO for SCK
#define ETHERNET_SPI_CS_GPIO 38 // Example GPIO for CS
void ethernet_init() {
ESP_LOGI(TAG, "ethernet_init");
esp_err_t ret;
// Initialize the SPI bus for SPI3
spi_bus_config_t buscfg = {
.mosi_io_num = ETHERNET_SPI_MOSI_GPIO,
.miso_io_num = ETHERNET_SPI_MISO_GPIO,
.sclk_io_num = ETHERNET_SPI_CLK_GPIO,
.quadwp_io_num = -1, // Not used
.quadhd_io_num = -1, // Not used
.max_transfer_sz = 4096,
};
ESP_LOGI(TAG, "spi_bus_initialize");
ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO)); // <--- here is the crash
...
}
I'd like to reach something similar to this thread
https://esp32.com/viewtopic.php?t=36708
Thank you for the ideas
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Thu Dec 05, 2024 8:46 am
by ESP_ondrej
It's quite unusual to restart without any log... Is there at least backtrace? What is the exact part number of module you use?
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Thu Dec 05, 2024 6:40 pm
by igormoo
Maybe the "panic" information is saying something? I don't know how to interpret this.
As you can see there is nothing specific after log output "spi_bus_initialize"
Here is how the code looks and this is what's in the trace with the highest level of VERBOSEty
#define ETHERNET_SPI_MOSI_GPIO 35 // Example GPIO for MOSI
#define ETHERNET_SPI_MISO_GPIO 37 // Example GPIO for MISO
#define ETHERNET_SPI_CLK_GPIO 36 // Example GPIO for SCK
#define ETHERNET_SPI_CS_GPIO 38 // Example GPIO for CS
void ethernet_init() {
ESP_LOGI(TAG, "ethernet_init");
esp_err_t ret;
// Initialize the SPI bus for SPI3
spi_bus_config_t buscfg = {
.mosi_io_num = ETHERNET_SPI_MOSI_GPIO,
.miso_io_num = ETHERNET_SPI_MISO_GPIO,
.sclk_io_num = ETHERNET_SPI_CLK_GPIO,
.quadwp_io_num = -1, // Not used
.quadhd_io_num = -1, // Not used
.max_transfer_sz = 4096,
};
ESP_LOGI(TAG, "spi_bus_initialize");
// ESP_ERROR_CHECK(spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO));
esp_err_t err = spi_bus_initialize(SPI3_HOST, &buscfg, SPI_DMA_CH_AUTO);
if (err != ESP_OK) {
ESP_LOGE("SPI", "Failed to initialize bus: %s", esp_err_to_name(err));
return;
}
ESP_LOGI(TAG, "spi_bus_initialize complete");
...
}
Code: Select all
I (1929) main: IDF version: v5.1.5-dirty
I (1934) main: ESP-IDF Version: 5.1.5
I (1938) Ethernet: ethernet_init
I (1942) Ethernet: spi_bus_initialize
D (1947) gdma: new group (0) at 0x3c070b80
D (1951) gdma: new pair (0,0) at 0x3c070bc4
D (1955) gdma: new tx channel (0,0) at 0x3c070b4c
D (1960) gdma: new rx channel (0,0) at 0x3c070be4
D (1965) spi: SPI3 use gpio matrix.
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0x2b (SPI_FAST_FLASH_BOOT)
Saved PC:0x40375b61
--- 0x40375b61: panicHandler at /Users/igor/esp/v5.1.5/esp-idf/components/esp_system/port/panic_handler.c:217
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:1
load:0x3fce3810,len:0x1a2c
load:0x403c9700,len:0x4
load:0x403c9704,len:0x1088
load:0x403cc700,len:0x2fc8
SHA-256 comparison failed:
Calculated: 199fc0fcb8b95d8ca3a70b2bf648cf011b7b8936d0c7f11a9f79f9553fa7fe37
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403c9994
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Thu Dec 05, 2024 8:38 pm
by FrankJensen
Does it compile and run without the SPI initializing? I think this looks strange, no matter if your code is good or bad:
Code: Select all
SHA-256 comparison failed:
Calculated: 199fc0fcb8b95d8ca3a70b2bf648cf011b7b8936d0c7f11a9f79f9553fa7fe37
Expected: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Attempting to boot anyway...
entry 0x403c9994
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Fri Dec 06, 2024 7:44 am
by ESP_ondrej
You didn't answer to my question, what is the exact part number of module you use, please? The reason I'm asking is:
" For modules with Octal SPI PSRAM, i.e., modules embedded with ESP32-S3R8 or ESP32-S3R16V,
pins IO35, IO36, and IO37 are connected to the Octal SPI PSRAM and are not available for other
uses."
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Tue Dec 10, 2024 3:33 pm
by igormoo
Thank you for pointing this out. My apologies, I thought you were referring to the ETH module, not to ESP32. I'm using "ESP32-S3-DevKitC-1-N32R8V Development Board".
Maybe I'm a bit biased because I've tested this hypothesis previously with a different pin layout and got the same error. Here is one of the setups I've tried:
#define ETHERNET_SPI_MOSI_GPIO 23 // Example GPIO for MOSI
#define ETHERNET_SPI_MISO_GPIO 19 // Example GPIO for MISO
#define ETHERNET_SPI_CLK_GPIO 18 // Example GPIO for SCK
#define ETHERNET_SPI_CS_GPIO 5 // Example GPIO for CS
What may be a suggested pin setup for a second SPI on this module? Does anyone have it working?
I've found an interesting thread that may be related to this topic:
https://github.com/espressif/arduino-esp32/pull/7163
Am I overthinking this?
thanks
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Thu Dec 12, 2024 7:42 am
by ESP_ondrej
Code: Select all
#define ETHERNET_SPI_MOSI_GPIO 23 // Example GPIO for MOSI
Such GPIO pin number is not available
https://docs.espressif.com/projects/esp ... ng-started
Re: Esp32-S3 crashes when a second SPI is initialized for Ethernet module W5500
Posted: Thu Dec 12, 2024 8:04 am
by ESP_ondrej
Also see
https://www.espressif.com/sites/default ... eet_en.pdf, Section "2.3 IO Pins" to consult usage restrictions which may apply to certain GPIO.