Resetting the Arduino Uno R3 Atmega16U2

It might be easiest to just uninstall macports and install it again. 2.4. Uninstall MacPorts

Make sure running clang from a terminal works before you install it.

hi,
i had kind of the same problem.
my uno r3 stopped responding after setting the baudrate to 14400 and started to create a new serial (/dev/ttyACM*) port with each reset.
i did patch and build the dfu-programmer with the mentioned patch but when it comes to flashing the firmware i get a parsing error:

sudo dfu-programmer atmega16u2 flash unor3.hex
Error parsing the line.
Something went wrong with creating the memory image.
(i renamed the the *.hex for being lazy in the typing area).

uname -a
Linux laptopanatol2 2.6.32-39-generic #86-Ubuntu SMP Mon Feb 13 21:47:32 UTC 2012 i686 GNU/Linux

the lsusb returns a "03eb:2fef Atmel Corp" device (instead of the unnamed 2341:0043 which used to be the arduino)
and dmesg confirms the "full speed USB device"

the erase command with dfu-programmer went just fine and that was the last i heard from the arduino.

any idea if i got the wrong firmware or if the patch went wrong? (the one i used was "Arduino-usbserial-atmega16u2-Uno-Rev3.hex" from the git)

dhunt:

tar xzf ~/Downloads/dfu-programmer-0.5.4.tar.gz

cd dfu-programmer-0.5.4
patch -p0 < ~/Downloads/atmega16u2.diff

Make sure you have the tools needed to build it

sudo apt-get install build-essential libusb-1.0-0-dev

configure and build it

./bootstrap.sh
./configure

bootstrap succeeds, but configure fails with:
./configure: line 3588: syntax error near unexpected token LIBUSB_1_0,' ./configure: line 3588: PKG_CHECK_MODULES(LIBUSB_1_0, libusb-1.0 >= 1.0.0 , have_libusb_1_0=yes, have_libusb_1_0=no)'

This is on Debian 6.
Help?

hodwy,
it seems to me that you have the *dev lib installed but not libusb itself.
just do the sudo apt-get install libusb (don't remember the package name right now but you could use aptitude to search for it)
recompile again and it should go fine

anatolw:
hodwy,
it seems to me that you have the *dev lib installed but not libusb itself.
just do the sudo apt-get install libusb (don't remember the package name right now but you could use aptitude to search for it)
recompile again and it should go fine

That would be weird. Installing the dev lib should install the base lib also. E.g. apt-rdepends output for libusb-1.0-0-dev:
libusb-1.0-0-dev
Depends: libc-dev
Depends: libc6-dev
Depends: libusb-1.0-0 (= 2:1.0.8-4)

I would think it more likely that libusb-1.0-0-dev and libusb-1.0-0 is not installed.

Running "dpkg -l | grep libusb" would be one way to check.

right you are dhunt,
but you never know
it turns out that my *.hex was corrupted
i got the right one now and the flashing went fine
never the less, the arduino, even with the new bootloader, still doesn't respond to the arduino ide.
i've got the /dev/ttyACM0, the ide reports it correctly, but when it comes to uploading i get a java error:

Experimental: JNI_OnLoad called.
Stable Library

Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyACM0
processing.app.SerialException: Error opening serial port '/dev/ttyACM0'.
at processing.app.Serial.(Serial.java:146)
at processing.app.Serial.(Serial.java:91)
at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:204)
at processing.app.Editor.handleSerial(Editor.java:2415)
at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:352)
at java.awt.Component.processMouseEvent(Component.java:6200)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:5968)
at java.awt.Container.processEvent(Container.java:2105)
at java.awt.Component.dispatchEventImpl(Component.java:4564)
at java.awt.Container.dispatchEventImpl(Container.java:2163)
at java.awt.Component.dispatchEvent(Component.java:4390)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4122)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
at java.awt.Container.dispatchEventImpl(Container.java:2149)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4390)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
at java.awt.EventQueue.access$000(EventQueue.java:96)
at java.awt.EventQueue$1.run(EventQueue.java:608)
at java.awt.EventQueue$1.run(EventQueue.java:606)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
at java.awt.EventQueue$2.run(EventQueue.java:622)
at java.awt.EventQueue$2.run(EventQueue.java:620)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171)
at processing.app.Serial.(Serial.java:136)
... 35 more

anyone got an idea?
might it be a mixup between processing and arduino libs?

