Page 1 of 1

PlatformIO, ESP32 with Flash Encryption enabled - partition 0 invalid magic number

Posted: Wed Aug 19, 2020 6:56 pm
by rg2000
I have an app that has been working on the ESP32 Dev Kits for some time but I want to start encrypting it going forward.

However, when I enable Flash Encryption via menuconfig, build and upload it, I get this error on first upload:

Code: Select all

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:0x3fff0018,len:4
load:0x3fff001c,len:6912
ho 0 tail 12 room 4
load:0x40078000,len:16340
load:0x40080400,len:4460
entry 0x4008069c
E (60) flash_parts: partition 0 invalid magic number 0xa02
E (60) boot: Failed to verify partition table
E (62) boot: load partition table error!
ets Jun  8 2016 00:22:57
I am using custom partitions, so here is my partitions.csv:

Code: Select all

# Name,   Type, SubType, Offset,   Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap,,,,
nvs,data,nvs,,16K,
otadata,data,ota,,8K,
phy_init,data,phy,,4K,
factory,app,factory,,1M,
ota_0,app,ota_0,,1M,
ota_1,app,ota_1,,1M,
In platform.io and menuconfig, offset is set at 0x10000.

platform.ini is as follows:

Code: Select all

[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32dev
framework = arduino
                     espidf
monitor_speed = 115200
monitor_filters = direct
board_build.partitions = partitions.csv
build_flags = 
    -I include
    -I include/util
    -D CONFIG_PARTITION_TABLE_OFFSET=0x10000

platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#idf-release/v4.0

lib_deps =  ArduinoJson
Logging is set at warning as info creates a bootloader that’s too large.

I have run pio run -t erase and pio run -t clean before the uploads.

Any idea what I’m missing?

Thanks

Re: PlatformIO, ESP32 with Flash Encryption enabled - partition 0 invalid magic number

Posted: Thu Aug 20, 2020 3:05 pm
by rg2000
I'll answer my own question. Turns out misunderstood the offset and kept pointing it to the app partition, instead of realizing its referring to the actual partition table location.