arduino / ArduinoCore-megaavr

Arduino Core for the ATMEGA4809 CPU
103 stars 62 forks source link

Nano Every on linux: "avrdude: jtagmkII_getsync(): sign-on command: status -1" when uploading sketches #124

Open chconnor opened 1 year ago

chconnor commented 1 year ago

Hello -- with IDE 2.0.2 or 1.8.19 running on Kubuntu Linux 22.04 I am unable to upload sketches to the Nano Every.

It gives many errors like this:

avrdude: jtagmkII_getsync(): sign-on command: status -1

...eventually followed by:

Failed uploading: uploading error: exit status 1

The same sketch/board/USB cable/USB port combination works fine in Windows 10 on IDE 2.0.2.

I have found, in Linux, that if I change the Serial monitor to 1200 baud (from the default of 9600), and then upload the sketch, it works. After that I can upload the sketch at any baud rate, including 9600 baud, until the board is power cycled.

I was told this was the place to report this issue. Let me know if I can provide any other information.

Verbose console output, in case it's useful:

/home/savel/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/avr-size -A /tmp/arduino-sketch-014E27C2218B86F33F99FEE7D689DAE1/Telemetrix4Arduino.ino.elf
Sketch uses 21797 bytes (44%) of program storage space. Maximum is 49152 bytes.
Global variables use 1630 bytes (26%) of dynamic memory, leaving 4514 bytes for local variables. Maximum is 6144 bytes.
Performing 1200-bps touch reset on serial port /dev/ttyACM0
"/home/savel/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/home/savel/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega4809 -cjtag2updi -P/dev/ttyACM0  -b115200 -e -D "-Uflash:w:/tmp/arduino-sketch-014E27C2218B86F33F99FEE7D689DAE1/Telemetrix4Arduino.ino.hex:i" "-Ufuse2:w:0x01:m" "-Ufuse5:w:0xC9:m" "-Ufuse8:w:0x00:m" {upload.extra_files}

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/savel/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/home/savel/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         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(): timeout/error communicating with programmer (status -1)

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

I also tried with MegaCoreX on IDE 1.8.19. Same behavior -- although one difference is that 1.8.19 remembers the last baud rate (2.0.2 reverts to 9600 every time). If I just open the serial monitor window (already at 1200), but don't change baud, that's enough to "fix" it and make it work.

facchinm commented 1 year ago

Hi @chconnor , we found this problem some time ago and it looks like a regression in the linux kernel; basically the "set 1200bps" message and the "open port" were well separated (some milliseconds) while in recent kernels (but not on all distributions) the second is being sent immediately after the first, creating some confusion in the D11 firmware. Setting the port at 1200bps separately gives the fw some time to properly set its internal state. We definitely need to allocate some time to fix the issue mainline (or simply add a quirk for the Nano every) beacuse updating the D11 firmware is not viable for most of the users. @agdl

tehkillerbee commented 1 year ago

@chconnor We have the same issue. We made a small python script to be executed before attempting to upgrade firmware. This script performs the baud rate "handshake" and also makes sure to enable hupcl as it is needed for arduino reset. It seems the Arduino IDE is also supposed to do this, but for some reason it does not work properly. Perhaps this is explained by @facchinm .

#!/usr/bin/python3
#   Run this script to reset the Arduino Nano Every
#   eg. sudo python3 mcu_reset.py
#
# Note: You must install pyserial first; i.e. sudo pip3 pyserial

import serial
import os, sys
# total arguments
n = len(sys.argv)
if n >= 2:
    port = sys.argv[1]
else:
    port = '/dev/ttyACM0'

print("Port: {}".format(port))

#re-enable hupcl temporarily (necessary for arduino reset using serial port)
os.system('sudo /bin/stty -F {} hupcl'.format(port))

try:
    #perform Arduino Nano Every reset "handshake"
    ser = serial.Serial()
    ser.baudrate = 1200
    ser.port = port
    ser.open()
    ser.close()

except serial.SerialException:
    print("Error: serial.SerialException")
    exit()
gratefulfrog commented 7 months ago

Hi, I am getting this same bug on my Ubuntu system Distributor ID: Ubuntu Description: Ubuntu 22.04.4 LTS Release: 22.04 Codename: jammy and further: Operating System: Ubuntu 22.04.4 LTS
Kernel: Linux 6.5.0-18-generic Architecture: x86-64 Hardware Vendor: Framework Hardware Model: Laptop 13th Gen Intel Core