edit (just a few hours later)
sorry about filling it up
a very strange thing happened with the user permissions
i had to re-add myself to the dialout group to get r/w access to the /dev/ttyACM* and still i have no clue wtf happend.

anatolw:
my uno r3 stopped responding after setting the baudrate to 14400 and started to create a new serial (/dev/ttyACM*) port with each reset.

Last time I looked (about 3 years ago when Teensy started and all Arduino boards were still FTDI), multiple software issues all combined in a terrible way.

1: Linux cdc_acm driver didn't support 14400 and 28800 baud settings.

2: The RXTX library behaves badly when an unsupported baud rate setting is configured.

3: Arduino remembers and applies the old setting before giving you the serial monitor window, and won't accept a new setting after RXTX starts misbehaving.

The net result was choosing either of these baud rates made the board forever inaccessible. The only way to fix it was editing the prefs file to change back to a supported baud rate.

One of the many patches Teensyduino installs is a tiny bit of code which silently turns 14400 into 19200 and 28800 into 38400 if Linux is in use, and a Teensy board is selected. I'd pretty much forgotten about this little problem until now....

Hopefully this explanation helps?

hi there.

have some issue with flashing my mega 2560 R3

this is what i did so far:

http://arduino.cc/forum/index.php/topic,99902.0.html

following @dhunts suggestion

".......

Ah yes, dfu-programmer 0.5.4 does not know about the atmega16u2 and the developers don't seem to have updated it yet.

Download the dfu-programmer source from Atmel USB DFU Programmer download | SourceForge.net, apply the attached patch and build your own:
Code:
tar xzf ~/Downloads/dfu-programmer-0.5.4.tar.gz
cd dfu-programmer-0.5.4
patch -p0 < ~/Downloads/atmega16u2.diff

Make sure you have the tools needed to build it

sudo apt-get install build-essential libusb-1.0-0-dev

configure and build it

./bootstrap.sh
./configure
make

install it

.........."

i get this results

Claudio-Battistas-MacBook-Pro:dfu-programmer-0.5.4 claudiobattista$ sudo apt-get install build-essential libusb-1.0-0-dev
Password:
sudo: apt-get: command not found

what am i missing here?

apt-get is a debian package management tool, so if you're not running a debian-based destroy (like Ubuntu) you'll have to use whatever package manager comes with your distro instead. There should also be a GUI interface tat you can use instead of the command line.

Hi Claudio,

We have managed to get the Chronome firmware to install using Mac OS X 10.6 by doing roughly the following:

Install autoconf tools via macports: sudo port install pkgconfig automake

Install libusb development packages:
sudo port install libusb-devel
and maybe before that
sudo port uninstall libusb
if you have the trouble installing that you did earier.

installing dfu-programmer from source whilst utilising dhunt's patch:

tar xzf ~/Downloads/dfu-programmer-0.5.4.tar.gz
cd dfu-programmer-0.5.4
patch -p0 < ~/Downloads/atmega16u2.diff

# configure and build it
./bootstrap.sh
./configure
make

# install it
sudo make install

now you don't need to run dfd-programmer yourself doing the build of arduino-usbserial will do that for you later but first you need to tweak its makefile so it's looking for your more modern board by editing the following lines in it:

MCU_AVRDUDE = at90usb82                                                       
MCU_DFU = at90usb82

such that they look like:

MCU_AVRDUDE = atmega16u2
MCU_DFU = atmega16u2

and now short the pads to put the arduino in dfu mode and do

sudo make dfu

it should install this time, then install the chronome sw on to it, get serialosc going and you can get on with testing your hardware!

that's probably a fairly hacky way of doing things but it got us going!

hi tristan.

can´t wait to get home to try this out....
will let you know....
thanks in the meanwhile.

so exited.... :sweat_smile:

