Platformio Upload Error for Arduino Uno Wifi Rev2

The output error when I tried to upload to my Arduino Uni Wifi Rev 2 board is shown below. However, compiling the code is successful. So I think is just some kind of directory issue here.

avrdude: invalid file format '\Users\Wong' in update specifier
avrdude: error parsing update operation 'flash:w:C:\Users\Wong'
*** [upload] Error 1

My platformio.ini code:

[env:uno_wifi_rev2]
platform = atmelmegaavr
board = uno_wifi_rev2
framework = arduino
lib_deps =
    arduino-libraries/Braccio@^2.0.4
    arduino-libraries/Servo@^1.1.8

My main.cpp:

#include <Arduino.h>
#include <Braccio.h>
#include <Servo.h>
Servo base;
Servo shoulder;
Servo elbow;
Servo wrist_rot;
Servo wrist_ver;
Servo gripper;
void setup() {  
  //Initialization functions and set up the initial position for Braccio
  //All the servo motors will be positioned in the "safety" position:
  //Base (M1):90 degrees
  //Shoulder (M2): 45 degrees
  //Elbow (M3): 180 degrees
  //Wrist vertical (M4): 180 degrees
  //Wrist rotation (M5): 90 degrees
  //gripper (M6): 10 degrees
  Braccio.begin();
}
void loop() {
  /*
   Step Delay: a milliseconds delay between the movement of each servo.  Allowed values from 10 to 30 msec.
   M1=base degrees. Allowed values from 0 to 180 degrees
   M2=shoulder degrees. Allowed values from 15 to 165 degrees
   M3=elbow degrees. Allowed values from 0 to 180 degrees
   M4=wrist vertical degrees. Allowed values from 0 to 180 degrees
   M5=wrist rotation degrees. Allowed values from 0 to 180 degrees
   M6=gripper degrees. Allowed values from 10 to 73 degrees. 10: the toungue is open, 73: the gripper is closed.
  */
  // the arm is aligned upwards  and the gripper is closed
                     //(step delay, M1, M2, M3, M4, M5, M6);
  Braccio.ServoMovement(20,         90, 90, 90, 90, 90,  73);  

}

Can anyone make sense of the error? I can’t seem to find anyone that has a similar issue.

Does your username have a space in in it? There might be a path escaping issue in the upload script.

Thanks for replying. Answering yr question, when I create a new platformio project, I saved it at a D/ drive where there are no spaces in my directory naming. However, looking at the c_cpp_properties.json code. There are lines that indicated some files are still located on another drive.

//
// !!! WARNING !!! AUTO-GENERATED FILE!
// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
//
{
    "configurations": [
        {
            "name": "PlatformIO",
            "includePath": [
                "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/include",
                "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/src",
                "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/.pio/libdeps/uno_wifi_rev2/Braccio/src",
                "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/.pio/libdeps/uno_wifi_rev2/Servo/src",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/cores/arduino/api/deprecated",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/cores/arduino",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/variants/uno2018",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/EEPROM/src",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/HID/src",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/SPI/src",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/SoftwareSerial/src",
                "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/Wire/src",
                "C:/Users/Wong Zhi Wei/.platformio/packages/tool-unity",
                ""
            ],
            "browse": {
                "limitSymbolsToIncludedHeaders": true,
                "path": [
                    "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/include",
                    "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/src",
                    "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/.pio/libdeps/uno_wifi_rev2/Braccio/src",
                    "D:/Nextcloud/PlatformIO/Project/Robot Arm Braccio/.pio/libdeps/uno_wifi_rev2/Servo/src",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/cores/arduino/api/deprecated",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/cores/arduino",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/variants/uno2018",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/EEPROM/src",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/HID/src",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/SPI/src",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/SoftwareSerial/src",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/framework-arduino-megaavr/libraries/Wire/src",
                    "C:/Users/Wong Zhi Wei/.platformio/packages/tool-unity",
                    ""
                ]
            },
            "defines": [
                "PLATFORMIO=50203",
                "ARDUINO_AVR_UNO_WIFI_REV2",
                "UNO_WIFI_REV2_328MODE",
                "MILLIS_USE_TIMERB3",
                "F_CPU=16000000L",
                "ARDUINO_ARCH_MEGAAVR",
                "ARDUINO=10808",
                "USB_VID=0x03eb",
                "USB_PID=0x2145",
                "USB_PRODUCT=\"Arduino Uno WiFi Rev2\"",
                "USB_MANUFACTURER=\"Arduino\"",
                ""
            ],
            "cStandard": "c11",
            "cppStandard": "c++11",
            "compilerPath": "C:/Users/Wong Zhi Wei/.platformio/packages/toolchain-atmelavr/bin/avr-gcc.exe",
            "compilerArgs": [
                "-mmcu=atmega4809",
                ""
            ]
        }
    ],
    "version": 4
}

