Problems uploading sketches to Arduino Mega on Windows 10

I'm running into a strange sporadic problem while connecting to multiple genuine Arduino Mega boards (not clones) through VirtualHere and trying to upload a sketch/program to the board. It opens a serial connection, tries to communicate with a bootloader, then uploads the program. Sometimes it works, but most of the time it fails with timeout errors. Strangely enough, this doesn't happen with the Arduino Uno boards that work the same way.

I thought it might be Ethernet or network connection related, but I'm running with very low 1

Another bit of info is that the success rate is much better on the Linux clients than the Windows clients.

Server: (Debian 8.1, amd64, kernel 3.16) [I wasn't sure how to display the exact build]
Client 4.1.7 (Windows 10.0.15063)

I can give reproduction steps if they're useful or detailed output from the IDE that uploads the program. But when I freshly power cycle the board and connect to it, the first upload usually works fine. The second one might timeout on the first attempt but then make it through after that. Then I can have 6 failures in a row where it completely times out, but then the next attempt after that works just fine.

#3

<p>...less than 1ms ping. Usually I start with a freshly power cycled board, then I try uploading one program. Usually it works, but sometimes I'll see a single timeout warning. It may work after the first timeout. But sometimes on the following 5-6 attempts, I can get a complete timeout failure trying to communicate with the board. Then it could work completely fine on the attempt after that.
</p>
<p>Is there anything in logging that I can check that might be useful? Or have you ever seen this kind of problem with serial devices? I can provide more info/reproduction steps if they help.
</p>
<p>The client is 4.1.7 on Windows 10. The server is running on Debian 8.1, kernel 3.16. (I'm not sure how to output the VirtualHere version in CLI mode). Interestingly enough, it doesn't seem to fail as often on a Linux client running on Debian.</p>

#4

Yes ive seen this

I think in windows it is trying to power down the adapter. Can you use the device via VirtualHere then in Windows Device Manager, click View By Connection then go to Virtualhere eXtensible Host Controller and look under there for the device. Then right click Properties -> Power Events and UNcheck Allow the Computer to Turn off this device to save power.

Also you might as well update to client 4.4.0 as well.

#5

Thanks for the idea. For some reason, I didn't have that Power Events option when I right clicked on the Arduino Mega. I tried editing my power policy's advanced settings, USB settings, USB selective suspend setting (changed from enabled to disabled). I didn't see any change.

I did have an option under Device Manager, View Devices by Connection, VirtualHere USB 3 eXtensible Host Controller, Arduino Mega 2560, Port Settings. Under Advanced, I did try changing the buffer settings from their default high settings to low, but it didn't make a difference. Neither did unchecking "Use FIFO buffers", unfortunately.

I also updated to 4.4.0 just to be sure. If there's anything else you can think of, I'll give it a try.

#6

ok, the only other thing i can think of is to update your server to the latest kernel.

3.16 is quite old and the kernel has had a lot of bug fixes since then so you should try something with at least a 4.9 kernel. Sometimes the core hub/hcd infrastructure gets fixes added by kernel developers. Especially parts for SoC USB drivers, if you are using an embedded board as the server.

#7

Windows 10 PC running latest VU 64bit client.

Server is RPi3 running 3.5.3 with unlimited licence.

I can connect to the Arduino fine and see the serial output. However I can't upload sketches, I get various numbers of the following errors:

avrdude: stk500v2_recv(): checksum error
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: verification error, first mismatch at byte 0x0336
0x52 != 0x6c
avrdude: verification error; content mismatch

Sketch will upload fine if I connect directly via USB cable to the Arduino.

#8

RPi is connected via Wi-fi, to my home network (Ubiquiti AP directly above it). PC is on wired ethernet.

#9

Looking at the specs for the arduino mega it shows it uses an ftdi chip that normally works fine with virtualhere as i have a lot of customers who use this chip. Can you send me the /var/log/syslog from the virtualhere server when you try to upload a sketch and it fails. Perhaps its just a reset skip we need to do. Also it should appear as a COM port so double check that the Power Events in Device Manager for that device have UNchecked "Turn off device to save power"

#10

Hi,

I can't find that power option for the USB device, tried by connection and drilling down to the Arduino COM port and all the devices above it in the tree. Can you point me in the right direction?

I ssh'd onto the Rpi (this is your ready to roll flash the SD card version). There is no file /var/log/syslog - in the /var/log folder there are two files "lastlog" and "wtmp". They are both empty. The folder /var/log folder appears to link to to /tmp/log

#11

OK perhaps we can schedule a teamviewer session early next week? I would like to take a look to see if i can fix it. Should only need about 15mins. Let me know a time that suits you. Im in sydney australia GMT+11 mail [at] virtualhere.com (mail[at]virtualhere[dot]com)

#12

Sorry, no luck. I built a new server running Debian 9.1 (amd64), VirtualHere USB Server v3.5.4 (Built: Feb 1 2018, 20:32:40), kernel 4.9.0. I still get the same timeout from the Arduino Mega. Is there anything else that I should try?

#13

During the teamviewer session with Antony Winn we discovered that the serial chip in the Mega is very senstive to variable network latency, if its more than a millisecond it will lock the serial chip. Are you running over wifi or ethernet, it wasnt entirely clear in your posting, if you are running over wifi you need to use ethernet.

#14

Thanks for investigating this, Michael. That seems pretty consistent what I was seeing. I'm using Gigabit Ethernet for both the server and client (and I've tried just about everything I could to reduce the latency). Even talking with some Arduino hardware experts, there doesn't seem to be a way to change the behavior of the serial chip to fix this.

#15

I had some success by setting the Flow control on my PC for the USB port to Hardware or Xon/Xoff. When I say some success, I mean I was able to upload a sketch out 20% of the time.

Not sure how VirtualHere handles flow control or buffering in the server/client components, but it does indicate that there may be a software solution possible.

#16

Para executar o flash altere o campo Upload Speed na aba ferramentas.
No teste que executei utilizando Arduino IDE com "esp8266 D1" tive 100% de eficácia usando Upload Speed de 512000.

#17

Please do NOT write in another language. Only English will be answered