Not all USB cables can flash an MCU? I can't believe my eyes - Page 1
Forum section: electronics / projects

author: analogo
author_rank: Regular Contributor
timestamp: March 13, 2017, 05:28:57 pm
content: I thought all the USB cables where the same. I made fun of audiofools, but now...I received a new NodeMCU board and proceeded to flash it via USB using the Arduino IDE. After a while the flashing process was interrupted. Well, it happens. Let's tray again. Same. Let's just read serial data from another, already flashed board. Garbage. Only after a while I tried a new cable and... it worked.The MCU flashed correctly and the serial output was working just fine. I tried again with the other cable and the old problems reappeared. I could not, and I still can not believe it.I tried all the mirco USB cables I have in my house, from solid data cables to random cables that came with power adapters. Out of 15 only 3 worked reliably.Why? All these USB cables work just fine when I used them to connect to external HDs and other stuff. I can imagine that these MCU dev kits are using chipsets that are flakier than what is used in USB-SATA controller, but still I cannot imagine which part of the cable could make a difference. They are just four wires twisted together, aren't them?What makes the three working USB cables better than others 12 non-flashing cables?

author: DavidDLC
author_rank: Frequent Contributor
timestamp: March 13, 2017, 05:58:37 pm
content: Maybe it is a combination of the board and some cables ?Not necessarily the cables are wrong.David DLC.

author: bktemp
author_rank: Super Contributor
timestamp: March 13, 2017, 06:11:34 pm
content: Most USB problems are due to the voltage drop on the cable for the 5V supply voltage.If you have a scope, you could look at the supply rail on the board. Maybe it drops while flashing (I doubt it draws so much current but that is easy to check).It could also be a bad USB phy implementation with marginal signal integrity but that is more difficult to analyse.Or it could be a cheap or broken USB connector only making a good contact with some cables.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: March 13, 2017, 06:14:23 pm
content: There are a lot of USB cables out there with inadequate power cores. It may also be that something else is so marginal that it's so close to the edge that small cable differences will push it over .

author: Nusa
author_rank: Super Contributor
timestamp: March 13, 2017, 06:17:06 pm
content: You ever looked at how small the wires are on cheap USB cables? Those 3 cables were probably of higher quality. Larger wires, less resistance. Maybe they were the shortest cables as well?My experience is that when flashing NodeMCU, you're right on the edge of what a vanilla computer USB port will provide currentwise. My problems with that went away when I provided external power and only used USB for comms.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 13, 2017, 06:21:48 pm
content: As others have said, most likely a design issue with said "NodeMCU board", not providing enough bulk capacitance needed for the operation with most USB cables. You could try to solder a large (like 470uF or even bigger) electrolytic capacitor right to the 5V input of the board and redo your tests and see how many cables pass.

author: voltsandjolts
author_rank: Unknown
timestamp: March 13, 2017, 07:15:05 pm
content: ^^^What he said.Or maybe a crappy micro-usb socket on the nodeMCU?

author: Fungus
author_rank: Super Contributor
timestamp: March 13, 2017, 07:29:28 pm
content: Try measuring the voltage on the MCU using the different cables. I bet you'll find something.

author: langwadt
author_rank: Super Contributor
timestamp: March 13, 2017, 07:48:53 pm
content: Quote from: Siwastaja on March 13, 2017, 06:21:48 pmthe USB specification specifies a maximum capacitance on Vusb of 10uf to limit inrush current

author: james_s
author_rank: Super Contributor
timestamp: March 13, 2017, 08:47:58 pm
content: I've encountered several USB cables that were either bad or just made with such thin wires that they couldn't power the device I tried plugging in. Now I usually just throw away any that look marginal and use a good quality cable. You need not spend a lot, decent USB cables can be found cheaply.

author: Siwastaja
author_rank: Super Contributor
timestamp: March 13, 2017, 09:11:22 pm
content: Quote from: langwadt on March 13, 2017, 07:48:53 pm10uF is the limit if you just passively connect a capacitor there, but there are cases where 10uF simply is not enough, and I guess this device might be one, requiring quite high pulse currents due to the WLAN transceiver. And btw, this limit, strictly speaking, is not there to limit inrush current - the current can't be limited by limiting the capacitance, so the inrush current itself is OK to begin with.The USB spec does allow larger capacitances in the device, but then you need an inrush limiter circuit (which doesn't need to be too complex, but it's more than just the cap)This kind of a crappy toy device, however, isn't going to follow the relevant standards anyway, it probably doesn't even negotiate for more current; so you can just add the cap and test whether the success rate goes up. A 470uF cap is not going to blow any physical fuses, or damage the hub (at least hopefully - but you always do everything at your own risk, when reading forum advice).

author: HwAoRrDk
author_rank: Super Contributor
timestamp: March 14, 2017, 01:11:15 am
content: I had a similar problem a while ago. A micro USB cable I was using on an AVRISP MkII just suddenly decided one day to give me trouble. This was a cable I'd been successfully using for years, but all of a sudden was dropping too much voltage, because of too much resistance on the wire. Not sure if it suddenly went bad, or had been steadily declining and had reached the point where it was marginal.

author: AlessandroAU
author_rank: Regular Contributor
timestamp: March 14, 2017, 01:17:30 am
content: Those ESP8266 boards often default to the 1Mbit flash rate, I find that sometimes this causes the flashing to flail randomly sometimes, only to work fine when you press the upload button again. I bet if you reduce the flash speed to 115200 all of your cables will work fine.

author: analogo
author_rank: Regular Contributor
timestamp: March 14, 2017, 08:21:44 am
content: Quote from: AlessandroAU on March 14, 2017, 01:17:30 amRandom failures is what I suspected at first, but nope, in this case the cables play an important role. And you lost your bet: I always use 115200.