[en] 115200bps UART for Arduino Uno R3

Update 2015.06.26:
You don’t need this hack to use 115200 baud. Arduino firmware supports baud rate config out of box. I think I misconfigured something and it caused error which I believed firmware error. Just read this as some kind of fail of the week.

Recently, I have to develop firmware runs on Atmel AVR MCU. During prototyping stage, I decided to use Arduino Uno R3 board to speed up development (less soldering/breadboard wiring).

However, Uno R3’s USB (CDC-ACM) to UART converter only supports 9600bps baud. It is terribly slow so I decided to speed it up to 115200bps. I searched web but I could not find some pre-built firmware for ATMEGA16U2 chip which converts USB CDC-ACM to UART. So I decided to patch it and compile it by myself.

Grabbing source code is easy. Since Arduino IDE is open-source application, anyone can git clone its source code. After clonning Arduino IDE repo, I inspected files in hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbserial/ directory and patched Arduino-usbserial.c:L146 and some files. Here is my patch: Arduino-usbserial-115200bps.patch.xz

After that, I issued make command to build project and make complains about missing dependency: LUFA. I read README.txt file in hardware/arduino/avr/firmwares/atmegaxxu2/ and searched LUFA release 100807. Unfortunately, Google closed Google code and I could not find corresponding version of LUFA (My mistake: I missed Show/Hide older release button in http://www.fourwalledcubicle.com/LUFA.php. You can download LUFA 100807 from there.). At first, I dropped LUFA 151115 on requested directory, but it failed to build due to LUFA API difference.

After a while, I found LUFA 100807 on some blog and downloaded it and unzipped it. It compiled and I tried to flash it on my Uno R3 using ISP.

PRE-WARN: DON’T RUN FOLLOWING COMMAND!!!! IT WILL BRICK YOUR DEVICE!!!

At first, I just copy and pasted (replaced hex file to compiled ELF) command from README.txt

DO NOT RUN THIS COMMAND!!!

To burn (Uno):
avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:UNO-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

and It bricked my Arduino Uno. Since Uno R3 uses atmega16u2 but that command mentions at90usb82 and -F flag overrides signature mismatch. So avrdude treated atmega16u2 as at90usb82 and bricked my Uno. So, DON’T USE -F WITHOUT VERIFYING.

After some frustration, I brought spare Uno R3 and flashed it using this command:

avrdude -c stk500 -P /dev/ttyUSB1 -p atmega16u2 -U flash:w:Arduino-usbserial.elf

Now, Arduino can speak UART in 115200bps. Although this hack renders stock Arduino bootloader unusable, it allows much faster UART communication which I wanted.

I’ll attach prebuilt ELF for Arduino Uno R3. If you don’t want to bother with Arduino firmware build environment setup, you may flash this ELF on atmega16u2.

Arduino-usbserial.elf

Note: I think this method can be applied to MegaADK/Mega2560 which uses same chip – ATMEGA16U2 – for USB to UART.

Disclaimer: I’m not responsible to any damage occurred in your Arduino. Use this hack at your own risk!

Leave a Reply

Your email address will not be published. Required fields are marked *