Uploading issue with mega2560 arduino

I had no luck uploading a sketch to a MEGA2560. I get an avrdude error saying 'can’t connect to com7"
I have uploaded successfully with the arduino ide.

any ideas or suggestions would be appreciated
MANDO

  • exact error message?
  • exact platformio.ini?
  • you’ve made sure to explicitly select the mega environment through the project environment switcher?

Error message =

Linking .pio\build\megaatmega2560\firmware.elf
Checking size .pio\build\megaatmega2560\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 0.1% (used 9 bytes from 8192 bytes)
Flash: [ ] 0.6% (used 1500 bytes from 261120 bytes)
Building .pio\build\megaatmega2560\firmware.hex
Configuring upload protocol…
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port…
Use manually specified: COM7
Uploading .pio\build\megaatmega2560\firmware.hex
avrdude: ser_open(): can’t open device “\.\COM7”: The system cannot find the file specified.

avrdude done. Thank you.

*** [upload] Error 1
============================================================== [FAILED] Took 1.60 seconds ==============================================================The terminal process “C:\Users\TOM.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.

Platformio.ini =

" PlatformIO Project Configuration File

Build options: build flags, source filter

Upload options: custom upload port, speed and extra flags

Library options: dependencies, extra library storages

Advanced options: extra scripting

Please visit documentation for the other options and examples

Redirecting...

[env:megaatmega2560]

platform = atmelavr

board = atmega2560

framework = arduino

upload_port = COM7"

Thanks for the help – hope there’s a clue in there :slight_smile:

TOM

It says there is no COM7 connected to the computer?

Is there a problem with the automatic upload port detection or why specify

in the first place? Have you tried deleting that?

MAX my mistake! I had speced the wrong port. Using the correct port I get this response. I will try auto port detection again but decided to use manual spec when it did not originally find the board.

Compiling .pio\build\megaatmega2560\src\Blink.ino.cpp.o
Linking .pio\build\megaatmega2560\firmware.elf
Checking size .pio\build\megaatmega2560\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [ ] 0.1% (used 9 bytes from 8192 bytes)
Flash: [ ] 0.6% (used 1500 bytes from 261120 bytes)
Configuring upload protocol…
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port…
Use manually specified: COM8
Uploading .pio\build\megaatmega2560\firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x4b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x4b

avrdude done. Thank you.

*** [upload] Error 1
============================================================= [FAILED] Took 103.68 seconds =============================================================The terminal process “C:\Users\TOM.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.

Tom

Can you upload to the board via the Arduino IDE? Via which COM port and which board selected?

Yes sir! Works great no issues. Used com8 for mega 2560

Go into the Arduino IDE settings and turn on “verbose upload”, then upload it again and copy the invocation of avrdude here from the log.

Execute the project task “Advanced → Verbose Upload” and copy the invocation of avrdude, too.

OK I’ve made a breakthrough of sorts. I was successful in getting Platformio to compile and upload an example sketch. When I looked over the output I noticed that without specifying the port the “upload_protocol” was set to “wiring”. With the sketch that would not work I noticed the “upload_protocol” was set to “arduino” (??? I have no clue why!). I added “upload_protocol = wiring” to the non-working sketch and voila it worked.
I want to play with this “discovery” a bit before having you spend any more time and I’ll get back to you if I can’t figure it out :-).
Thanks for your efforts - TOM