Arduion IDE: Version: 2.3.2 Date: 2024-02-20T09:54:08.669Z CLI Version: 0.35.3

It is really annoying, is there any solution coming?

Also, when the error message starts appearing: avrdude: jtagmkII_getsync(): sign-on command: status -1 avrdude: jtagmkII_getsync(): sign-on command: status -1 ... There seems to be no way to abort the upload?

Is there any way to abort the upload without closing the IDE?

Thanks for all the great Arduino stuff - I am a supporter from day 1!

gratefulfrog commented 7 months ago

Hi, Here is some more info, now the nano seems to get burning hot as it fails to upload...

Hi, I have a similar or the same issue with a nano every... I can sometimes, but not often upload to it... The board sometimes, often, gets burning hot.

Below is the output from an attempt to upload blink, (attached my conf file).

I am at a loss, and there seems to be no way to abort the uploading process, which is really painful...

Any help would be greatly appreciated, my project is being killed by these delays... And now I fear that the board is burning up...

for blink (my config file is attached)à

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/bob/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/home/bob/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         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.conf.zip

gratefulfrog commented 4 months ago

This is an ongoing issue and quite painful.

I learned that setting the serial monitor to 1200 baud, BEFORE UPLOADING, will mostly make the upload work.

After the upload works once, the serial monitor can be set to anything and the upload will continue to work, as long as the Nano Every is not powered off. I am not sure what happens if the reset button is pressed, though.

It would be nice if someone were to integrate this workaround into the the Arduino IDE (I am using version 2.3.2 , on Ubuntu 22.04.04)

Cheers, B

rph-r commented 3 months ago

Hello, I have this issue for years and years, and I'm working a lot with nanos. On 1.8.19 I simply had to click several times on Upload and finally it was working, until I unplugged the Arduino. Now on 2.3.2, IDE get stuck on uplaoding... and I have to quit. Painful, as you said...

anttiryt commented 1 month ago

For me resetting the arduino remotely helped. I have Nano Everys with sign-on command: status -1 problems. Suddenly flash worked in a jif ( sorry my stepper is still not moving ).

