ext flash fatfs example uses internal flash
Posted: Mon May 06, 2024 9:59 am
Hi!
I'm trying to use an external flash IC with my ESP32 to store some data that won't fit on the internal flash.
I used the ext_flash_fatfs_example from ESP-IDF, and changed it to use SPI2 (SPI3 IO overlaps with LAN8720 connections):
When I run the code it works but I noticed it is the wrong chip, it's connected to the internal flash chip as seen by the partitions and size (ESP32 = 4MB, W25Q64 = 8MB):
I thought SPI0/1 were for the internal flash and SPI2/3 were free to use. I've read the SPI pages on the Espressif website multiple times but I can't see what I'm doing wrong.
Any advice is greatly appreciated.
I'm trying to use an external flash IC with my ESP32 to store some data that won't fit on the internal flash.
I used the ext_flash_fatfs_example from ESP-IDF, and changed it to use SPI2 (SPI3 IO overlaps with LAN8720 connections):
Code: Select all
const spi_bus_config_t bus_config = {
.mosi_io_num = 13,
.miso_io_num = 12,
.sclk_io_num = 14,
.quadhd_io_num = -1,
.quadwp_io_num = -1,
};
const esp_flash_spi_device_config_t device_config = {
.host_id = SPI2_HOST,
.cs_id = 0,
.cs_io_num = PIN_CS,
.io_mode = SPI_FLASH_DIO,
.freq_mhz = EXAMPLE_FLASH_FREQ_MHZ,
};
When I run the code it works but I noticed it is the wrong chip, it's connected to the internal flash chip as seen by the partitions and size (ESP32 = 4MB, W25Q64 = 8MB):
Code: Select all
I (394) example: Initialized external Flash, size=4096 KB, ID=0x204016
I (394) example: Adding external Flash as a partition, label="storage", size=4096 KB
I (404) example: Erasing partition range, offset=0 size=4096 KB
I (8064) example: Listing data partitions:
I (8064) example: - partition 'nvs', subtype 2, offset 0x9000, size 24 kB
I (8064) example: - partition 'phy_init', subtype 1, offset 0xf000, size 4 kB
I (8074) example: - partition 'storage', subtype 129, offset 0x0, size 4096 kB
Any advice is greatly appreciated.