Uploading on a Uno board fails
S4deghN opened this issue · 3 comments
Describe the bug
Using ArduinoUpload to upload code to a Uno board whit AVR ISP programmer being chosen registers the following command:
"/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -Uflash:w:/home/s4/Arduino/sketches/AS5048A_tester/build/AS5048A_tester.ino.hex:i"
which fails and this is the output:
"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 "/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
User configuration file is "/home/s4/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
Using Programmer : stk500v1
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 : STK500
Description : Atmel STK500 Version 1.x firmware
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.01s
avrdude: Device signature = 0x000000 (retrying)
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x000000 (retrying)
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Error during Upload: Failed programming: uploading error: exit status 1
doing the exact same thing with arduino-cli or the Arduino IDE registers this command:
"/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_521661/AS5048A_tester.ino.hex:i "
which succeeds and this is the output:
"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 "/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
User configuration file is "/home/s4/.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
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 "/tmp/arduino_build_521661/AS5048A_tester.ino.hex"
avrdude: writing flash (4120 bytes):
Writing | ################################################## | 100% 0.73s
avrdude: 4120 bytes of flash written
avrdude: verifying flash memory against /tmp/arduino_build_521661/AS5048A_tester.ino.hex:
avrdude: load data flash data from input file /tmp/arduino_build_521661/AS5048A_tester.ino.hex:
avrdude: input file /tmp/arduino_build_521661/AS5048A_tester.ino.hex contains 4120 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.57s
avrdude: verifying ...
avrdude: 4120 bytes of flash verified
avrdude done. Thank you."
the commands that each produces and the results are different, I have tested other programmer options of the plugin but none of them worked for me. I have also tested using the plugin with g:arduino_use_cli being set and without it
.
System information
- OS: [linux]
- Vim: [neovim v0.6.1]
- Arduino: [Arduino: 1.8.19]
- CLI version: [0.19.3-arch]
- ArduinoInfo: [
Board :arduino:avr:uno
Programmer :avrisp
Port :/dev/ttyACM0
Baud rate :9600
Hardware dirs :/home/s4/.arduino15/packages/arduino/hardware/avr/1.8.4, /home/s4/.arduino15/packages/stm32duino/hardware/STM32F1/2021.5.31, /home/s4/.arduino15/packages/STMicroelectronics/hardware/stm32/2.1.0
Verify command:arduino-cli compile -b arduino:avr:uno -p /dev/ttyACM0 -P avrisp --build-path "/home/s4/Arduino/sketches/AS5048A_tester/build" -v "/home/s4/Arduino/sketches/AS5048A_tester/AS5048A_tester.ino"
]
To Reproduce
Steps to reproduce the behavior:
- open a simple arduino sketch in neovim: $
nvim [sketch].ino - use
AruinoChooseBoard: Arduino Uno,ArduinoChoosePort: [your system port],ArduinoChooseProgrammer: AVR ISP. - use
ArduinoUpload
Expected behavior
Working command
- $
cd /path/to/sketch - $
arduino-cli board attach arduino:avr:uno [sketch].ino - $
arduino-cli board attach serial://[port] - $
arduino-cli compile [sketch].ino - $
arduino-cli upload -v
alternatively Arduino IDE application also works and produces the same result.
output:
"/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-P/dev/ttyACM0" -b115200 -D "-Uflash:w:/tmp/arduino-sketch-5C77E717031944FF3B6B05CEF0DD445F/AS5048A_tester.ino.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 "/home/s4/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
User configuration file is "/home/s4/.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
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 "/tmp/arduino-sketch-5C77E717031944FF3B6B05CEF0DD445F/AS5048A_tester.ino.hex"
avrdude: writing flash (4120 bytes):
Writing | ################################################## | 100% 0.69s
avrdude: 4120 bytes of flash written
avrdude done. Thank you.
There's probably some subtle difference in the command that's being run from
vim. I don't have any way to test this locally, so the best I can do is give you
the general debugging steps that I would follow.
Try running the upload command vim-arduino is using (by adding a -u to the compile command)
arduino-cli compile -b arduino:avr:uno -p /dev/ttyACM0 -P avrisp \
--build-path "/home/s4/Arduino/sketches/AS5048A_tester/build" \
-v -u "/home/s4/Arduino/sketches/AS5048A_tester/AS5048A_tester.ino"
It should fail. Then see if you can gradually update your working compile &
upload into a single line command. Doing this one step at a time should make it
easy to spot problems. At this point you should have a working one-line
compile & upload, and a non-working one. From there you should be able to change
one thing at a time until the command starts working. Once we know what triggers
the failure we can reason better about the potential root cause and create a fix
or workaround.
The only differences I see at the moment are specifying the programmer and the
build-path. Of those, I suspect the programmer argument.
This is all that is different
failing command: ... -cstk500v1 -P/dev/ttyACM0 -Uflash...
succeeding command: ... -carduino -P/dev/ttyACM0 -b115200 -D -Uflash...
I figured out that choosing the None option for programmer with ArduinoChooseProgrammer command lets Arduino-IDE or arduino-cli (both the same) falls back on its default which is the succeeding command and it resolved the problem for me.
Not sure if it's intended to be this way but coming from Arduino-IDE I'm used to have AVR ISP selected as programmer.
Not an arduino IDE expert, but I believe that the IDE always has a programmer selected, but only actually uses it if you select "Upload Using Programmer". If this is the case then that would explain why manually passing it in causes the upload to fail.