no luck sofar =( =( =(

still get this error when typing ./configure

...configure: error: cannot run C compiled programs.
If you meant to cross compile, use --host'. See config.log' for more details.

same when i try to instal chronome serialosc. even when trying to instal libconfuse....

thanks.

Claudio-Battistas-MacBook-Pro:~ claudiobattista$ tar xzf ~/Downloads/dfu-programmer-0.5.4.tar
Claudio-Battistas-MacBook-Pro:~ claudiobattista$ cd dfu-programmer-0.5.4
Claudio-Battistas-MacBook-Pro:dfu-programmer-0.5.4 claudiobattista$ patch -p0 < ~/Downloads/atmega16u2.diff
patching file src/arguments.c
patching file src/arguments.h
Claudio-Battistas-MacBook-Pro:dfu-programmer-0.5.4 claudiobattista$ ./bootstrap.sh
Claudio-Battistas-MacBook-Pro:dfu-programmer-0.5.4 claudiobattista$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... m4/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in /Users/claudiobattista/dfu-programmer-0.5.4': configure: error: cannot run C compiled programs. If you meant to cross compile, use --host'.
See `config.log' for more details

i´m running out of ideas.

seems my mainproblem is, this error:

configure: error: cannot run C compiled programs.

it just WON´T let me ./configure

@triss

it´s working like a charm now. the problem was some funny issue with my root permission which didn´t allow me to do some commands in terminal... jus had a little jam with pages and ableton.... :slight_smile:

thanks a ton

after installing dfu programmer and patching
I get this:

cortex:~ nicosteckhan$ sudo dfu-programmer atmega16u2 erase
dfu-programmer 0.5.4
Usage: dfu-programmer target command [command-options] [global-options] [file|data]
targets:
at89c51snd1c
at89c51snd2c
at89c5130
at89c5131
at89c5132
at90usb1287
at90usb1286
at90usb1287-4k
at90usb1286-4k
at90usb647
at90usb646
at90usb162
at90usb82
atmega32u6
atmega32u4
atmega32u2
atmega16u4
atmega8u2
at32uc3a0128
at32uc3a1128
at32uc3a0256
at32uc3a1256
at32uc3a0512
at32uc3a1512
at32uc3a0512es
at32uc3a1512es
at32uc3a364
at32uc3a364s
at32uc3a3128
at32uc3a3128s
at32uc3a3256
at32uc3a3256s
at32uc3b064
at32uc3b164
at32uc3b0128
at32uc3b1128
at32uc3b0256
at32uc3b1256
at32uc3b0256es
at32uc3b1256es
at32uc3b0512
at32uc3b1512
at32uc3c064
at32uc3c0128
at32uc3c0256
at32uc3c0512
at32uc3c164
at32uc3c1128
at32uc3c1256
at32uc3c1512
at32uc3c264
at32uc3c2128
at32uc3c2256
at32uc3c2512
global-options: --quiet, --debug level
commands:
configure {BSB|SBV|SSB|EB|HSB} [--suppress-validation] [global-options] data
dump [global-options]
dump-eeprom [global-options]
dump-user [global-options]
erase [--suppress-validation] [global-options]
flash [--suppress-validation] [--suppress-bootloader-mem] [global-options] {file|STDIN}
flash-eeprom [--suppress-validation] [global-options] {file|STDIN}
flash-user [--suppress-validation] [global-options] {file|STDIN}
get {bootloader-version|ID1|ID2|BSB|SBV|SSB|EB|
manufacturer|family|product-name|
product-revision|HSB} [global-options]
getfuse {LOCK|EPFL|BOOTPROT|BODLEVEL|BODHYST|
BODEN|ISP_BOD_EN|ISP_IO_COND_EN|
ISP_FORCE} [global-options]
setfuse {LOCK|EPFL|BOOTPROT|BODLEVEL|BODHYST|
BODEN|ISP_BOD_EN|ISP_IO_COND_EN|
ISP_FORCE} [global-options] data
reset [global-options]
start [global-options]
version [global-options]
cortex:~ nicosteckhan$

any ideas ?

nsteckhan:
after installing dfu programmer and patching
I get this:

cortex:~ nicosteckhan$ sudo dfu-programmer atmega16u2 erase
dfu-programmer 0.5.4
Usage: dfu-programmer target command [command-options] [global-options] [file|data]
targets:

atmega32u6
atmega32u4
atmega32u2
atmega16u4
atmega8u2

any ideas ?

You should see this in the list of options:

atmega32u6
atmega32u4
atmega32u2
atmega16u4
atmega8u2
atmega16u2 <----- the new target added by the patch

So you're running un-patched dfu-progammer. Either the patch wasn't applied, dfu-programmer didn't build, it's installed in a different location to the existing dfu-programmer executable, or the new dfu-programmer has not been installed.

Try running it directly from your build directory: dfu-programmer-0.5.4/src/dfu-programmer.

Also you shouldn't need to use sudo to run it.

Hi all, please give a step by step processing for DFU methode on arduino uno r3 on snow leopard 10.6.8. I am totally confuse. thanks

I am having some serious with your code...

user@ChrUbuntu:~/dfu-programmer-0.5.4$ sudo make install
Making install in src
make[1]: Entering directory /home/user/dfu-programmer-0.5.4/src' gcc -Wall -g -O2 -I/usr/include/libusb-1.0 -lusb-1.0 -o dfu-programmer main.o arguments.o atmel.o commands.o dfu.o intel_hex.o util.o main.o: In function main':
/home/user/dfu-programmer-0.5.4/src/main.c:58: undefined reference to libusb_init' /home/user/dfu-programmer-0.5.4/src/main.c:108: undefined reference to libusb_release_interface'
/home/user/dfu-programmer-0.5.4/src/main.c:121: undefined reference to libusb_close' /home/user/dfu-programmer-0.5.4/src/main.c:131: undefined reference to libusb_exit'
/home/user/dfu-programmer-0.5.4/src/main.c:79: undefined reference to libusb_set_debug' dfu.o: In function dfu_transfer_out':
/home/user/dfu-programmer-0.5.4/src/dfu.c:836: undefined reference to libusb_control_transfer' /home/user/dfu-programmer-0.5.4/src/dfu.c:836: undefined reference to libusb_control_transfer'
dfu.o: In function dfu_transfer_in': /home/user/dfu-programmer-0.5.4/src/dfu.c:863: undefined reference to libusb_control_transfer'
/home/user/dfu-programmer-0.5.4/src/dfu.c:863: undefined reference to libusb_control_transfer' dfu.o: In function dfu_transfer_out':
/home/user/dfu-programmer-0.5.4/src/dfu.c:836: undefined reference to libusb_control_transfer' dfu.o:/home/user/dfu-programmer-0.5.4/src/dfu.c:863: more undefined references to libusb_control_transfer' follow
dfu.o: In function dfu_device_init': /home/user/dfu-programmer-0.5.4/src/dfu.c:388: undefined reference to libusb_get_device_list'
/home/user/dfu-programmer-0.5.4/src/dfu.c:394: undefined reference to libusb_get_device_descriptor' dfu.o: In function dfu_find_interface':
/home/user/dfu-programmer-0.5.4/src/dfu.c:677: undefined reference to libusb_get_config_descriptor' dfu.o: In function dfu_device_init':
/home/user/dfu-programmer-0.5.4/src/dfu.c:415: undefined reference to libusb_open' /home/user/dfu-programmer-0.5.4/src/dfu.c:417: undefined reference to libusb_set_configuration'
/home/user/dfu-programmer-0.5.4/src/dfu.c:445: undefined reference to libusb_close' /home/user/dfu-programmer-0.5.4/src/dfu.c:451: undefined reference to libusb_free_device_list'
dfu.o: In function dfu_find_interface': /home/user/dfu-programmer-0.5.4/src/dfu.c:716: undefined reference to libusb_free_config_descriptor'
dfu.o: In function dfu_device_init': /home/user/dfu-programmer-0.5.4/src/dfu.c:419: undefined reference to libusb_claim_interface'
/home/user/dfu-programmer-0.5.4/src/dfu.c:436: undefined reference to libusb_release_interface' /home/user/dfu-programmer-0.5.4/src/dfu.c:426: undefined reference to libusb_free_device_list'
dfu.o: In function dfu_make_idle': /home/user/dfu-programmer-0.5.4/src/dfu.c:814: undefined reference to libusb_reset_device'
dfu.o: In function dfu_device_init': /home/user/dfu-programmer-0.5.4/src/dfu.c:431: undefined reference to libusb_free_device_list'
collect2: ld returned 1 exit status
make[1]: *** [dfu-programmer] Error 1
make[1]: Leaving directory `/home/user/dfu-programmer-0.5.4/src'
make: *** [install-recursive] Error 1

Hi
would someone tell me how to implement this code in ubuntu

tar xzf ~/Downloads/dfu-programmer-0.5.4.tar.gz
cd dfu-programmer-0.5.4
patch -p0 < ~/Downloads/atmega16u2.diff

# Make sure you have the tools needed to build it
sudo apt-get install build-essential libusb-1.0-0-dev

# configure and build it
./bootstrap.sh
./configure
make

# install it
sudo make install

Hi there I am trying to do this process for my Arduino Mega 2560 R3. I can get to the patch -p0 < ~/downloads/atmega16u2.diff but thats as far as I get. In terminal I get this message

mr-mojo-risins-imac:dfu-programmer-0.5.4 jbran$ patch -p0 < ~/downloads/atmega16u2.diff
-bash: /Users/jbran/downloads/atmega16u2.diff: No such file or directory

Do I need to download the atmega16u2.diff from somewhere?