ESP32-S3 SPI CS

daniSi
Posts: 47
Joined: Thu Dec 23, 2021 9:43 am

ESP32-S3 SPI CS

Postby daniSi » Wed May 04, 2022 8:22 am

Dear,

we have until now successfully used the esp spi flash library on the ESP32S3-WROOM. However, now we have made a hardware change which affected only the CS pin which has moved from GPIO10 to GPIO8, and suddenly the flash stopped working. The pin is constantly 0.

We have tested the board and there is now shortcut or something else. Also when we initialize the pin as a normal output and toggle it, everything works as expected.

Code: Select all

const spi_bus_config_t bus_spi_config = {
			.mosi_io_num = CONFIG_SPI_PIN_MOSI, // GPIO11
			.miso_io_num = CONFIG_SPI_PIN_MISO, // GPIO13
			.sclk_io_num = CONFIG_SPI_PIN_CLK, // GPIO12
			.quadhd_io_num = -1,
			.quadwp_io_num = -1,
		};

const esp_flash_spi_device_config_t device_config = {
		.host_id = PICO_SPI_HOST,
		.cs_id = 0, // we are not shure if this has to stay 0? tried also with 1 but no change
		.cs_io_num = CONFIG_SPI_PIN_CS_FLASH, // before GPIO10, now GPIO8
		.io_mode = SPI_FLASH_DIO,
		.speed = ESP_FLASH_40MHZ,
	};
Is there maybe some pin limitation which pins can/cant be used? Thank you

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 SPI CS

Postby ESP_Sprite » Wed May 04, 2022 11:56 am

That is odd. Do you see any errors or warnings on the ESP serial port when booting / initing the flash?

daniSi
Posts: 47
Joined: Thu Dec 23, 2021 9:43 am

Re: ESP32-S3 SPI CS

Postby daniSi » Wed May 04, 2022 12:49 pm

No there is everything normal on the output, until it comes to the flash initialization, where the output is:

Code: Select all

E (976) HW_INIT: Failed to initialize external Flash: ESP_ERR_FLASH_NOT_INITIALISED (0x6003)
for curiosity we have now try to connect also to some other GPIOs, such as: 9, 39 but it neither works. But, when we brick it back to GPIO10 as it was before it works out of the box. Also we have disabled all other peripherals, if there would be some pinoverlaping.

So the CS pin doesnt have to be specific if using the flash library? Because what has irritated us was the function use for the GPIO10 which is: RTC_GPIO10, GPIO10, TOUCH10, ADC1_CH9, FSPICS0, FSPIIO4, SUBSPICS0

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 SPI CS

Postby ESP_Sprite » Thu May 05, 2022 1:35 am

As far as I'm aware, the external flash library uses the SPI master driver as the underlying layer, and that is supposed to be able to allocate the pins through the GPIO matrix. I'll see if I can investigate, perhaps there's some bug in the S3 implementation.

daniSi
Posts: 47
Joined: Thu Dec 23, 2021 9:43 am

Re: ESP32-S3 SPI CS

Postby daniSi » Thu May 05, 2022 6:07 am

Ok, thank you for checking on this. If it helps, we are using the esp-idf v4.4.

ESP_Sprite
Posts: 9770
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32-S3 SPI CS

Postby ESP_Sprite » Fri May 06, 2022 5:02 am

It looks like a bug in the SPI flash driver. As you are using the IOMUX pins for the bus, the driver logic erroneously assumes the CS will be an IOMUX pin as well, meaning only GPIO10 will work. A dirty hack to get around this is to open esp-idf/components/spi_flash/esp_flash_spi_init.c and locate the line

Code: Select all

bool use_iomux = spicommon_bus_using_iomux(config->host_id);
and put 'use_iomux=false;' under it. I'll ask my colleagues to find and integrate a better solution for this.

daniSi
Posts: 47
Joined: Thu Dec 23, 2021 9:43 am

Re: ESP32-S3 SPI CS

Postby daniSi » Wed May 11, 2022 12:22 pm

Thank you, this has now solved the problem!

regards, Danijel

Who is online

Users browsing this forum: No registered users and 101 guests