I am unsure if this is the cause of it. But free feel to suggest any method for me to try.

Can you please go into the project tasks and press “Advanced → Verbose Upload” and post the content here?

Here you go.

> Executing task in folder Robot Arm Braccio: C:\Users\Wong Zhi Wei\.platformio\penv\Scripts\platformio.exe run --verbose --target upload <

Processing uno_wifi_rev2 (platform: atmelmegaavr; board: uno_wifi_rev2; framework: arduino; lib_deps: arduino-libraries/Braccio@^2.0.4, arduino-libraries/Servo@^1.1.8)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/uno_wifi_rev2.html
PLATFORM: Atmel megaAVR (1.5.0) > Arduino Uno WiFi Rev2
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash     
PACKAGES:
 - framework-arduino-megaavr 1.8.7
 - tool-avrdude-megaavr 1.60300.191015 (6.3.0)
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Braccio> 2.0.4 (D:\Nextcloud\PlatformIO\Project\Robot Arm Braccio\.pio\libdeps\uno_wifi_rev2\Braccio)
|   |-- <Servo> 1.1.8 (D:\Nextcloud\PlatformIO\Project\Robot Arm Braccio\.pio\libdeps\uno_wifi_rev2\Servo)
|-- <Servo> 1.1.8 (D:\Nextcloud\PlatformIO\Project\Robot Arm Braccio\.pio\libdeps\uno_wifi_rev2\Servo)
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\uno_wifi_rev2\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.5% (used 90 bytes from 6144 bytes)
Flash: [=         ]   7.6% (used 3720 bytes from 48640 bytes)
.pio\build\uno_wifi_rev2\firmware.elf  :

section                     size      addr

.data                         14   8398848

.text                       3542       512

.rodata                      164     20438

.bss                          76   8398862

.comment                      17         0

.note.gnu.avr.deviceinfo      64         0

.debug_aranges               416         0

.debug_info                11869         0

.debug_abbrev               9132         0

.debug_line                 2445         0

.debug_str                  3979         0

