Arduino Mega: stk500_recv(): programmer is not responding

I looked at these similar posts:

and

to no avail.

I am using PlatformIO with VScode, all latest versions, and am trying yo upload a program. which gives me this error message:

Building in release mode
Checking size .pio/build/uno/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [====      ]  40.6% (used 832 bytes from 2048 bytes)
Flash: [=======   ]  67.6% (used 21818 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Auto-detected: /dev/ttyUSB0
Uploading .pio/build/uno/firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
^C*** [upload] Build interrupted.
AbortedByUser: Aborted by user

I aborted here as it would go to 10 and produce the same result.

However, I can upload this program via the Arduino IDE w/o any problem.

My platformio.ini looks like this (I commented the port as suggested in one of the other posts, but it made no difference; USB0 is the only one connected, and is detected):

[platformio]
default_envs = megaatmega2560
;default_envs = uno
description = Garage controller: lights and doors

[env:uno]
platform = atmelavr
board = uno
framework = arduino
upload_port = /dev/ttyACM0
lib_deps = knolleary/PubSubClient@^2.8
	paulstoffregen/OneWire@^2.3.7
	arduino-libraries/Ethernet@^2.0.1

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
;upload_port = /dev/ttyUSB0
lib_deps = knolleary/PubSubClient@^2.8
	paulstoffregen/OneWire@^2.3.7
	arduino-libraries/Ethernet@^2.0.1

[env]
monitor_speed = 115200

Any hints appreciated.

Well, selecting the proper environment would have avoided this problem.
Sorry, for the bother.

2 Likes