This short script helped me reset Nano Every ( https://stackoverflow.com/a/55985897/468921 )

sleep 1
while true; do    
    echo -en "\x01\x02"    
    sleep 0.1
 done | socat -T1 -t1 - /dev/ttyACM1,hupcl=1,raw,b1000000,cs8,echo=0
w-u-2-o commented 1 month ago

How are people programming their Nano Every boards? How can this not be fixed after 18 months?

I'm a brand new Arduino user, but a highly experienced engineer, so not a "newbie". I'm suffering with the same issues here with my very first Arduino board which, unfortunately, is a Nano Every. I can't go to another board, this is replacing a Nano in an existing project and I need the extra memory of the Every.

Environment is Windows 10 Pro, IDE 2.3.2. I tried IDE 2.0.2 but had the same problem. The IDE automatically detects the board and will read board info.

At this point I'm dead in the water. This seems ridiculous, Arduino development is supposed to be "easy".

Is there no work-around for this issue?

Is there a separate UPDI programmer I can use with the IDE? Perhaps this one?

FWIW, with the verbose option turned on here is the IDE 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 "C:\Users\Radioserver2\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM6
         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.

Failed uploading: uploading error: exit status 1
anttiryt commented 1 month ago

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

FWIW, all my problems with -1 have been that another program is using the COM port. It seems, atleast on Linux, that only one program can access the special USB com port at a time.

I know you're using windows, but try to look if you can somehow find some other program that's using the COM port. is it possible there's two versions of the software running? Check out also process list and systray. Try uninstalling IDE and going with CLI. Or try uninstalling CLI and going with IDE.

Also, it's not a bad idea to use another computer to program the Arduino. Maybe an old laptop or an rPi? Just install CLI and use RDP.

w-u-2-o commented 1 month ago

There are no other programs using the COM port in question. If there was a conflict then how would the IDE automatically detect the presence of the board, and how would it be able to read the board info?

On Sun, Aug 25, 2024 at 5:06 PM Antti Rytsölä @.***> wrote:

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

FWIW, all my problems with -1 have been that another program is using the COM port. It seems, atleast on Linux, that only one program can access the special USB com port at a time.

I know you're using windows, but try to look if you can somehow find some other program that's using the COM port. is it possible there's two versions of the software running? Check out also process list and systray. Try uninstalling IDE and going with CLI. Or try uninstalling CLI and going with IDE.

Also, it's not a bad idea to use another computer to program the Arduino. Maybe an old laptop? You just install CLI and use RDP.

— Reply to this email directly, view it on GitHub https://github.com/arduino/ArduinoCore-megaavr/issues/124#issuecomment-2308993734, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX4YGS6X5X7HLAD3AO3GEQDZTJBOPAVCNFSM6AAAAAASML52J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYHE4TGNZTGQ . You are receiving this because you commented.Message ID: @.***>

w-u-2-o commented 1 month ago

I just tried using IDE 2.3.2 on a fully up to date Linux Mint build. I got the same exact behavior as on Windows. Board was auto-detected. Board info could be read. Upload fails with same exact error messages.

gratefulfrog commented 1 month ago

There is a work around!

On Mon, 26 Aug 2024, 00:11 w-u-2-o, @.***> wrote:

I just tried using IDE 2.3.2 on a fully up to date Linux Mint build. I got the same exact behavior as on Windows. Board was auto-detected. Board info could be read. Upload fails with same exact error messages.

— Reply to this email directly, view it on GitHub https://github.com/arduino/ArduinoCore-megaavr/issues/124#issuecomment-2309013649, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUDF3OTT7VA2XZPW2H4GDZTJJC7AVCNFSM6AAAAAASML52J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBZGAYTGNRUHE . You are receiving this because you commented.Message ID: @.***>

gratefulfrog commented 1 month ago

In the ide, open the aerial monitor and set it to 1200 baud.

Then connect the nano every.

Open the serial monitor.

Then upload your sketch.

It should work fine!

On Mon, 26 Aug 2024, 00:16 Grateful Frog, @.***> wrote:

There is a work around!

On Mon, 26 Aug 2024, 00:11 w-u-2-o, @.***> wrote:

I just tried using IDE 2.3.2 on a fully up to date Linux Mint build. I got the same exact behavior as on Windows. Board was auto-detected. Board info could be read. Upload fails with same exact error messages.

— Reply to this email directly, view it on GitHub https://github.com/arduino/ArduinoCore-megaavr/issues/124#issuecomment-2309013649, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUDF3OTT7VA2XZPW2H4GDZTJJC7AVCNFSM6AAAAAASML52J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBZGAYTGNRUHE . You are receiving this because you commented.Message ID: @.***>

w-u-2-o commented 1 month ago

That work-around does not work for Windows. Apparently that is a Linux work-around only. So I proceeded to try this on the Linux machine I had set up in addition to Windows, as already noted above.

The instructions are not complete. You can't open the serial monitor and set it to 1200 without first connecting the board. So I did that. Then I disconnected and reconnected the board with the serial monitor already open and set to1200.

After that it took 2 tries to upload the sketch. The first try failed about halfway through. The second try appeared to be successful.

gratefulfrog commented 1 month ago

Sorry for the bad info on the work around. I wasn't in front of my machine.

On Linux that fix works nearly 100% of the time.

I have no idea about development on windows as I seek to be fully open source and haven't developed on windows in 30 years...

There must be a solution though because the nano every is a very popular board.

I hope you find one!

Cheers, Bob

On Mon, Aug 26, 2024, 03:47 w-u-2-o @.***> wrote:

That work-around does not work for Windows. Apparently that is a Linux work-around only. So I proceeded to try this on the Linux machine I had set up in addition to Windows, as already noted above.

The instructions are not complete. You can't open the serial monitor and set it to 1200 without first connecting the board. So I did that. Then I disconnected and reconnected the board with the serial monitor already open and set to1200.

After that it took 2 tries to upload the sketch. The first try failed about halfway through. The second try appeared to be successful.

— Reply to this email directly, view it on GitHub https://github.com/arduino/ArduinoCore-megaavr/issues/124#issuecomment-2309141860, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOUDFY54HKLAHAC4NLRSY3ZTKCMXAVCNFSM6AAAAAASML52J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBZGE2DCOBWGA . You are receiving this because you commented.Message ID: @.***>

w-u-2-o commented 1 month ago

Following up on this: right now it appears that there is some issue with my Windows machine. Linux works perfectly on a separate machine. I'm thinking it is some USB hardware limitation rather than a problem with Windows or drivers.

Final update (problem solved): testing on another Win10 machine was successful. Redoubling efforts on the first Win10 machine one of the initially suggested changes (from the Arduino Forum) turned out to be a bad move. Reversing that change, plus whatever else I did prior to doing that, fixed the problem.