Total                      31718
<lambda>(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
BeforeUpload(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
avrdude -v -p atmega4809 -C "C:\Users\Wong Zhi Wei\.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c xplainedmini_updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x02:m -Ulock:w:0xC5:m "-Uflash:w:"C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex":i" -b 115200 -V -e -D -P usb -U flash:w:.pio\build\uno_wifi_rev2\firmware.hex:i
avrdude: invalid file format '\Users\Wong' in update specifier
avrdude: error parsing update operation 'flash:w:C:\Users\Wong'
*** [upload] Error 1
===================================================================== [FAILED] Took 1.71 seconds =====================================================================The terminal process "C:\Users\Wong Zhi Wei\.platformio\penv\Scripts\platformio.exe 'run', '--verbose', '--target', 'upload'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Okay I’m very sure this is where PlatformIO goes wrong. It tries to tell it to flash the bootloader too (?) but some weird path escpaing kicks in and messes things up. Without the quotes at the start and end of the argument it should have been correct.

As far as I can see that happens here in the code

with

the problem is that the Python code looks correct since it doesn’t add quotes around the ´-Uflash` argument itself inside the string, just the bootloader path, it must come from somewhere else.

I will open an issue about this – sadly I don’t have any other quick fix than to add a new Windows user account that has no spaces in the name. Hopefully this is fixed soon.

Actually there is also another fix possible: You can re-install PlatformIO into a different folder by setting up the PLATFORMIO_CORE_DIR system environment variable. You can use that to get rid of the space inside the path C:\Users\Wong Zhi Wei\.platformio\ (which is the PlatformIO core). This has been discussed in e.g. Install platformio in different folder on Linux - #3 by ivankravets and Specify Path to PlatformIO in Visual Studio Code - #11 by maxgerhardt.

An issue about this bug has been opened at Users can't upload to Uno WiFi Rev2 because of argument escaping problem · Issue #33 · platformio/platform-atmelmegaavr · GitHub.

This is way too advanced for me to understand. But thank you for your help and I will read up to your suggested solution. To those who read this in the future, my alternative working solution is just to download the original Arduino IDE and code it there. It works without any issue for me.

This bug has been supposedly fixed. Can you replace your platformio.ini with

[env:uno_wifi_rev2]
platform = https://github.com/platformio/platform-atmelmegaavr.git
board = uno_wifi_rev2
framework = arduino

and verify that the sketch uploads?

(You must also have git installed for this).

1 Like

I have modified the platformio.ini file as requested. I can confirm that it is working and I am able to upload my code to Arduino Uno Wifi Rev 2 without any issue. I also attached the verbose upload output for your reference if needed. Thanks again for the quick fix.

> Executing task in folder Robot Arm Braccio: C:\Users\Wong Zhi Wei\.platformio\penv\Scripts\platformio.exe run --verbose --target upload --environment uno_wifi_rev2 <

Processing uno_wifi_rev2 (platform: https://github.com/platformio/platform-atmelmegaavr.git; board: uno_wifi_rev2; framework: arduino; lib_deps: arduino-libraries/Braccio@^2.0.4, arduino-libraries/Servo@^1.1.8)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/atmelmegaavr/uno_wifi_rev2.html
PLATFORM: Atmel megaAVR (1.5.0+sha.317e3e8) (git+https://github.com/platformio/platform-atmelmegaavr.git) > Arduino Uno WiFi Rev2
HARDWARE: ATMEGA4809 16MHz, 6KB RAM, 47.50KB Flash
PACKAGES:
 - framework-arduino-megaavr 1.8.7
 - tool-avrdude-megaavr 1.60300.191015 (6.3.0)
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 7 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Braccio> 2.0.4 (D:\Nextcloud\PlatformIO\Project\Robot Arm Braccio\.pio\libdeps\uno_wifi_rev2\Braccio)
|   |-- <Servo> 1.1.8 (D:\Nextcloud\PlatformIO\Project\Robot Arm Braccio\.pio\libdeps\uno_wifi_rev2\Servo)
|-- <Servo> 1.1.8 (D:\Nextcloud\PlatformIO\Project\Robot Arm Braccio\.pio\libdeps\uno_wifi_rev2\Servo)
Building in release mode
MethodWrapper(["checkprogsize"], [".pio\build\uno_wifi_rev2\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.5% (used 90 bytes from 6144 bytes)
Flash: [=         ]   7.6% (used 3714 bytes from 48640 bytes)
.pio\build\uno_wifi_rev2\firmware.elf  :

section                     size      addr

.data                         14   8398848

.text                       3536       512

.rodata                      164     20432

.bss                          76   8398862

.comment                      17         0

.note.gnu.avr.deviceinfo      64         0

.debug_aranges               416         0

.debug_info                11869         0

.debug_abbrev               9132         0

.debug_line                 2445         0

.debug_str                  3979         0

Total                      31712
<lambda>(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
AVAILABLE: xplainedmini_updi
CURRENT: upload_protocol = xplainedmini_updi
BeforeUpload(["upload"], [".pio\build\uno_wifi_rev2\firmware.hex"])
avrdude -v -p atmega4809 -C "C:\Users\Wong Zhi Wei\.platformio\packages\tool-avrdude-megaavr\avrdude.conf" -c xplainedmini_updi -Ufuse2:w:0x01:m -Ufuse5:w:0xC9:m -Ufuse8:w:0x02:m -Ulock:w:0xC5:m -U "flash:w:C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex:i" -b 115200 -V -e -D -P usb -U flash:w:.pio\build\uno_wifi_rev2\firmware.hex:i

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

         System wide configuration file is "C:\Users\Wong Zhi Wei\.platformio\packages\tool-avrdude-megaavr\avrdude.conf"

         Using Port                    : usb
         Using Programmer              : xplainedmini_updi
         Overriding Baud Rate          : 115200
avrdude: Found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATmega4809
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
           prodsig        0     0     0    0 no         61   61      0     0     0 0x00 0x00
           fuses          0     0     0    0 no          9    0      0     0     0 0x00 0x00
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse6          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse7          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           fuse8          0     0     0    0 no          1    0      0     0     0 0x00 0x00
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
           usersig        0     0     0    0 no         64   64      0     0     0 0x00 0x00
           flash          0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom         0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3_UPDI
         Description     : Atmel AVR XplainedMini in UPDI mode
         ICE hardware version: 0
         ICE firmware version: 1.19 (rel. 57)
         Serial number   : 3E8AF0BC6CAE72168E44
         Vtarget         : 5.00 V
         JTAG clock megaAVR/program: 0 kHz
         JTAG clock megaAVR/debug:   0 kHz
         JTAG clock Xmega: 0 kHz
         PDI clock Xmega : 0 kHz

avrdude: Partial Family_ID returned: "mega"
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9651 (probably m4809)
avrdude: erasing chip
avrdude: reading input file "0x01"
avrdude: writing fuse2 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse2 written
avrdude: verifying fuse2 memory against 0x01:
avrdude: load data fuse2 data from input file 0x01:
avrdude: input file 0x01 contains 1 bytes
avrdude: reading on-chip fuse2 data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of fuse2 verified
avrdude: reading input file "0xC9"
avrdude: writing fuse5 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse5 written
avrdude: verifying fuse5 memory against 0xC9:
avrdude: load data fuse5 data from input file 0xC9:
avrdude: input file 0xC9 contains 1 bytes
avrdude: reading on-chip fuse5 data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "fuse5", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xcd instead of 0xc9 (double check with your datasheet first).
avrdude: 1 bytes of fuse5 verified
avrdude: reading input file "0x02"
avrdude: writing fuse8 (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of fuse8 written
avrdude: verifying fuse8 memory against 0x02:
avrdude: load data fuse8 data from input file 0x02:
avrdude: input file 0x02 contains 1 bytes
avrdude: reading on-chip fuse8 data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of fuse8 verified
avrdude: reading input file "0xC5"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xC5:
avrdude: load data lock data from input file 0xC5:
avrdude: input file 0xC5 contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex"
avrdude: writing flash (280 bytes):

Writing | ################################################## | 100% 0.12s

avrdude: 280 bytes of flash written
avrdude: verifying flash memory against C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex:
avrdude: load data flash data from input file C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex:
avrdude: input file C:\Users\Wong Zhi Wei\.platformio\packages\framework-arduino-megaavr\bootloaders\atmega4809_uart_bl.hex contains 280 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.10s

avrdude: verifying ...
avrdude: 280 bytes of flash verified
avrdude: reading input file ".pio\build\uno_wifi_rev2\firmware.hex"
avrdude: writing flash (4226 bytes):

Writing | ################################################## | 100% 1.06s

avrdude: 4226 bytes of flash written

avrdude: safemode: Fuses OK (E:FF, H:FF, L:FF)

avrdude done.  Thank you.

==================================================================== [SUCCESS] Took 3.97 seconds ====================================================================

Terminal will be reused by tasks, press any key to close it.