Error when uploading to Arduino WiFi Uno Rev 2

I continue to get an error when I try to upload a simple (Blink) sketch to my Arduino WiFi Rev 2.:

.
.
.
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): timeout/error communicating with programmer (status -1)

The sketch is the “Blink example” and I am trying to set up VSCode with PlatformIO to be able to program this board.
I have already uploaded and run the sketch using the Arduino IDE and it works fine.
I’ve imported the project into VSCode/Platformio. I’ve added the #include <Arduino.h> line but cannot get it to upload.
I’m running on a Mac.
Any ideas?

What’s the platformio.ini?

Full log of the project task “Advanced → Verbose Upload”?

Hi,
Thank you for responding.
This is the platformio.ini file:

[env:ATmega4809]
platform = atmelmegaavr
board = ATmega4809
framework = arduino

Here’s the output from the serial monitor when I try to upload:

"CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/ATmega4809.html
PLATFORM: Atmel megaAVR (1.4.0) > ATmega4809
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 48KB Flash
PACKAGES: 
 - framework-arduino-megaavr-megacorex 1.0.7 
 - tool-avrdude-megaavr 2.60300.210128 (6.3.0) 
 - toolchain-atmelavr 2.70300.201015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio/build/ATmega4809/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.1% (used 4 bytes from 6144 bytes)
Flash: [          ]   1.6% (used 804 bytes from 49152 bytes)
.pio/build/ATmega4809/firmware.elf  :
section                     size      addr
.data                          0   8398848
.text                        804         0
.bss                           4   8398848
.comment                      17         0
.note.gnu.avr.deviceinfo      64         0
.debug_aranges               128         0
.debug_info                10070         0
.debug_abbrev               8934         0
.debug_line                  945         0
.debug_str                  3973         0
Total                      24939
<lambda>(["upload"], [".pio/build/ATmega4809/firmware.hex"])
AVAILABLE: jtag2updi
CURRENT: upload_protocol = jtag2updi
BeforeUpload(["upload"], [".pio/build/ATmega4809/firmware.hex"])
Auto-detected: /dev/cu.usbmodem143302
Forcing reset using 1200bps open/close on port /dev/cu.usbmodem143302
avrdude -v -p atmega4809 -C /Users/smiller85715/.platformio/packages/tool-avrdude-megaavr/avrdude.conf -c jtag2updi -b 115200 -P "/dev/cu.usbmodem143302" -U flash:w:.pio/build/ATmega4809/firmware.hex:i

avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/smiller85715/.platformio/packages/tool-avrdude-megaavr/avrdude.conf"
         User configuration file is "/Users/smiller85715/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem143302
         Using Programmer              : jtag2updi
         Overriding Baud Rate          : 115200
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): sign-on command: status -1
avrdude: jtagmkII_getsync(): timeout/error communicating with programmer (status -1)

avrdude done.  Thank you.

*** [upload] Error 1
================================================================================= [FAILED] Took 166.30 seconds =================================================================================
The terminal process "platformio 'run', '--target', 'upload'" terminated with exit code: 1.

I’m not sure how to format this stuff in the post…
Steve

Why that? Per documentation you’re supposed to select board = uno_wifi_rev2 here.

Markdown.

Thanks again. I did not see your second response until this morning after I had tried the experiment where I reconfigured the project for Arduino Uno Atmega 328P. Uploading the same program worked perfectly.

It has been a while since I worked with PlatformIO and I was unsure of how to set things up. Changing the board as the documentation shows elliminates the problem…duh!

Thank you for the help.