Go Down

Topic: Resetting the Arduino Uno R3 Atmega16U2 (Read 55 times) previous topic - next topic

Paul Stoffregen


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?

monoaural

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 http://sourceforge.net/projects/dfu-programmer/files, 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?

dhunt

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.

triss

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:
Code: [Select]
sudo port install pkgconfig automake

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

installing dfu-programmer from source whilst utilising dhunt's patch:
Code: [Select]

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:
Code: [Select]

MCU_AVRDUDE = at90usb82                                                       
MCU_DFU = at90usb82                                                           

such that they look like:
Code: [Select]

MCU_AVRDUDE = atmega16u2
MCU_DFU = atmega16u2


and now short the pads to put the arduino in dfu mode and do
Code: [Select]
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!

monoaural

hi tristan.

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

so exited....  :smiley-sweat:

monoaural

#20
Apr 20, 2012, 10:16 pm Last Edit: Apr 20, 2012, 11:49 pm by monoaural Reason: 1
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


monoaural

#21
Apr 22, 2012, 07:57 pm Last Edit: Apr 22, 2012, 09:14 pm by monoaural Reason: 1
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




monoaural

@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....  :)

thanks a ton

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:
        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 ?

dhunt


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:
        <snip>
        atmega32u6
        atmega32u4
        atmega32u2
        atmega16u4
        atmega8u2
        <snip>
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.

pukulsesuatu

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

Waza_be

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

anishh2003

Hi
would someone tell me how to implement this code  in ubuntu
Code: [Select]


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


jbrannic

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?

seanfoxen

Hello,

I am attempting to add the patch provided by dhunt but when I type in patch -p0 < ~/Downloads/atmega16u2.diff and run it I receive the following error:

Code: [Select]
Sean-Foxens-MacBook-Pro:dfu-programmer-0.6.2 admin$ patch -p0 < ~/Downloads/atmega16u2.diff
patching file src/arguments.c
Hunk #1 FAILED at 78.
1 out of 1 hunk FAILED -- saving rejects to file src/arguments.c.rej
patching file src/arguments.h
Reversed (or previously applied) patch detected!  Assume -R? [n] r
Apply anyway? [n] y
Hunk #1 FAILED at 57.
1 out of 1 hunk FAILED -- saving rejects to file src/arguments.h.rej


I am working off of MAC OS X Mavericks (10.9), Xcode 5.02 (control tools were added), MacPorts 2.2.1, and dfu-programmer 0.6.2

I did revive an error when I attempted to perform the libusb-devel install
Code: [Select]
Sean-Foxens-MacBook-Pro:~ admin$ sudo port install libusb-devel
--->  Configuring libusb-devel
Error: Please do not install this port since it has been replaced by 'libusb'.
Error: org.macports.configure for port libusb-devel returned:
Please see the log file for port libusb-devel for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_devel_libusb-devel/libusb-devel/main.log
To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
Error: Processing of port libusb-devel failed


Please help, I have been going at this for a few days now and still can not get it right.

Go Up