Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Constant disconnects on Windows making development tricky
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Constant disconnects on Windows making development tricky

by BillyTheSheep on Tue Jul 21, 2020 4:58 am

Hi, I'm running into an issue with my new Grand Central board - it is an issue I've had with previous adafruit boards, I figure it's time I asked for help.

On macOS using Arduino IDE, development is a breeze. I leave the device plugged in, make changes to the sketch, press "upload" and the microcontroller will upload, reset, and run the new code all by itself. No need to physically touch anything, I can iterate all day.

On Windows using Arduino IDE, development is way more finicky. Every sketch upload causes the device to be lost, often the microcontroller is put on another port (requiring the port to be re-selected in the port dropdown). In addition, on Windows, each time you write a sketch, the reset button must be multi-clicked, which also can cause Windows to lose the device and the port to be switched again. Sometimes this gets into a cycle where you cannot upload a sketch at all, especially if Windows is cacheing any info about what is connected to ports. Sometimes physically unplugging/plugging the USB gets you back on track, sometimes it does not. And what *really* makes this an untenable workflow is that all of this has to be done with specific timing that you kinda have to muscle-out with trial-and-error.

With the Gemma and the Feather, I was able to develop a routine of muscle-memory that made development on Windows possible, but still irritating. With the Trinket and the Grand Central, I never found the specific timing that allowed a sketch to be uploaded and had to give up (switch to solely work from my macbook).

Am I doing anything wrong? I looked through the forums and found a dozen or so cases of people with the same problems, the ones that resolved (besides a few cases where a charge-only USB cable was being used) *still* ended up requiring a pattern of pressing reset / choosing Port / pressing upload at just the right time to get it working. Has everyone with the option just switched over to macOS when working with these chips? I'm hoping there still something to try.

Additional info / things I have tried:

Windows 10

I've tried swapping the USB cable (make sure it's not charge-only or poor quality)

I've tried USB 2.0 and 3.0 ports, and circumventing my USB hub.

I've tried with and without the adafruit drivers and with and without the older drivers linked in the help center.

Tried on a different Windows machine (also Windows 10 but worth a shot).

I've tried nuking the Arduino install and getting fresh copies of the board/library files.

I've tried several different Adafruit boards.

BillyTheSheep
 
Posts: 6
Joined: Thu Mar 22, 2018 3:33 pm

Re: Constant disconnects on Windows making development trick

by User_UMjT7KxnxP8YN8 on Tue Jul 21, 2020 1:06 pm

Have you updated the bootloader per the pinned post in this forum?

User_UMjT7KxnxP8YN8
 
Posts: 153
Joined: Tue Jul 17, 2018 1:28 pm

Re: Constant disconnects on Windows making development trick

by BillyTheSheep on Tue Jul 21, 2020 1:41 pm

I have not, the Grand Central was shipped very recently, I'm assuming it wasn't part of the bad batch. But I will give it a shot.

However I don't think that's going to resolve it - my other boards are not m4 chips, and suffer the same issue. Also the Grand Central works fine on macOS as is.

BillyTheSheep
 
Posts: 6
Joined: Thu Mar 22, 2018 3:33 pm

Re: Constant disconnects on Windows making development trick

by User_UMjT7KxnxP8YN8 on Tue Jul 21, 2020 3:10 pm

Are you using a hardware debugger?

User_UMjT7KxnxP8YN8
 
Posts: 153
Joined: Tue Jul 17, 2018 1:28 pm

Re: Constant disconnects on Windows making development trick

by BillyTheSheep on Fri Jul 24, 2020 12:26 am

Ok, got more info:

My Grand Central *was* running the older UF2 firmware. However updating it did not fix the issue. It helped slightly, The reliability of uploading a sketch went way up, but I still had to double-click reset and physically unplug / plug in the USB each time.

I am not using a hardware debugger.

