-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Serial Port selected disconnects after upload. #3495
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
The micro disconnects and reconnects USB when switching from sketch to bootloader and back, perhaps this causes the problem? I haven't tried reproducing this, though. |
I think the switching is causing the problem, because it switches to the port for uploading but never returns to the normal port. The IDE never reselects the port after an upload. I think something that works with the Leonardo/micro upload style has been changed in the code, because it used to work correctly, i.e. it remembered the com port it is on after an upload. |
Hi @ReeceM , are you on Linux? Your problem can be triggered by the serial monitor (which is now kept in a "zombie" state during upload) respawning too soon and thus locking the previous port, so the sketch will get another one. |
Hi @facchinm, I am on Windows XP, never had this problem before. |
Very strange, as Windows assigns different COM numbers to bootloader and sketch. Are you uploading with the serial monitor opened? |
Ok, thanks for the screenshot, we'll analyze this issue as soon as @ffissore is back! |
@facchinm cool 😃 |
Hi, we can also reproduce this issue with a ATMega32U4 (3.3V/8MHz). The same cannot be reproduced with ATMega32U4(5V/16MHz) with Arduino IDE 1.6.5r2. This issue does not happen to Arduino IDE 1.6.4. We suspect that this is related to In recent changes, the uploader will set the |
Does this only happen on Windows? |
Hi @NicoHood,
|
have you tried the 16mhz bootloader on a 16 mhz device? I mean you cannot use a slower/faster bootloader on a device with a different crystal. You should try the sparkfun 16mhz bootloader for sure. You could also try to recompile HoodLoader2 (see my repos) for 8mhz and see if this fixes the issue (since the original and modified bootloaders have some major problems) |
But still I think the IDE code should have a more "formal" way to deal with Leonardo-derivatives which have disappearing COM ports after sketch uploads. |
Reduce timeout time along with clock frequency to make sure COM port timing is aligned with Arduino IDE detection rules. See arduino/Arduino#3495
I do not have any 8mhz device, but with a clock devider I could test this though. However I dont have the time to do it. But it seems that 8mhz causes the problem. You could try to recompile HoodLoader2 with 8mhz and see if it also has the problem. Because the sparkfun and official bootloaders are not perfect, I could imagine that this causes the problem, and not the IDE itself. |
Wow, there is some activity :). First off my pro micro broke a month ago as it was one from v1.3 batch where the micro USB connector did not have the extra mount pads, thus I am at present and have been unable to test this, so thank you to those who have commented on this issue. @pablosun what IDE version did you test the Sparkfun 5v/16MHz bootloader with? @NicoHood I don't think it could be the bootloader, talking of Sparkfuns as I haven't used any other, because this problem only started after I ran the 1.6.6 hourly build, as mentioned in the first comment. Why would the IDE and bootloader work harmoniously and then not? That makes me think the way in which the IDE handles the 32u4 port switching is not as it was a while back. |
@ReeceM I tested with official releases: |
USB can introduce many problems. Just because the IDE changed a few things that broke the connection, doesnt mean the real cause is not in the bootloader itself. It just popped up then (maybe!). but it is really more likely that the IDE broke the code, I just dont want to cross out a bad bootloader because it is known to have some major issues that noone is willing to fix (not because its hard to fix, just because of compatibility and not being able to tell users how to update it properly). So here are 4 things we have to keep in mind when dealing with USB Problems:
For example Ive had issues with usb 2 hubs on usb 3 ports. But it was a bootloader bug. And once ago we had a problem with a special linux kernel version. |
I am having the same issue. Windows 10 + Sparkfun 16MHz Pro micro on Arduino IDE 1.6.5. *Update: moved to 1.6.11 and the issue no longer occurred initially. Upon changing code and attempting the upload, I am seeing the same behavior. |
@jsnmc , if you are still experiencing this it means that the serial port is not becoming available in the first two seconds after the end of the upload. This could be caused by:
|
Same problem with Leonardo, but not with Genuine Arduino under Win 10. Sketch uses 7,872 bytes (27%) of program storage space. Maximum is 28,672 bytes. avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
avrdude: ser_open(): can't set com-state for ".\COM5" Board at COM5 is not available
|
I am having a similar problem with my Arduino micro-5V, which I run with windows10, IDE 1.8.2. The micro disconnects during the upload, but then reconnects again. I am having some hardware problems which I suspect are related to this problem. |
I am surprised to see this com port switching or disappearing problem has continued over the years. It just keeps coming back. I see lots of quasi theories. Can't someone provide a comprehensive solution layered on the IDE and/or the USB boot driver.... SOMEDAY!!!! |
My TAU board worked under Win 7. It doesn't under Win 10 (same PC). I note that the filesize of the sounds when the board reset is pressed are 4 or 5 times larger in Win 10 than in Win 7 (the files are located in Windows/media, "Windows Hardware Insert.wav" and "Windows Hardware Remove.wav"). When uploads are initiated, I wonder if these substantial extra delays interfere in the timing required when the port is switched from serial to programming and back again. I've attempted to change these files, but they are protected under "Trusted Installer" permissions that cannot be changed. And they can't be disabled. |
@selligv I don't think it would be the audio that windows plays. The IDE does not trigger the connect and disconnect audio, but rather the windows system. This original problem came up on an XP PC, and I still have issues with it on a mac and a linux machine too. So I don't think this is the fault of the OS, I believe a part of the serial section of the IDE was changed and it has had a knock-on effect causing this issue. |
I really have to apologize.... the problem had to do with my poor programming skills. RabidPrototypes pointed me in a direction I finally understood. I won't explain further for fear of being expelled from this forum. For shame. |
FWIW, I too am having this problem with a Zero-based board in the latest Win10 64-bit, Arduino 1.8.5. The issue doesn't occur in the Arduino 1.8.5 environment on MacOS with the same board, since (probably because of the OS) it always receives the same
It's pretty annoying. :( Does the typical Zero bootloader assign VID, PID, and a serial number? I think those are usually the things that help the OS detect whether two devices are the same or not. |
All boards with Native USB bootloader have this behaviour; this is a consequence of how Windows works, by design. |
We are a new user, have an LP 2Gb/32Gb board with Windows 10, and have the same problem. In an attempt to isolate exactly where the problem is, we built the "blink" example, added Arduino.cs into the project, but in the sub Arduino(port,baud,bool,delay) we forced "serialPortName" to "COM1:". This seemed to work, but only until we powered down. On the next power up, COM1: had disappeared from the list of available serial ports available in Arduino. However, the Win10 device manager showed it as "in use", but as "USB Serial Device". |
I've read the post and understand: " it means that the serial port is not becoming available in the first two seconds after the end of the upload. This could be caused by: drivers taking a lot of time to load properly (if you are on windows)"etc I'm on Windows 10, using a Due and still having this problem in 2018! What is the fix????!!!!!!??? EDIT: I can get it to work. I have a Due. The problem was trying to programme it via the native USB port. The solution (for me) was to programme it via the programme port (Doh!) and then remove the cable and insert it to the native USB port to commence reading from that. It may be obvious but it had me stumped for a few hours. I hope this may help someone else. |
Yes! I have the same thing, and I am using a super fast and powerful Windows PC.... Yet I cannot get a small arduino micro programmed...
Sorry, but I didn't understand what that meant. Perhaps the Due has 2 ports, however the Micro only has the one, so this is still an issue.... |
@wcndave and @DaMicrok I think the Due is not directly related to this as it is a different form factor / programming method of the device. It doesn't have programming and communication over the same ports like the micros which switch between the boot loader on a different usb port and then back to the user's program space. Also I don't believe it is a driver issue, as it won't change if the driver hasn't updated, but rather the software that is making use of said driver. |
okay, well my "same issue" is the same as those that started 3 years ago, on a genuine Micro. |
Ok, let's recap a bit since I've just tested on both a real Windows PC and on a VM with Native USB uploads and they all work on latest IDE. Arduino/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java Lines 128 to 132 in 9818dcf
This is where the upload starts; all affected boards have doTouch set as true .The touch operation is allowed to change the upload port name silently, since the bootloader may appear on a different port. After upload, this is the snippet that restores the serial port name Arduino/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java Lines 205 to 237 in 9818dcf
Bothe If all conditions are true, we wait at least 1 second and then we check if the originally selected upload port has reappeared; we continue checking for 2 more seconds; if it didn't reappear yet, we set What I can see here is:
What can we do:
if (finalUploadPort == null) {
finalUploadPort = actualUploadPort;
} This will affect any further upload while the board is still in bootloader mode. Usually if upload fails there's something deeply wrong so it may not be a very common case.
If we agree on an approach I can prepare a PR with the changes. |
I like this solution. My recent experience with similar native-upload boards is that the post-upload port changes to something new, so I have to switch manually every time. Being able to detect this change automatically would eliminate a big annoyance with the process. |
New behaviour: if upload failed or we are uploading through a "Programming" port (that does not disappear), leave the user selected port selected. if upload succeded and we are using 1200bps touch, wait for the first port that reappears, and if nothing reappears after the timeout select the bootloader port. Fixes #arduino#3495
PR open for testing (as soon as Jenkins produces the builds): #8218 |
@facchinm that is cool, this would be useful that it is fixed after so long 😄 As an aside, version 1.8 on a mac doesbt experience the behaviour that seemed to be present on the windows machine, it seems to stick to one port regardless of the switch between the CDC bootloader and user space program. I presume this fix won't affect that as it will still keep the port either way? |
It's a Windows specific problem, on every other OS the CDC driver takes milliseconds to load, not 5 seconds 😄 |
@facchinm that's funny. Thank you for finding a way to get it working 👍 |
@jrowberg @wcndave @selligv @ReeceM @Breidenbach @Chris-Moir @DaMicrok sorry for the spam, but could you test PR #8218 and report if it solves the problem with port being deselected after upload? Thanks! |
@facchinm Will do 👍 |
Has this been fixed yet as I too am having the same issues. I would like to test it as well |
@PilotinControl25 can you test the IDE build at PR #8218 and report if it solveds your problem? |
Hi @facchinm, I tested the new PR #8212 and it doesn't seem to cause the same issue as before. It was tested on windows 10, unfortunately I don't have access to XP anymore. What I also did is to run 1.8.7 as well to see if the same issue was still there, but it appears that it isn't happening, this may be related to windows 10 only and other versions are still experiencing the issue. I presume the others who have also experienced this issue should have a look too, and possibly state the version they were running when they had the ports not connecting. |
Dunno if this will help, but just want to share a bit of experience from Teensy's long history of native USB. We've seen Windows 7, Vista & XP take much longer to complete USB enumeration depending on how many extra HID interfaces are included together with CDC serial (using IAD, class/subclass/protocol = 254/2/1 in the device descriptor). Years ago I put many long hours into investigating this problem. Using a USB protocol analyzer proved it was just some strange delay in Windows, not any issue where control transfers were being delayed by the device side. The good news is those delays are avoided if you use only CDC (class/subclass/protocol = 2/0/0 in the device descriptor) without any extra HID interfaces. The bad news is the delays become noticeable starting with 2 HID interfaces and really annoying for 3+ HID interfaces, and there seems to be no solution other than upgrading to Windows 8 or 10. |
Thanks @PaulStoffregen that kind of makes sense because I did originally have this issue on XP. I haven't used Arduino on windows since 2016, so I haven't actually had this issue since then. Thanks for giving some info on the reasons 👍 |
New behaviour: if upload failed or we are uploading through a "Programming" port (that does not disappear), leave the user selected port selected. if upload succeded and we are using 1200bps touch, wait for the first port that reappears, and if nothing reappears after the timeout select the bootloader port. Fixes ##3495
Has this ever been tested in a linux vm on a linux host or with usbip? I have yet to get it to upload, Attempted to use udev rules to autoconnect the device back to the host after disconnect and then a script with systemd to auto add the device back to the client machine but failed with timeout so I modified the java file and increased the delays but then got a butterfly programmer error instead of the timeout. In the VM I can't re-attach the device fast enough (QEMU with Libvirt). Anyone have any tips for using 32u4 with Linux VM or USBIP in Linux as well for both server/client? |
Hi @NonaSuomy, I used to have a version of the Arduino IDE running on Ubuntu 12.04 LTS a while back, and was using the 32u4 on that without problems if I can remember properly when I was using it, but I recall I only had this issue on windows when it was opened. I am no quite sure if the issue you are having is related to the vm story or not, but that does sound like quite a bit of a different setup to the normal way it can be implemented and the case when this was first an issue. I think it may be better to open a new issue as it could be related to something else and would also get better attention by the community. This is quite an old issue and discussion, so may not get a response from the actual maintainers. |
Running Arduino IDE on Linux is not an issue, VM / Delays / Reconnects seem to be. It's pretty much similar to the same issue as above except with the addition of extracurricular delays caused by outside influences unbeknownst to the Arduino IDE causing the issue. I've yet to test a regular Arduino with the 2 methods here: http://nonasuomy.github.io/Arduino-Remote-Upload/ The 32u4 with it's special case of the delay way it connects to serial with the IDE seems to be the issue. Maybe having definable delays as an option. If you know it takes X time for USB/IP and Services to reconnect. Instead of hardcoded wait timeouts. I tried to recompile the IDE by manually changing the delays set, but then hit another error about the butterfly programmer failing as I wasn't really sure what I was doing to begin with... trial and error. It found the port again though after massively increasing the delay. Finding this post though helped me find where in the code to change the delays so that's a step forward :) thanks. I'll paste this to another issue to see if anybody has another suggestion. |
Hi @NonaSuomy, okay I am glad that this issue's details helped you start off in a direction of getting somewhere with your problem. There is a timeout option that happens with the avrdude when running in butterfly mode, I don't know where that is set in the IDE's code though, but that may be where it stopped working when you extended the delays. |
When I upload to my Sparkfun pro micro after selecting the port its on, after upload the selected port becomes deselected in the drop down and I can't upload again without going there and re-selecting the com port.
I am using a Hourly build when this happens :
Arduino 1.6.6 Hourly Build 2015/07/07 9:41
But if I use ver. 1.6.0 the serial port stays connected after upload.
Is this a localised problem or am I suffering from beta.
The text was updated successfully, but these errors were encountered: