esp: flash search and configure

串口日志报警告:

1
spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.

原因:硬件flash为4MB,而编译固件的配置flash为2MB,导致报警告。

查询flash大小

通过esptool.py工具可以查询flash信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$ esptool.py flash_id
esptool.py v4.7.0
Found 33 serial ports
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 40:22:d8:fc:d1:fc
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

Detected flash size: 4MB,就是实际的flash大小。

设置flash大小

通过 idf.py menuconfig 菜单修改flash的大小。

操作过程:”Serial flasher config” –> “Flash size” –> “4M”,然后保存退出。

image-20241105114934762