Also - while experimenting, I plugged in my Adafruit Metro (the older one, 328, product ID 50). This one worked smoothly! It worked as well on Windows as the other boards worked on macOS! I was able to leave it plugged in, I didn't have to press reset each time, I could just tweak the sketch, and press upload in Arduino IDE, it was lovely.

I am trying to figure out why this is the only board I have from adafruit that works seamlessly on Windows, the only thing I can think is it's the only board I have that predates CircuitPython. Is the CircuitPython support (the ability to show up as a drive when first recognized) messing with the normal workflow of Arduino IDE? (only on Windows, macOS works fine). Is there a way to get a non-CircuitPython UF2 bootloader for these to test that? (I don't use CircuitPython so I would rather have the smooth Windows experience)

BillyTheSheep
 
Posts: 6
Joined: Thu Mar 22, 2018 3:33 pm

Re: Constant disconnects on Windows making development trick

by User_UMjT7KxnxP8YN8 on Fri Jul 24, 2020 1:55 am

First, despite appearances, I don't work for Adafruit; chose the username so I'd remember its for the Adafruit forum. A mistake, in retrospect.

Second, I understand the difference in behavior to be due to the 328 having a dedicated HW UART vs the Metro M4 emulating it in software.

I've had lots of issues too, but managed to find workarounds.

If your code is not surrendering the CPU or is doing lots of heavy-duty serial I/O, you're going to have problems getting the loader to run. I cycle power on my board by unplugging the USB cable from my PC. I bought a USB hub with switches for each port, thinking that would be easier but it doesn't work for some reason.

If you're able to call yield() in your loop, it may help you load a new sketch without hitting the reset button IF the one you currently have loaded hasn't hung somewhere.

The other thing you can do if your code is hanging during development is activate the ATSAMD51's watchdog timer, which automatically reboots the GC's processor if it isn't reset periodically. I've done that and you can find my code at https://github.com/SapientHetero/Watchdog-Timer-for-ATSAMD51J19A. Call wdtInit() in your init() function, and call wdtClear() periodically before it times out. The timeout is currently set to 8.192 secs, but you can change it easily (see the comments in the code).

If you try it and have problems, drop me a note.

User_UMjT7KxnxP8YN8
 
Posts: 153
Joined: Tue Jul 17, 2018 1:28 pm

Re: Constant disconnects on Windows making development trick

by BillyTheSheep on Fri Jul 24, 2020 5:47 pm

Ha! I did assume you were a community mod of some kind, that is humorous.

I definitely appreciate you taking the time to help others out, that is very kind. Even if this doesn't end up getting solved, your input has been very helpful, thank you.

I'm using very simple sketches while trying to pin down the problem - stuff that boils down to:
Serial.println("..");
delay(500);
<loop>

I don't know if delay() surrenders the CPU or not. I will run some experiments with yield() to be sure. But I must say, these simple sketches that trip up the Windows workflow *do* work on macOS. So I'm hesitant to say that is the problem. The issue seems to be in the relationship between the board as a USB device and how Windows handles USB devices. But again, I'll run tests to eliminate other possibilities.

Also to help pin down the issue, I ordered a comparable board from another manufacturer to see if it has the Windows workflow issues.

I will also try an external programmer. Using Arduino as ISP seems like it would run into less issues since the device doesn't need to reset it's connection to Windows every upload. For the Cortex M boards I ordered up a Segger JTAG/SWD. Treading a lot of new ground for me.

BillyTheSheep
 
Posts: 6
Joined: Thu Mar 22, 2018 3:33 pm

Re: Constant disconnects on Windows making development trick

by Saint_Chablo on Fri Jul 24, 2020 10:46 pm

Has this problem been solved yet or not. Im also suffering from the same problems. What i did notice is if i disconnect for like at least 10 mins and reconnect, it works and enters into bootloader mode(green neopixel with red single led). This gave me an opportunity to update the bootloader (3.10 from 3.9) however, it still had those random disconnects. I have no idea why its doing this.

