Can't get esp32 to use more than 4MB

I have made a custom dev board with a 16MB esp 32 on it

esptool.py --port /dev/cu.usbserial-0001  flash_id
esptool.py v3.3.2
Serial port /dev/cu.usbserial-0001
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....................
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e8:31:cd:2a:b1:e4
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4018
Detected flash size: 16MB
Hard resetting via RTS pin...

I am attempting to change my partitions to make use of this via bigger partition table.
However, it seems that every time I overflow the 4MB, I get an error. We upload fine, but then it just spins with this error. It crashes on outputting this.

rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
ets Jul 29 2019 12:21:46

I have a working custom partition file which I set via: board_build.partitions

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1E0000,
app1,     app,  ota_1,   0x1F0000,0x1E0000,
spiffs,   data, spiffs,  0x3D0000,0x30000,

But as soon as I try to add more partitions or make them bigger, I end up spinning. E.g.

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
factory,  app,  factory, 0x10000, 0x1E0000,
app0,     app,  ota_0,   0x1F0000,0x1E0000,
app1,     app,  ota_1,   0x3D0000,0x1E0000,
spiffs,   data, spiffs,  0x5B0000,0x30000,

Is there some other config that needs to be set to allow flashing above 4MB? Maybe a build flag or something? … did we buy a fake chip?

We are using Arduino, if that is relevant here.

platformio.ini is? Did you adapt board_upload.flash_size = 16MB?

I did not know about that option. I tried putting it in my platformio.ini, but same error still happening.

I suspect I need to create a custom board. I am still using the esp32dev, which I suspect is set to 4MB

https://docs.platformio.org/en/latest/platforms/espressif32.html

mmmm. No progress.

I created a custom board, but I still get errors above a 4MB partition table.

I think this is the relevant part of the board.json file. I was guessing a bit at the values. I also see now that the suggestion from @maxgerhardt was probably overriding/setting this flash_size value. So I guess we don’t need to create a custom board if we put all the configs in the platformio.ini

    "upload": {
        "flash_size": "16MB",
        "maximum_ram_size": 327680,
        "maximum_size": 16777216,
        "require_upload_port": true,
        "speed": 460800
    },

It’s definitely a nice thing to have a board file for your custom board, but you should also be able to equivalently take the “stock” esp32dev definition and then on-the-fly modify it with board_x.y = z modifications in the platformio.ini, like board_upload.flash_size = 16MB etc.

Can you please use this exact platformio.ini

[env:esp32dev]
platform = espressif32@5.3.0
framework = arduino
board = esp32dev
board_build.flash_size = 16MB
; built-in avaiable thanks to https://github.com/espressif/arduino-esp32/blob/master/tools/partitions/default_16MB.csv
board_build.partitions = default_16MB.csv
monitor_speed = 115200

with only this src/main.cpp source file

#include <Arduino.h>
void setup() { Serial.begin(115200); }
void setup() { Serial.println("Test"); delay(1000); }

I’ve gone ahead and tried setting this up. I have 3 targets. No partition specified, the default 4MB partition, and the 16MB partition. The first 2 targets work fine. The 16MB target is not working for me. I get the same error on a loop.


rst:0x3 (SW_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13104
load:0x40080400,len:3036
entry 0x400805e4
ets Jul 29 2019 12:21:46

Edit: for completeness, and curiosity, I added an 8MB target. Same results for me as the 16MB target.

Edit 2: I found another chip, also 16MB, which I bought from another retailer, and am getting the same results.
For posterity, flash_id on the 2nd chip I tried is also reporting 16MB

# esptool.py --port /dev/cu.usbserial-02Q1P7T7  flash_id                                                                                                                                                                                                                                                                                                                                     
esptool.py v3.3.2
Serial port /dev/cu.usbserial-02Q1P7T7
Connecting......
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting...
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision 3)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 94:e6:86:c0:43:2c
Uploading stub...
Running stub...
Stub running...
Manufacturer: 20
Device: 4018
Detected flash size: 16MB
Hard resetting via RTS pin...

Does it also fail with default_8MB.csv?

Yes. It also fails with 8MB. I created a hello world with esp-idf, and I am able to flash at 16MB just fine. Here’s that project.

… I’ve found the smoking gun.

Running the platformio project I shared in my previous message above on the 16MB mode:
platformio run -v --target upload --target monitor --environment esp32dev_default_16MB

will log the following:

"/opt/homebrew/Cellar/platformio/6.1.5_1/libexec/bin/python3.11" "/Users/xxx/.platformio/packages/tool-esptoolpy/esptool.py" --chip esp32 --port "/dev/cu.usbserial-0001" --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB 0x1000 /Users/xxx/workspace/flash_16MB/.pio/build/esp32dev_default_16MB/bootloader.bin 0x8000 /Users/xxx/workspace/flash_16MB/.pio/build/esp32dev_default_16MB/partitions.bin 0xe000 /Users/xxx/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x10000 .pio/build/esp32dev_default_16MB/firmware.bin

I can see in here: --flash_size 4MB

That’s weird, then maybe runtime modifications of flash_size does not work anymore. I’ll check it out.

Holdup.

that can’t work because the flash size is in the upload section, not in the build section. It needs to be

board_upload.flash_size = 16MB

I did write it correctly there. Can't get esp32 to use more than 4MB - #2 by maxgerhardt

1 Like

Boom! That fixed it. I had board_build the whole time.

Thank you!