Introduction: Program ANY Arduino Board When USB Chip Breaks/corrupts.. the Easy Way!!
After accidentally somehow back-feeding power from my triple wide breadboard powered by an old ATX power supply, my 2012 Arduino MEGA2560ADK could no longer be programmed. Tried everything from FLIP trying to reprogram the atmega8u2 via FLIP and the USB, to trying to use a YUN (basically an UNO) to run the ArduinoISP sketch and program the mega that way, to an Adafruit USB Serial Debug converter with just 4 lines (PWR,GND,TX,RX), even tried avrdude command line to upload the hex file to the 8u2 over usb. While i couldn't get avrdude to do anything more than display it's help screen, FLIP was able to flash a similar firmware hex file from within the arduino install directory. Every time after that I tried to upload a revised sketch it would timeout(). So now what? Turns out that I had somehow fried the TX/RX lines I/O circuitry within the 8u2, but the rest of the chip worked OK. It showed up every time in the device manager like it should, it just never flashed the TX/RX leds anymore. I know they work cause i shorted the right side of the leds to ground briefly as a test, they lit up like normal, (following the schematic for the MEGA2560 and the board layout of course). Somehow I had fried only the output part of the 8u2. This took much longer to troubleshoot because the 8u2 did everything else right (device mgr,FLIP.EXE,DFU mode).
Long story, ..long, i guess. I'm right in the thick of finalizing a prototype design using a 16bit LCD touch screen as the only UI and none of the other arduino dev boards I have on hand have that many I/O available. I don't have time to mess with the YUN and making a web UI (would need to get it into AP server mode - don't know how) or using the host USB feature to connect directly to an android phone (none of these apps have all the features I need, don't know android to roll my own USB UI). So now I must find a way to be able t program the MEGA2560 with a semi-fried 8u2 that's basically useless.
Step 1: Locate a Device You Can Hack!
If you're like me, you probably have more than a few MCU boards and USB to Serial converters somewhere in a drawer. Now most of the dev boards i have sitting around don't have a FTDI converter built in (4 Funduino Pro mini, 3 HUZZAH ESP8266, 3 Parallax Propeller proto boards,&now my MEGA 2560 ADK). But there are a few USB Serial converters I do have here (YUN, Adafruit USB to TTL Serial Debug/console cable for Pi, and a Propeller Quickstart board I had gotten a few years ago with FTDI built-in).
Could probably run a sketch on the YUN to pass the TTL serial data to the mega without avrdude trying to program the YUN as a MEGA2560, but even google could not find exactly what I was looking for. The Adafruit debug cable works great for USB Serial Debug to a console like the serial terminal, but you can't program a mega with it only using the TX/RX lines and power. You need at most 5 lines to be able to program nearly ANY arduino!
- Power (optional)
Realizing the Propeller Quickstart had a FTDI chip on board, I located the schematic for it and noticed that nearly all the FTDI lines were broken out to two headers. So since I wasn't using the quickstart board from parallax,I simply desoldered the Parallax P8X32A MCU from the board (in case I need to do some 32 bit parallel processing later) and simply followed the schematic to access the available pins from the FTDI. The available pins from the FTDI on a Quickstart board are:
- TX - connected through a level shifting buffer to 3.3V (TTL compatible)
- DTR(RESET) - toggles an NPN transistor base connected to RESn (works the same)
There are other lines from the chip but they aren't broken out anywhere. For the Arduino purposes we won't need the RTS & CTS lines.
Step 2: Time to Sling Some Solder!
I desoldered the Parallax MCU from the quickstart board using hot air from a cordless butane soldering iron with the hot air tip attached. A heat gun of about 1500W also would have worked but you're melting solder over a fairly larger area than the cordless soldering iron with a hot air tip. ANY kind of torch is not recommended!!!
Soldered some male header strip into the Quickstart board where the FTDI lines are according to the schematic.
Quickstart(or other FTDI) ----------> ANY Arduino
TX(via 3V3 level shifter TTL OK)-->TX
If your board is externally powered and doesn't rely on the USB for power that's all you need!
5V(Vin)---------------------------------->5V(OPTIONAL FOR 5V ARDUINOS)
3V3(if available)----------------------->3v3(OPTIONAL FOR 3V3 ARDUINOS)
Step 3: Programing/Communication With Your Arduino Again.
Here's the easy bit. Whatever you use for a Device Manager (able to view USB connected devices)
- [Windows-Logo]+[R] then in the dialog box type [devmgmt.msc] and hit enter.
- Open a terminal and type [lsusb][ -v][ -t] hit enter and look for the USB Serial Port (same process as installing Arduino IDE & locating your arduino. Instead your looking for just a USB Serial Port, that will usually be your FTDI chip.
- Same as linux above.
You can use the same method described in the setup of the Arduino IDE on how to find your USB Arduino's COM port. Or just google "how to find arduino usb on ______"
In the case of the parallax quickstart boards,they just show up as a USB Serial Port (COM12 in my instance) ONCE the parallax MCU is removed. Just make sure you choose the correct board yoru trying to program from the tools menu as always. Be sure to choose the COM port of the USB Serial Port you just connected and located in your device manager.
Hit upload and you should be back in business!
If you wired everything correctly, your sketch will upload and the serial terminal will work also.