Upload failed - Arduino uno - beginner

Hi guys :slight_smile:

I’ve been trying to figure out why I’ve had this problem for 2 days now.
I’ve read a lot of topics on the subject, I’ve done a lot of research but I can’t find a solution to this problem.

I’m using Linux Mint, an Arduino UNO (Elegoo).

I’d like to be able to upload a simple blink :frowning:

when i use : pio run --target upload -v

➜  Arduino1 pio run --target upload -v    
Processing uno (platform: atmelavr; board: uno; framework: arduino; board_build.mcu: atmega328p; board_build.f_cpu: 16000000L)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (5.0.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 -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".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: [          ]   2.9% (used 936 bytes from 32256 bytes)
.pio/build/uno/firmware.elf  :
section                    size      addr
.data                         0   8388864
.text                       936         0
.bss                          9   8388864
.comment                     17         0
.note.gnu.avr.deviceinfo     64         0
.debug_aranges               64         0
.debug_info                1866         0
.debug_abbrev              1482         0
.debug_line                 258         0
.debug_str                  520         0
Total                      5216
<lambda>(["upload"], [".pio/build/uno/firmware.hex"])
AVAILABLE: arduino
CURRENT: upload_protocol = arduino
BeforeUpload(["upload"], [".pio/build/uno/firmware.hex"])
Auto-detected: /dev/ttyACM0
avrdude -v -p atmega328p -C /home/olivier/.platformio/packages/tool-avrdude@1.60300.200527/avrdude.conf -c arduino -b 115200 -D -P /dev/ttyACM0 -U flash:w:.pio/build/uno/firmware.hex:i

avrdude: Version 6.3, compiled on Sep 12 2016 at 15:21:49
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/olivier/.platformio/packages/tool-avrdude@1.60300.200527/avrdude.conf"
         User configuration file is "/home/olivier/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

*** [upload] Error 1

and i tried : pio run --target bootloader -v

➜  Arduino1 pio run --target bootloader -v
Processing uno (platform: atmelavr; board: uno; framework: arduino; board_build.mcu: atmega328p; board_build.f_cpu: 16000000L)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (5.0.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 -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Using bootloader image:
/home/olivier/.platformio/packages/framework-arduino-avr/bootloaders/optiboot/optiboot_atmega328.hex

Selected fuses: [lfuse = 0xFF, hfuse = 0xDE, efuse = 0xFD]
avrdude -p atmega328p -C /home/olivier/.platformio/packages/tool-avrdude@1.60300.200527/avrdude.conf -e -c arduino -Ulock:w:0x3F:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m -Uefuse:w:0xFD:m
avrdude: ser_open(): can't open device "unknown": No such file or directory

avrdude done.  Thank you.

*** [bootloader] Error 1

° with the Arduino IDE i have the same for the upload
° i check my groups : ➜ ~ groups olivier
olivier : olivier adm dialout cdrom sudo dip plugdev lpadmin sambashare
° i tried with a ESP32-CE Mini but this is the same
° i tried with an other Arduino UNO, and i can uploaded :confused: (this is why i think it’s my bootloader…)

can you help me ?

//Sorry for my english

I tried replacing my MCU (Atmega328p from AlieExpress) with another one (an official Arduino Atemga328p) and it works!
I can upload my program…

So I don’t understand what’s going on

Taking your second problem, first:

pio run --target bootloader -v

This failed with avrdude: ser_open(): can't open device "unknown": No such file or directory because you need to burn a bootloader using an ICSP device, or another Arduino configured as an ICSP by running the Arduino supplied example, “Arduino ISP”. You also need to supply, at the very least, the upload_protocol parameter in platformio.ini.

As for the first problem, let’s start at the beginning just to be sure. I know you have probably done all this, but bear with me please. :wink: I notice you are using the command line.

First, we need to be sure that you are in the correct groups. I’m not sure about Manjaro, I think it’s Arch based, so you might need plugdev or uucp as an additional group. I’m pretty sure dialout is Debian/Ubuntu/Mint. You can find out if you plug your board in to USB then:

ls -l /dev/ttyACM0

Your board obvioulsy is closer to an actual Uno than my Chinese clone. I have an on-board FTDI chip which gives me /dev/ttyUSB0. The result of my query is:

crw-rw-rw- 1 root dialout 188, 0 Jan 15 10:41 /dev/ttyUSB0

You can see that the board’s group is dialout in my case. Check yours and if necessary, add yourself to the group noted.

# Replace xxxxxx with the appropriate group.
sudo usermod -a -G xxxxxx $USER

Once added, you will need to close your terminal session and reopen it and recheck with the groups command that all is now well.

Also, you need to be sure that your udev rules are up to date:

curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules

You can find the command at 99-platformio-udev.rules — PlatformIO latest documentation if you don’t trust me! :neutral_face: You will need to restart the service. This will be one of:

sudo service udev restart 

or

sudo udevadm control --reload-rules
sudo udevadm trigger

Hopefully, you will now be able to upload without problems. If not, read on…

Now create a brand new blinck sketch.

cd ~/Documents/PlatformIO
mkdir blink
cd blink

pio init -b uno

When that’s done, edit src/main.cpp and add the following:

// The next line is important!!!
#include <Arduino.h>

void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
}

Check your platformio.ini has the following, and no more, other than comments:

[env:uno]
platform = atmelavr
framework = arduino
board = uno

Now compile:

pio run

Fix any typos, sketches never compile first time! Then upload:

pio run -t upload -v

In my case, it all worked fine.

HTH

Cheers,
Norm.

1 Like

First of all, thank you so much for your reply and sharing. It’s impressive for me :crazy_face:
in fact, I’ve already tried many of your suggestions, but I’d be happy to try them again with a master :sunglasses:.

for this:

ls -l /dev/ttyACM0

➜  ~ ls -l /dev/ttyACM0
crw-rw-rw- 1 root dialout 166, 0 Jan 15 17:49 /dev/ttyACM0

for this:
You can see that the board’s group is dialout in my case. Check yours and if necessary, add yourself to the group noted.

my user is in the dialout group :slightly_smiling_face:

➜  ~ groups olivier
olivier : olivier adm dialout cdrom sudo dip plugdev lpadmin sambashare

for this:
Also, you need to be sure that your udev rules are up to date:

i added the rules with the same link
➜  ~ cd /etc/udev/rules.d 
➜  rules.d ls -l
total 16
-rw-r--r-- 1 root root 8419 Jan 15 17:57 99-platformio-udev.rules
-rw-r--r-- 1 root root   31 Jan 13 16:19 my-newrule.rules

and a restart the service:

OMG ! that works !!

but :frowning: for my others mcu dosen’t work…

the problem must be with the bootloader…
because with the other MCU I can upload.

I need to focus: how to burn bootloader.
and to do that, you’ve given me some new leads, thank you so much.

If I can burn a bootloader, I’ll get back to you with the info.

in parallels, i learn the C language and i have a question about that.
It’s possible to write only in C and not in C++ with platformIO ? (to uppload a project in a MCU etc…)

again, thank yo uso much Norm,
cheers :beers:

Olivier

i need something like that ?
ICSP Device

I tried replacing my MCU (Atmega328p from AlieExpress) with another one (an official Arduino Atemga328p) and it works!

This either means the old MCU did not have a bootloader burned in or the bootloader operated at a different baud rate. You could have tried common baud rates, or at least the both known ones as upload_speed setting.

And yes, if the bootloader really wasn’t burned into the chip per-se (which would be weird with a commercially sold uno board), then you can burn it with one of multiple ISCP adapters, even other other Unos (“Arduino as ISP”).

Hi @maxgerhardt

Thank you so much for your answer.

for this:
This either means the old MCU did not have a bootloader burned in or the bootloader operated at a different baud rate. You could have tried common baud rates, or at least the both known ones as upload_speed setting.

I tried with different upload speed but dosen’t works :frowning:

Finaly i think, the issue it’s about the programmer…
I need a ICSP device…

I ordered this : https://www.amazon.com.be/gp/product/B07Y3B8H91/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1

and this (for my Attiny85): https://www.amazon.com.be/dp/B07YBZ1F6L?psc=1&ref=ppx_yo2ov_dt_b_product_details

If you have a “spare” Arduino lying around – I’ve used an Uno, a Duemilanove and a Nano – you can follow these instructions on the Arduino website, to make your board into an ICSP programming device.

I used this for ages as an ICSP before I purchased a USBtiny device.

Cheers,
Norm.

Hello guys :slight_smile:
it’s sunday, so it’s time to take advantage of the opportunity to make this burn bootloader.

Thank you or your answers :slight_smile:

I tried with Arduino IDE and a “spare” Arduino UNO.
// i should like use only platformIO… it’s my new parallels project

And…

It’s works ! :sunglasses: :beers: :fire: :tada:

At the moment we have a lot of snow, and my ISP programmer order isn’t arriving… Impatient as I am, I tried the following method

I followed your instructions from Arduino website and this post (in french) :
passionelectronique

Thank you so much for your sharing.

Now, i will can continue my project of “sculpture” and upload my code in this ATmega328p.

i should like do a thermometer station with a coincells…

Full in C without Arduino library …

I don’t know if this project it’s realist, but i’m learning a lot !

2 Likes

Et voilà !

that works without Arduino !!
this is the first for me, i’m proud … go to open a beer ! :sunglasses: :beers:

Now, i will study to change my alimentation.
to finaly, my project will be works with 3,5 volt

this has nothing to do with the topic, but it’s just for fun :upside_down_face:.

1 Like

It’s provbably not relevant here, but when using a ATMega328P on a breadboard, it’s advisable to have a 100 nF capacitor between AREF and GND in the same manner as you have for VCC and GND.

Glad you got it sorted out, well done.

Cheers,
Norm.

1 Like