Skip to content

ESP32 Flash size read via API is wrong when flash is in modes qio, dio, qout #7157

Closed
@Jason2866

Description

@Jason2866

Board

esp32 devkit 4 MB

Device Description

Plain Devkit board, nothing connected

Hardware Configuration

none

Version

v2.0.4

IDE Name

Platformio latest release

Operating System

macOS 12.5.1

Flash frequency

40 Mhz

PSRAM enabled

no

Upload speed

115200

Description

Get flash size correctly when in flash modes qio, qout, dio as it does when in flash mode dout.
The standard Arduino function get flash size is useless in most cases, since it just reads the values which are set from the IDE and it does not detect the real flash size

Sketch

Sketch to test https://github.com/Jason2866/ESP32_Show_Info
Can be run with Arduino IDE too.
The test sketch shows too that flash mode is not correct when queried via the API (qio and qout never shown)

Debug Message

First (correct) output in mode dout 

entry 0x400805c4
can't allocate memory with malloc

ESP32 SDK: v4.4.3
ESP32 CPU FREQ: 240 MHz
ESP32 APB FREQ: 80.0 MHz
ESP32 FLASH CHIP ID: 1458392
ESP32 FLASH REAL SIZE: 4.00 MB
ESP32 FLASH SIZE (MAGIC BYTE): 4.00 MB
ESP32 FLASH MODE: 3, 0=QIO, 1=QOUT, 2=DIO, 3=DOUT
ESP32 RAM SIZE: 366.19 KB
ESP32 FREE RAM: 342.56 KB
ESP32 MAX RAM ALLOC: 119.99 KB
ESP32 FREE PSRAM: 0.00 KB

Second (wrong) output in mode qio (shown wrong dio too)

entry 0x400805d0
can't allocate memory with malloc

ESP32 SDK: v4.4.3
ESP32 CPU FREQ: 240 MHz
ESP32 APB FREQ: 80.0 MHz
ESP32 FLASH CHIP ID: 729324
ESP32 FLASH REAL SIZE: 0.00 MB
ESP32 FLASH SIZE (MAGIC BYTE): 4.00 MB
ESP32 FLASH MODE: 2, 0=QIO, 1=QOUT, 2=DIO, 3=DOUT
ESP32 RAM SIZE: 366.19 KB
ESP32 FREE RAM: 342.56 KB
ESP32 MAX RAM ALLOC: 119.99 KB
ESP32 FREE PSRAM: 0.00 KB


### Other Steps to Reproduce

Running the example sketch

### I have checked existing issues, online documentation and the Troubleshooting Guide

- [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions