ESP32 boot loop when changing partition table using default_8M.csv

Thanks :-). There are no partitions greater than 3MB in the 8MB partition table quoted however?

I found some other threads which mentioned setting
board_upload.flash_size = 8MB
in platformio.ini, so I will try that when I have the relevant hardware available (currently only have 4MB with me).

1 Like

Hi,

Was any solution ever found here?

I am having exactly the same issue with setting the partition table size explicitly for any partition size including the default that’s already on it.

Thanks
Tim

I too am very interested in the solution to this problem. I have a custom board using the 16MB FLASH/ 8MB PSRAM variant of the ESP32 WROVER E module. I made a custom partitions file like this:

# Name,	    Type,	SubType,	Offset,	Size,	Flags
nvs,  	     data,	nvs,       0x9000,	 0x5000,	
otadata,     data,	ota,   	   0xe000,   0x2000,	
app0,	      app,	ota_0,	  0x10000, 0x600000,	
app1,	       app,	ota_1,	 0x610000, 0x600000,	
spiffs,	      data,	spiffs,	 0xc10000, 0x3e0000,
coredump,     data,	coredump,0xff0000,	0x10000

This worked and let me download some large builds for a long time. Then, the project started crashing and I built some debug code and uploaded it only to the get SW_RESET boot loop. After days of work, I found the sensitivity to the partition table and I now have a situation, like others on this thread, where a “Hello World” program gets in the SW_RESET boot loop if the OTA partitions are over 0x140000.

I can’t understand how this used to work and then stopped unless there was some change in PlatformIO recently that causes this for me.

What’s the content of the corresponding platformio.ini ?

You can specify the platform version to be used in platformio.ini to use an older version. If it worked with an earlier version, check this.

Example how to specify version 6.5.0:

  platform = espressif32 @ 6.5.0

You’ll find all available versions here PlatformIO Registry


A hardware defect could also be considered.
Double check it with an identical board.

Here it is:

