Unable to Program esp32-cam using arduino ISP (via atmega2560)

I need some help! I am able to use the arduino (atmega2560) to program the esp32 in Arduino IDE, but I am not able to get it to work with platformio in VSCode on macOS. I read the documentation here Atmel AVR — PlatformIO latest documentation and this is my platform.ini file:

[env:program_via_ArduinoISP]
platform = espressif32
board = esp32cam
framework = arduino
monitor_speed = 115200
upload_protocol = custom
upload_port = /dev/cu.usbmodem13301
upload_speed = 19200
upload_flags =
    -C
    ; use "tool-avrdude-megaavr" for the atmelmegaavr platform
    ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

In VSCode when I click upload I get the following error:

Processing program_via_ArduinoISP (platform: espressif32; board: esp32cam; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Espressif 32 (3.4.0) > AI Thinker ESP32-CAM
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduinoespressif32 3.10006.210326 (1.0.6) 
 - tool-esptoolpy 1.30100.210531 (3.1.0) 
 - tool-mkspiffs 2.230.0 (2.30) 
 - tool-openocd-esp32 2.1000.20210721 (10.0) 
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> 
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 28 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Retrieving maximum program size .pio/build/program_via_ArduinoISP/firmware.elf
Checking size .pio/build/program_via_ArduinoISP/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.1% (used 13580 bytes from 327680 bytes)
Flash: [=         ]   8.4% (used 264942 bytes from 3145728 bytes)
Configuring upload protocol...
AVAILABLE: custom, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = custom
Uploading .pio/build/program_via_ArduinoISP/firmware.bin
sh: avrdude: command not found
*** [upload] Error 127

What does such an upload look like in hardware? Do you upload a special firmware on the ATMega2560 or do you just abuse it as a USB-Serial converter?

Can you go in the Arduino IDE’s File → Preferences menu and tick on “Verbose” for Upload and post the upload command that appears when you upload a sketch to the ESP32?

Thanks @maxgerhardt, I think that’s right, I am abusing it as a USB-Serial converter. Your question made me rethink the config and I was able to get it to work with the following:

[env:program_via_ArduinoISP]

platform = espressif32

board = esp32cam

framework = arduino

monitor_speed = 115200

upload_speed = 115200

The key was adding “upload_speed = 115200” option. I have it wired like this