ESP32_APP_OFFSET is not being set by board variable upload.offset_address

Is there a way to set the upload offset? The (user\.platformio\platforms\espressif32\builder)
script implies that ESP32_APP_OFFSET should be set by upload.offset_address but line 166 defaults it to 0x10000.

I changed the line to read:
ESP32_APP_OFFSET=board.get(“upload.offset_address”, “0x10000”),

which lets me set the offset from platformio.ini (or the board file) as expected but I figured there was a proper way to change the offset without editing the platform files.

Correct, that will the default value if

board_upload.offset_address = 0x...

is not in the platformio.ini.

[edit] in case it wasnt clear, i am defining the offset_address in platformio.ini (though I also tried in the board .json file to similar effect)

Yes, that is what I would expect as well. However, has the value hard coded and does not read offset_address. The only way I was able to make it work was to modify the build script to read the value (line 166 as indicated above).

Setting upload protocol to custom in platformio.ini and defining my own build command also seems to have no effect (it always defaults to “esptool” protocol).

I assume I am just doing it wrong but I cant quite figure out what it is.

Show your full platformio.ini.

[edit] Thanks for your time, it is appreciated [/edit]

[edit] removed my ini as all of it wasnt germane [/edit]

; C:\Users\[user]]\.platformio\platforms\espressif32\builder\ line 166 needs to be modified to the following
; ESP32_APP_OFFSET=board.get("upload.offset_address", "0x10000"),
; working on a better solution

board_upload.offset_address = 0x210000

;this doesnt work either
;board_upload.protocol = custom
;board_upload.command = "$PYTHONEXE" "$UPLOADER" $UPLOADERFLAGS 0x210000 $SOURCE

and for clarity, the extra scripts are post build steps which do some packaging and I verified they did not touch any of the env or build variables.

Actually I can’t find this line. L. 166 is

In the platform-espressif32 3.2.0 version.

However, I remember now that I had the same problem and had to resort to Python.

The way it’s programmed right now, at least how I see it, the platformio.ini option is only respected in that

case which also works; If I do

platform = espressif32
board = esp32dev
framework = arduino
board_upload.offset_address = 0x210000
upload_protocol = esp-prog

it actually does

CURRENT: upload_protocol = esp-prog
openocd -d2 -s C:/Users/Max/.platformio/packages/tool-openocd-esp32/share/openocd/scripts -f interface/ftdi/esp32_devkitj_v1.cfg -f board/esp-wroom-32.cfg -c “adapter_khz 5000” -c “program_esp {{.pio\build\esp32dev\firmware.bin}} 0x210000 verify” …

But not for serial uploads. A bug for that is filed in Inconsistent usage of offset_address · Issue #538 · platformio/platform-espressif32 · GitHub.

However, that might be going down the wrong path entirely – are you 100% sure you don’t need to use partition tables to describe your upload address? Changing the offset_address directly was only needed by me because I was writing a, basically, minimal bootloader application.

Thanks for the great feedback! The esp-prog using it is the only reason I knew there was an offset_address to begin with and I found it odd it didnt grab it for esptool.

I like your replace method as a better work around. I will check to make sure I have the most up to date platform scripts as its odd that my line 166 doesn’t match yours (though I probably added or removed an empty line in my fiddling so maybe not that odd).

And yes, we have a firmware file at 0x10000 that interfaces with some test equipment but our main build goes to an OTA partition at 0x210000. Ideally I could do a build target that would build both of these binaries but for debugging its good enough that just the OTA partition gets loaded.

Thanks again,


was a workable answer.

1 Like

I’m having the same problem with pio + espidf framework project. How/what do I patch?

Sorry, not a python expert.