-
-
Notifications
You must be signed in to change notification settings - Fork 7k
If the controller resets externally for some reason while writing the code, AVRdude gets stuck in an infinite loop avrdude: stk500_recv(): programmer is not responding #7704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Does it keep printing the message? In my experience, avrdude usually retries 10 times and then fails when it encounters an error (OTOH, these retries are almost always pointless, after the first failure it usually does not recover, so if there is an option to disable them, that might be useful...) |
Following your directions:
Clearly this is not an infinite loop. Are you experiencing different behavior @Vinayakj009? I absolutely agree with matthijskooijman that this retry is annoying and pointless. I always just end up pulling the USB plug when that happens. I've searched for a way to change this behavior a few times and it doesn't seem that AVRDUDE provides any way to configure it, other than modifying the source code. I did some searching without finding any related bug report or patch upstream. Somewhat related (and all the issues that network off of it): #5928 Vinayakj009 also reported this at: |
@per1234 : I apologize for the delayed response. I am new to raising issues and contributing to other repos. Please check my instructions. I said to wait till the avrdude code reaches write mode, as in it should start printing this Writing | ################ That's when you press the reset button. Hitting the reset button, when code reaches this point is tricky if the code is very small ( 0 to 2kb hex file) that's why you need a 2 to 4 kb file so that you have time to hit the reset button. |
matthijskooijman: Those retries are not pointless. This goes for the same for the error that I faced. |
I narrowed down the issue to the avr.c file at line number 504, 511, 662 and 1008. Lines 504, 511 and 662 don't take care of the return code from pgm->cmd(pgm, cmd, res); Also, there is no retry count or anything of the sort here, so the system goes into an infinite loop. I was able to get the thing to come out of the infinite loop, with 3 retries, (I think it changes the method or reprogramming for each try) by checking if the return code is negative, and exiting the function with return -1. I also added a return -1 to line number 1008, and now the code does not enter an infinite loop ever. |
I can reproduce the problem using the version of Optiboot in Arduino AVR Boards but the problem does not occur using the latest version of Optiboot. |
@per1234 : Help me understand what happens next. Also, I think it would be useful to know the following (I don't really know if this is relevant or not). I reached this issue because I was tinkering with uploading the code to the Arduino via a TCP connection. (The one where you use -P "net::") My network was a bit slow, and the controller would exit the bootloader during the upload process, and I would see the issue. I was able to replicate the same behavior by pressing the reset button, via a standard usb to ttl, but I originally stumbled into the issue because the programming speed was slow. What this potentially means is there may be more than 1 way to enter this infinite loop. |
I'm just a volunteer who tries to help out with administration of the issue tracker. If it's a problem with AVRDUDE then I suggest you submit a patch or bug ticket to them: Arduino does apply some of their own patches to AVRDUDE but it's not sure whether that would be done to fix such a rarely encountered and easy to work around bug. Even if they did, I think they would still want to see an upstream patch submitted for the change. |
Hi,
I know this is an avrdude issue, but i have detected the same issue with the AVRdude bundled with the Arduino IDE 1.8.4 on MacOs
To replicate the same, you will need an Arduino, and a compiled hex file with relatively large size (2 to 4kb should be perfect).
Exact conditions for error
./avrdude -c arduino -p m328p -P /dev/cu.usbmodem1411 -U flash:w:<some_code>.hex
avrdude: stk500_recv(): programmer is not responding
The code gets stuck in the same loop and keeps printing the error message every 1 second.
I know I can fix this for myself by resetting the board again at the right time, but then again, I feel that the code should be able to handle this and at the least exit so that it does not claim system resources.
The text was updated successfully, but these errors were encountered: