I am able to build and upload programs successfully, but no output on my UNO when I use Platform.io

Hello all, I am trying to test out a new arduino Uno I bought. When I run programs via the Arduino IDE it builds/uploads successfully and it functions correctly. When I use VSC PIO though, it builds/uploads successfully, I get indicator lights on the board showing the upload, but it doesn’t actually do anything. I’ve so far only tried it with the blinking example code.

To reiterate, Both IDE’s build and upload successfully. PIO however does not actually blink the LED after the upload. No visible errors in terminal, and code is exact same.

PIO Terminal:

 *  Executing task in folder Arduino Test: C:\Users\Work\.platformio\penv\Scripts\platformio.exe run --target upload 

Processing uno (platform: atmelavr; board: uno; framework: arduino)
-----------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: 
PLATFORM: Atmel AVR (5.1.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr @ 5.2.0
 - tool-avrdude @ 1.60300.200527 (6.3.0)
 - toolchain-atmelavr @ 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> 
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\uno\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.4% (used 9 bytes from 2048 bytes)
Flash: [          ]   1.4% (used 444 bytes from 32256 bytes)
Configuring upload protocol...
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
Looking for upload port...
Auto-detected: COM6
Uploading .pio\build\uno\firmware.hex

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file ".pio\build\uno\firmware.hex"
avrdude: writing flash (444 bytes):

Writing | ################################################## | 100% 0.09s

avrdude: 444 bytes of flash written
avrdude: verifying flash memory against .pio\build\uno\firmware.hex:
avrdude: load data flash data from input file .pio\build\uno\firmware.hex:   
avrdude: input file .pio\build\uno\firmware.hex contains 444 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.06s

avrdude: verifying ...
avrdude: 444 bytes of flash verified

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

avrdude done.  Thank you.

======================== [SUCCESS] Took 2.55 seconds ========================
 *  Terminal will be reused by tasks, press any key to close it. 

Arduino IDE:


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\Work\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\Work\AppData\Local\Temp\arduino\sketches\A982F225FB44C2EEDD0C43D007224FCB/Blink.ino.hex"
avrdude: writing flash (924 bytes):

Writing | ################################################## | 100% 0.17s

avrdude: 924 bytes of flash written

avrdude done.  Thank you.

Code:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(13, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Can you show a screenshot of VSCode with your main code file open?

Mhm okay, then it’s something different than I thought. (If you were to use src/main.c instead of src/main.cpp, I would expect this behavior).

The main suspicious thing is the difference in generated firmware sizes. Under PIO

avrdude: writing flash (444 bytes):

Under the Arduino IDE 2.0:

avrdude: writing flash (924 bytes):

And the bigger image is the working one. Let me see what firmware size you should expect…

1 Like

I noticed that but didnt know what to think

Ok so something changed, I ran the exact same program in vsc. All of a sudden it works now. No restart, nothing. Just works. But, it did go back to 924 instead of 444 bytes. Not sure why

Is the “Documents” folder, under which this project is created, in One Drive? Because that can cause major issues.

No but it is in Google drive, im assuming cloud based storage causes the same issues with it? updating the file doesnt work too well?

I think if there are some syncing issues or time races, when it goes to build the firmware.elf, and gets some older version of some object files or empty content back, then the firmware.elf won’t be build correctly.

Try recreating the project on your regular harddrive and see if this issues occurs, ever?

1 Like