Remote build does not flash bootloader - how to fix this?

I’m trying to setup a CI/CD pipeline for my procect with automatic deployment of firmware on a test module (ESP32). I build a toolchain for this, using a raspberry acting as pio remote agent for flashing. This toolchain is working in principle, it flashes.

But i’m facing a problem with esptool in the toolchain:

If building locally, and uploading the image by

pio remote run -t upload (without option -r)

i see the module being flashed with the code, but without bootloader. Thus, the module doesn’t boot.

Configuring flash size...
Flash will be erased from 0x00010000 to 0x00159fff...
Compressed 1348992 bytes to 858343...
Writing at 0x00010000... (1 %)
Writing at 0x0001af27... (3 %)

If building remotely (with option -r), the bootloader is written.

pio remote run -t upload -r

Configuring flash size...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00159fff...
Compressed 17408 bytes to 12112...
Writing at 0x00001000... (100 %)
Wrote 17408 bytes (12112 compressed) at 0x00001000 in 0.5 seconds (effective 256.4 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 475.5 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 621.8 kbit/s)...
Hash of data verified.
Compressed 1348624 bytes to 858311...
Writing at 0x00010000... (1 %)
Writing at 0x0001adfa... (3 %)
Writing at 0x0002732f... (5 %)

How can i fix this?

Seems like a bug to me. Can you file one in Issues · platformio/platform-espressif32 · GitHub?

Done: pio remote run -t upload does not flash bootloader · Issue #1005 · platformio/platform-espressif32 · GitHub