-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Arduino IDE sending avrdude commands to avrisp2 too fast #2986
Comments
For a 1s delay within a Win7 batch file, you can try this solution: http://ss64.com/nt/timeout.html
|
Hi jogo, My wording in the original post is a bit wierd now that i look back at it, but i do have a 1s delay working. The goal is for a sub 1s delay (eg: 500milliseconds ?) to see how short a delay causes the problem to re - occur. My hope is that i'm not the only one suffering this issue, and that the people whom work on that part of the IDE can insert a very short delay between sending multiple commands. I'm actually curious about it and would be interested in seeing where in the code that the "Burn Bootloader" code exists. |
I upgraded to Arduino 1.6.x and cannot burn the bootloader anymore with AVRISP mkIII. I could under previous versions of Arduino. I don't know if this is why but you are not alone and this has happened on all computers we upgraded arduino to 1.6.x. We still have an older copy of arduino and we have to use that to burn the boot loader. Would definitely like to see this fixed. |
darkwingz24, If you turn on verbose output in the IDE settings and check the error output you may find 2 commands are run. You can paste these commands into a command line and run them, one after the other. If i knew a bit more about programming i'd have a go at making the change myself, i'd bet it would be trivial to add a 1s delay between commands. |
Last time I tried burning Bootloader I found out that the avrdude-version comming with 1.6.3 was compiled without USB support. |
@adadnc this has been fixed and released. use boards manager to upgrade your avr core to the latest |
@virtual812 I turned on verbose mode as you said and copied the two instructions: "C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude" -C"C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf" -v -patmega328p -cstk500v2 -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m "C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avrdude" -C"C:\Program Files (x86)\Arduino/hardware/tools/avr/etc/avrdude.conf" -v -patmega328p -cstk500v2 -Pusb -Uflash:w:"C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/atmega/ATmegaBOOT_168_atmega328.hex":i -Ulock:w:0x0F:m I ran these as separate commands in a command prompt and boom, it works! I have also noticed that if I click "burn boot loader" in Arduino IDE enough times it does work about 1 in 20 times. So definitely a timing issue where the second command is issued too soon. At least I can make a batch file for this as I have 350 boards to program and this would not have been good to do with a 19/20 failure rate. Thank you for the help and guidance. |
ffissore, The imported bug from the google code repo is here: It is a bug in avrdude and should not be fixed by adding delays into the IDE. |
Confirming that this continues to be a problem with Arduino 1.6.4 (downloaded 2015-05-22) and an AVRISP mkII on Windows 7 x64 when trying to burn the
Issuing the two avrdude commands manually (i.e. slowly, by hand) via the Windows command terminal works successfully and results in a functional chip with a bootloader, so the issue certainly appears to be the speed at which the Arduino IDE is issuing the two avrdude commands to the AVRISP mkII. |
No! Once again. The real issue is NOT in the IDE. avrdude is intentionally resetting the USB just before it exits. It does this every single time. There are ways to work around it without modifying avrdude:
The real solution is to actually fix it in avrdude: The real answer is to fix the IDE to do everything in a single command which avoids the problem. --- bill |
Thanks for the clarification Bill. I did originally read all of your info in the other links on the google code site. As you've repeated several times here and over there, one solution to this bug that has broken the function of the Arduino IDE is to alter the way the Arduino IDE is handling the bootloader burn process. It appears that you agree that a workaround could be made to the Arduino IDE to restore full functionality that existed in prior versions of the Arduino software. Seems like a valid topic for the Arduino bug tracker, and separately for the non-responsive avrdude author? |
This isn't something that just broke. This issue has existed for MANY years and still exists today. And yes it is a good topic for the Arduino bug tracker and for avrdude and that is why I entered it in the Arduino bug list and on savannah tracker over 4 years ago and it is still there today (It was imported into the github issues when arduino was transitioned from Google Code to github) I have fully documented the issue, I have provided a fix for avrdude and and also provided a work around for the IDE. Since I don't have update access to either repository I can't update the code to either fix it in avrdude or add the work around to the IDE. While the ideal solution would be to fix ardude, after more than 5 years, it seems pretty clear that this may not ever get fixed in the main line avrdude code. --- bill |
This is insane. I have followed the links over to avrdude and can now see where the true Ultimately here I am, an idiot that can hardly make a light blink, having I'm genuinely surprised I figured it out. A message to anyone reading this with the power to do something about it, The solution proposed seems simple enough, let's make it happen! Else anyone wanna show a noob how to compile the IDE? Cheers all.
|
@bperrybap https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/platform.txt#L85 |
Cristian, So it may require some minor changes to the IDE as well to truly handle it properly and cleanly. In other words, even if the preferred avrdude work around solution does require modifying the IDE, I'm pretty sure I could modify one of these burn bootloader entries to do it all in one step. Then patch the other entries to essentially be NOPs so avrdude is not called again. I'll go review the IDE code and get back with some additional information as I'm not sure what is needed until I go review the latest IDE code. --- bill |
Cristian, Does the Arduino team have any interest in shipping a patched version of avrdude to just solve the problem where it really needs to be solved? Maybe you guys could put some pressure on Joerg to fix it since it it affects all the Atmel programming devices as Arduino is a pretty propular and visible user of the AVR chips and avrdude. |
Hi Bill, if the patch is simple (like adding a call to https://github.com/arduino/toolchain-avr/tree/master/avrdude-patches if you can do a pull-request on that repository to add the patch we can include it in the next release |
The avrdude patch is very simple. 7 lines of new code. in usb_libusb.c
This polls the USB every .1 seconds for up to 3 seconds looking for the USB device. Joerg didn't like the fix because it broke the way he was "polling" for USB devices on the USB. From my conversation with him it sounded like he was occasionally taking advantages of a undocumented "feature" of avrdude to detect the presence of certain USB devices. Adding this fix to the code would slow down what he was doing since it would wait for several seconds for a non existent device, so he didn't like it. This added delay only happens when you are trying to use non existent devices. Normal users are not ever doing this. There is no added delay when avrdude is used normally and so users of Atmel devices like the MKII or the Dragon will see no added delays. Cristian, But for sure if you guys are up to accepting and shipping avrdude patches, I'll get the avrdude patch to you guys. I'm not understanding what that patch tree is or how it works. --- bill |
OK, guys. The old libusb problem was that if you didn't reset the USB then libusb left the USB device in some sort of non working state and libusb couldn't talk to it anymore. So if things were in that state, then I'm assuming that no amount of delay would help. Anyway, I'd like to understand if this is now just a linux issue (as the latest code seems to indicate) or whether the Windows and MAC users are still seeing it as well. In order to know, I'd like know the version of the avrdude tool that the IDE is using for those that are having an issue with this. --- bill |
Output from the 2nd part of the bootloader burn process, after successfully burning the fuses in the first step:
Arduino version 1.6.4 from arduino.cc About three years ago when I originally got the AVR mkII working (under Arduino 1.0), I used the info and drivers listed in the first post from this thread: http://forum.arduino.cc/index.php?topic=118089.0 and the driver downloaded from http://mightyohm.com/blog/2010/09/avrisp-mkii-libusb-drivers-for-windows-7-vista-x64/ That arrangement worked fine up through Arduino 1.0.6, but started having this problem when I switched to Arduino 1.6.4. Here's what the Windows device manager reports for the USB driver for my AVR mkII: |
Following up, bperrybap sent me a new modified version of avrdude to work with my windows 7 x64 installation of Arduino 1.6.4. I believe the modified version implements the brief delay between the two bootloader burning steps described in his post above. His new version fixes the issue I was having with the 2nd step of the bootloader burning process failing. My AVRISP mkII works as expected once again. |
There is no blind delay between the 2 avrdude commands like what the IDE is currently doing. The very small amount of added code in avrdude polls for the USB device to be present for up to 3 seconds rather than looking just once. It is 7 lines of code that implements a loop around the existing code that waits 1/10 of a second if the expected device is not there and tries again, but then gives up after looking for 3 seconds. The advantage of this is that doesn't add any additional time to the device connection if it is not necessary. Given the IDE is already doing a 1 second delay between avrdude commands the maximum polling time probably should be bumped to at least 4 seconds and possibly even 5 if the delay inside the IDE is removed. The other alternative is to fix the IDE to not do 2 avrdude commands when burning a bootloader but rather do it all in a single command. If it were fixed this way, avrdude would not need to be fixed/patched and the burn would be just a little bit faster than it is now. |
@bperrybap I'm interested in trying the patched avrdude as I also have the same error burning bootloader with AVRISP mkII via IDE 1.6.6 on Win7 x64 even though it works fine with IDE 1.0.6. Upload using programmer does work. Is it available for download anywhere? Thanks for your work towards fixing this problem. |
@bperrybap P.S. sorry I forgot to answer your email! |
That would be great. I'll share the patch or do a pull-request but where is the actual avrdude code that you guys are using? I looked in the toolchain-avr tree from the link above and didn't see it? Is it somewhere else or am I just missing it? |
We use http://download.savannah.gnu.org/releases/avrdude/avrdude-6.0.1.tar.gz as source base. https://github.com/arduino/toolchain-avr/blob/master/avrdude.build.bash BTW you can't call this script directly because it needs some dependencies compiled first. You should use one of the |
I've created a workaround for this issue: https://github.com/per1234/Arduino-AVRISPmkII-fix that adds a new Programmer menu entry. It can be installed using Boards Manager or manually. |
This issue was solved for me by the update to avrdude 6.3.0-arduino2 in Arduino AVR Boards 1.6.12. Note that there was a new AVRISP mkII issue introduced: arduino/avrdude-build-script#2. EDIT: Using Windows 7 64 bit. |
Should be fixed with #5374. |
Where is the commit for the code that fixes this? |
Sorry wrong link, the fix was in avrdude itself |
That patch has nothing to do with this issue. Even though I expected no change from this patch, I went ahead and tested the 1.6.12 IDE using a Dragon.
After this failure, the Arduino board has no working bootloader as the chip was erased by the first/previous avrdude command that set the fuses. I've been trying for years to get Joerg to fix this in avrdude as it is only a 7 line patch in the libusb code but he won't fix it. It is amazing that this issue has been allowed to go so long without resolution, particularly since I have provided all the needed information to fix it or work around it about 5 years ago. I don't know what else to do to get this resolved. The most ironic part of this, is that avrdude is broken for the official Atmel made ISP programmers. None of the other 3rd party programmers have this issue. My preference would be to patch it in the version of avrdude that the IDE ships, rather than do a work around in the IDE, and also provide an AVR dragon ISP programmer types in the standard programmers.txt file included in the IDE. What can I do to move this issue forward and get it resolved? |
Hi, have come across an issue when burning a bootloader with the IDE.
The IDE sends the 2 avrdude commands too quickly without the AVRispMK2 getting a chance to reset.
I tested this with a batch file by copy/pasting the avrdude commands from the verbose output of the Arduino IDE window.
I was able to reproduce the issue by sending the commands 1 after another immediately using a batch file.
I tried the same again with 'wait 1' to add a 1 second delay to the batch file between commands and the issue was resolved.
This issue may depend on speed of computer.
It would be good to experiment with delays as a full 1 second delay may not be required.
If anyone has any idea how i might add and accurate sub 1s delay to a batch file I'd be happy to test and report my findings.
PC is an i5 3570K, 8gig, Win7x64, Intel SSD
Cheers.
The text was updated successfully, but these errors were encountered: