ext flash fatfs example uses internal flash

InterBilly
Posts: 13
Joined: Mon Jul 31, 2023 4:53 pm

ext flash fatfs example uses internal flash

Postby InterBilly » 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):

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
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.

MicroController
Posts: 1760
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ext flash fatfs example uses internal flash

Postby MicroController » Mon May 06, 2024 6:51 pm

it is the wrong chip, it's connected to the internal flash chip
From the log output you posted, this is clearly not what's happening.

The only issue is that the chip is detected as 4MB while you seem to be using an 8MB part.

Who is online

Users browsing this forum: No registered users and 71 guests