When i first used the board( week ago) it worked really well. BUT now when i used it today on arduino, while i was trying to change the board from my previous work to the grandcentral, even if it was connected, the COM port still was reading my previous board. I tried refreshing arduino and changing cables until the grandcentral completely disconnected (from the windows 10 nose notification and device manager). I tried connecting so many times but nothing worked. So i left it unconnected for 10 mins and it worked for a few mins. I Also managed to upload a code for sensor reading, but within 7 seconds my Grand central completey disconnects (happens all the time). Very weird.

Saint_Chablo
 
Posts: 1
Joined: Sun May 24, 2020 5:27 pm

Re: Constant disconnects on Windows making development trick

by BillyTheSheep on Fri Jul 24, 2020 11:44 pm

No solution yet, but what you are describing is very familiar. Disconnects, port hopping, general intermittent behavior.

I think Windows maybe cacheing port/device data, and waiting eventually clears it? There is an article I haven't tried yet that mentions clearing out the ghost/dead ports. I'm trying to fix the issue before it gets to that point, but if you wanted to take a look https://learn.adafruit.com/how-to-find-hidden-com-ports

It could also be something with the board itself needing to reset, but that seems more like a 20 second discharge, not 10 mins.

I'm still trying to resolve it over here, I'll post if I find something. My goal is a good workflow, not a workaround, I don't want to be constantly unplugging/resetting the board.

BillyTheSheep
 
Posts: 6
Joined: Thu Mar 22, 2018 3:33 pm

Re: Constant disconnects on Windows making development trick

by User_UMjT7KxnxP8YN8 on Sat Jul 25, 2020 11:22 am

I've used both Segger Ozone and Atmel Studio 7 with my J-Link Plus to program my Metro M4 Express. Ozone is really easy to use for downloading sketches, but AS7 is easier when programming a new boot loader.

Note that after you use Ozone to load a sketch and it starts running on your board, Windows won't recognize the board unless you reset it, so the J-Link probably isn't the answer of your dreams. But it DOES consistently upload sketches.

User_UMjT7KxnxP8YN8
 
Posts: 153
Joined: Tue Jul 17, 2018 1:28 pm

Re: Constant disconnects on Windows making development trick

by BillyTheSheep on Mon Jul 27, 2020 1:26 pm

Bittersweet info, as the board works more reliably now, but I do not know what action fixed it.

Info:

- Got another board from a different manufacturer. This board is near-identical to the Grand Central, except it has 2 micro USB ports, one for programming, and one that interfaces directly with the chip. You are supposed to be able to program over both, I believe. The programming port works 100% reliably, like the Metro 328. I'm guessing it has that dedicated HW UART. The other port works finicky, just like the non-metro adafruit boards. I had to unplug/plug/reset/was getting disconnects.

- Then a very strange thing happened when I switched back to the Grand Central board to test yield(). The adafruit board started working every time. No need to plug/unplug, no need to press reset, I just had to click upload and the board would handle everything.

So I am unsure what exactly happened. My best guess is the alternate-manufacturer board pulled down a different driver that doesn't have issues. But I have no idea. I also installed Atmel studio to do some ISP tests, it may have brought in a new driver as well.

Other info bits:

- Documentation says delay() will automatically call yield() within it, so I think my test sketches were already doing that. I cannot test it now as the board is working.

- The Grand Central board isn't quite at 100% reliability, sometimes the first upload disconnects it. But I have found that NOT touching reset, rather switching which computer USB port it is plugged into gets it going back to 100% successful sketch upload state again.

- Programming the chip as "Arduino as ISP" was fun, and I want to do more of that going forward to get off the development boards. I wasn't getting any disconnects on Windows as the programmer stays connected. But now that I have reliability plugging directly in, using a middle-man board seems unnecessary.

I'm hoping the board stays reliable on Windows, and I'm sorry I couldn't pin down more of what the issue was. Thanks everyone, particularly UMjT for their help.

BillyTheSheep
 
Posts: 6
Joined: Thu Mar 22, 2018 3:33 pm

Please be positive and constructive with your questions and comments.