MightyCore + ATmega32 + Mega 2560 as ISP

I’m having a heck of time just trying to flash the MightyCore bootloader onto an ATmega32A using a Mega 2560 as an ISP using PlatformIO. I had no trouble uploading the ArduinoISP sketch to the 2560 and (as far as I can tell) it seems to be working. This isn’t something I’ve ever attempted in the past, so I kind of cobbled this together based on instructions from the MightyCore github, PlatformIO documentation, and at least one Instructables article:

[platformio]
default_envs = Upload_UART

; To upload using an Arduino as ISP, run:
; pio run -e Upload_ArduinoISP -t upload
[env:Upload_ArduinoISP]
board = ATmega32
platform = atmelavr
framework = arduino
upload_protocol = custom
upload_port = /dev/cu.usbmodem143101
upload_speed = 19200
upload_flags =
	-C
	${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

; Run: pio run -e fuses_bootloader -t bootloader
[env:fuses_bootloader]
platform = atmelavr
framework = arduino
board = ATmega32
board_hardware.oscillator = external
board_hardware.uart = uart0
board_bootloader.speed = 115200
board_hardware.bod = 2.7
board_hardware.eesave = yes
upload_protocol = ${env:Upload_ArduinoISP.upload_protocol}
upload_port = ${env:Upload_ArduinoISP.upload_port}
upload_speed = ${env:Upload_ArduinoISP.upload_speed}
upload_flags = ${env:Upload_ArduinoISP.upload_flags}
upload_command = ${env:Upload_ArduinoISP.upload_command}

[env:Upload_UART]
platform = atmelavr
framework = arduino
board = ATmega32
upload_protocol = arduino
upload_port = /dev/ttyUSB0
board_upload.speed = ${env:fuses_bootloader.board_bootloader.speed}
platform_packages = platformio/framework-arduino-avr-mightycore@^2.2.1
lib_deps = 
	cyrusbuilt/ArduinoHAF@^1.1.9
monitor_port = ${env:Upload_UART.upload_port}
monitor_speed = ${env:fuses_bootloader.board_bootloader.speed}

I’m sure I’ve just done something silly here, but the issue I’ve had with trying to flash the bootloader and set fuses are as follows:

  1. avrdude command not found. I assume this is because the binary isn’t in my $PATH (it’s located where you’d expect on a Mac though: ~/.platformio/packages/tool-avrdude/bin/avrdude). I copy and paste the upload command and adjust the command so that the full path to avrdude and it’s .conf file are present, it will at least execute but…

  2. It seems to inject certain options into the command line more than once: avrdude -p atmega32 -C "avrdude.conf" -e -C /Users/cyrus/.platformio/packages/tool-avrdude/avrdude.conf -p atmega32 -P /dev/cu.usbmodem143101 -b 19200 -c stk500v1 -Ulock:w:0x3F:m -Uhfuse:w:0xc6:m -Ulfuse:w:0xff:m. As you can see it injects the -C and -p params twice. Also, if I change upload_command to have the full path to avrdude, it still just starts the command line out with ‘avrdude’ and doesn’t seem to truly honor that setting.

  3. Despite the above issues, manually executing the command appears to actually attempt to upload but I get an error: avrdude: stk500_recv(): programmer is not responding

I wired it up following this instructable: https://www.instructables.com/Programming-ATMEGA32-or-Any-Other-AVR-Using-Arduin/

My ultimate goal was to flash the '32 with the bootloader and fuses using the '2560, then afterward be able to upload my firmware to the '32 using it’s serial port like normal.