[env:esp_wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
upload_protocol = esptool
upload_speed = 115200
upload_resetmethod = nodemcu
; upload_protocol = espota
; upload_port = 10.248.2.84
; upload_flags = --auth=admin
lib_extra_dirs =
C:\Users\marc\Documents\PlatformIO\Lib
lib_deps =
milesburton/DallasTemperature@^3.11.0
arcao/Syslog@^2.0.0
bblanchon/ArduinoJson@^6.21.3
knolleary/PubSubClient@^2.8
bodmer/TFT_eSPI@^2.5.42
robtillaart/PCF8574@^0.4.0
bodmer/TFT_eWidget@^0.0.6
https://github.com/dvarrel/AsyncTCP.git
https://github.com/me-no-dev/ESPAsyncWebServer.git
greiman/SdFat@^2.2.3
https://github.com/aselectroworks/Arduino-FT6336U.git
https://github.com/michalmonday/CSV-Parser-for-Arduino.git
build_flags =
   ; -Wall
   -DDEBUG
-std=gnu99
-Os
   -u,vfprintf
-DUSER_SETUP_LOADED=1
-DST7796_DRIVER=1
-DTFT_RGB_ORDER=TFT_BGR
-DSPI_FREQUENCY=80000000
-DTFT_MISO=19
-DTFT_MOSI=23
-DTFT_SCLK=18
-DTFT_CS=5
-DTFT_DC=26
-DTFT_RST=25
-DLOAD_GFXFF=1
-DSMOOTH_FONT
board_build.partitions = WROOM-E-n16r8.csv
;board_build.partitions = default.csv
board_build.flash_mode = qio
;board_build.f_flash = 40000000L
build_type = debug

The partition file I posted earlier is what is in WROOM-E-n16r8.csv.

I have tried 40 and 80 MHz flash frequency as well as qio and dio flash access modes with no change in behavior.

I just tried a different WROOM module with the same problem.

Ill try rolling back the platformio next.

But the used esp-wrover-kit.json is limited to 4 MB:

So you have to change this to 16 MB in your platformio.ini

board_upload.flash_size = "16MB"
board_upload.maximum_size = 16777216

By the way: Your platformio.ini is quite complex!

For testing purpose I highly recommend to create a seperate test project with just basic settings!
(Much easier to check what’s going on and why)

OK, so we’re getting somewhere here now.
When I ran out of flash space on my 4MB WROOM module, I moved up to the 16M WROVER module. I had no experience with board files and I tried to put a custom file in the boards folder under the espressif32 platform in my .platformio folder. The PlatformIO system didn’t find it there. So, I decided to modify an existing board file to get the WROVER module going. I eventually got that working and, of course, never got back to figuring out how to get my custom board file recognized by PlatformIO. Just today I came across your answer to mitchdetailed on the forum so I know where to put it now.

What must have happened was my custom board got overwritten on an update and that caused all of the trouble. I knew better than to modify that board file and expect it to be permanent, but when you’re desperate to get new hardware going, you sometimes cut corners. As good as the PlatformIO documentation is, I did not find what I needed there regarding custom board files.

After building a custom board file in a new boards folder in c:\Users\marc\Documents\PlatformIO, I am past the SW_RESET boot loop. This is with my original 16MB partition file. However, I have not rediscovered the magic to getting the external SPI PSRAM working. My call to psramInit() returns false.

My board file looks like this:

 {
  "build": {
    "arduino":{
      "ldscript": "esp32_out.ld"
    },
    "core": "esp32",
    "extra_flags": [
      "-DARDUINO_ESP32_DEV",
      "-DBOARD_HAS_PSRAM",
      "-mfix-esp32-psram-cache-issue"
    ],
    "f_cpu": "240000000L",
    "f_flash": "80000000L",
    "flash_mode": "qio",
    "hwids": [
      [
        "0x0403",
        "0x6010"
      ]
    ],
    "mcu": "esp32",
    "variant": "esp32"
  },
  "connectivity": [
    "wifi",
    "bluetooth",
    "ethernet",
    "can"
  ],
  "debug": {
    "default_tool": "ftdi",
    "onboard_tools": [
      "ftdi"
    ],
    "openocd_board": "esp32-wrover.cfg"
  },
  "frameworks": [
    "arduino",
    "espidf"
  ],
  "name": "Espressif ESP32-WROVER-E 16MB",
  "upload": {
    "flash_size": "16MB",
    "maximum_ram_size": 327680,
    "maximum_size": 16777216,
    "protocols": [
      "esptool",
      "espota",
      "ftdi"
    ],
    "require_upload_port": true,
    "speed": 460800
  },
  "url": "https://espressif.com/en/products/hardware/esp-wrover-kit/overview",
  "vendor": "Espressif"
}

Do I need to modify the “upload” section’s maximum_ram_size attribute to something more than 327680?

I think it would be nice if PlatformIO had a tool in the build process that would sanity-check the board file against the partition file and catch mistakes like the one I made.

There are 3 possible locations :

  1. <homedir>/.platformio/platforms/espressif32/boards
  2. <homedir>/.platformio/boards
  3. <projectdir>/boards

Where

  • homedir on windows is C:/users/<username> (should be similar on other systems)
  • 1: will be overridden / deleted on platform updates or might not be used when the project specifies a specific platform version
  • 2: will be global available to all your projects
  • 3: will be available only to the current project

See Custom Embedded Boards — PlatformIO latest documentation

No, leave this value. This is the integrated in package memory and must not be modified!

Your boards.json missing the information about how the PSRAM is connected.
I don’t know which exact board / module you’re using, so i assume it is an “ESP32-WROVER-E” or “ESP32-WROVER-IE”.
Regarding to the table on page 7 of the datasheet the flash and the PSRAM are using QUAD SPI.

Two changes in your boards.json are necessary:

  1. “memory_type” must be changed:
 {
  "build": {
    "arduino":{
      "ldscript": "esp32_out.ld",
      "memory_type" : "qio_qspi"
    },
    ...
  1. “psram_type” must be added:
    ...
    "flash_mode": "qio",
    "psram_type": "qio",
    ...

Thank you for the detailed help. I made those changes but I still don’t have an operational SPI RAM. Both WROVER modules I have been testing behave the same way so I’m assuming I still need to get the configuration right. Can you think of anything else I need to check?

Some of the discussions I’ve read from the forums include running

pio run -t menuconfig

to make changes to the partition table. If I try that, I just get an error

scons: *** Do not know how to make File target `menuconfig'

One other observation is that despite specifying the flash and psram modes as qio, the boot info seems to suggest dio:

ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x33 (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:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0

Is that unexpected?

“menuconfig” is not available for pure Arduino projects because Arduino is using a pre-compiled core. (Wrong track)

That’s the output of the first-stage bootloader and is absoloutely okay.
The issue must be somewhere else.

Since your project has a complex configuration, I’ll repeat myself and suggest using a simple and basic test project.

  • minimal platformio.ini using the default esp-wrover-kit
[env:esp-wrover-kit]
platform = espressif32
board = esp-wrover-kit
framework = arduino
monitor_speed = 115200
build_flags = 
  -DBOARD_HAS_PSRAM
  -mfix-esp32-psram-cache-issue
  • minimal sketch
#include <Arduino.h>

void setup() {
    Serial.begin(115200);
    Serial.printf("PSRAM size: %d\r\n", ESP.getPsramSize());
    Serial.printf("PSRAM free: %d\r\n", ESP.getFreePsram());
}

void loop() {}

I’m working on your recommendation. Is there a global place to put partition files like we’ve done with board files?

Are there any other project configuration files to consider?

Per Espressif 32 — PlatformIO latest documentation user-defined partiton layouts must be placed in the root folder of the project.

I got the PSRAM recognized in the simple and complex sketches. The magic was to include the lines

   -DBOARD_HAS_PSRAM
   -mfix-esp32-psram-cache-issue

in the build_flags section of the platformio.ini file. It appears that including them in the board file like this:

    "extra_flags" : [
      "-DARDUINO_ESP32_DEV",
      "-DBOARD_HAS_PSRAM",
      "-mfix-esp32-psram-cache-issue"
    ],

is not effective.

That’s strange, because other built-in boards manifest and my own custom board manifest works without issues.