Pages: [1] 2   Go Down
Author Topic: uno rev3 16u2 firmware flashing with dfu-programmer  (Read 5393 times)
0 Members and 1 Guest are viewing this topic.
San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to get my Arduino Uno r3 into DFU mode in order to flash new firmware to it using Macports and DFU programmer.
I want to do this so I can use it as a USB recognized device.

I am using:
Mac OSX Lion v. 10.7.5
dfu-programmer 0.5.4
Arduino Uno R3

I have been following the directions given from this post:

Quote
Title: Re: Resetting the Arduino Uno R3 Atmega16U2
Post by: dhunt on February 19, 2012, 12:27:20 AM
I got the dfu-programmer to build on OSX Lion 10.7.3 with the following steps:

    Install Xcode 4.3 from the Appstore
    Install Xcode command line tools from Xcode preferences (see https://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html (https://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_4_3.html)).
    Tell Xcode where Xcode is installed: sudo xcode-select -switch /Applications/Xcode.app
    Set up a link for the missing clang executable: cd /Applications/Xcode.app/Contents/Developer/usr/bin; sudo ln -s clang llvm-gcc; cd -
    Install macports from http://www.macports.org/ (http://www.macports.org/)
    Install autoconf tools via macports: sudo port install pkgconfig automake
    Install libusb via macports: sudo port install libusb-devel ******this is where I encounter my problem please see below for details**********
    Configure and build dfu-programmer: cd dfu-programmer-0.5.4; ./bootstrap.sh; ./configure; ./make; ./sudo make install


After this you should be pretty much set for building other packages and tools too. You can also search for available packages using the macports search command.

For example:
port search libusb
libusb @1.0.8 (devel)
    library for USB device access

libusb-compat @0.1.3 (devel)
    library for USB device access

libusb-devel @1.0.8.20101017 (devel)
    library for USB device access

libusb-legacy @0.1.12 (devel)
    Library providing access to USB devices

Here is the result of me running: sudo port install libusb-devel
Code:
--->  Configuring libusb-devel
Error: [b]Please do not install this port since it has been replaced by 'libusb'.[/b]
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


Some assorted findings I have made:
The r3 is supposed to enter DFU mode more easily than previous versions of Arduino, but it seems that I may have been better off with an Arduino r2.   I might be encountering problems because the 16u2 chip (which is on the uno r3) is possibly not supported by tools I want to use. (dfu-programmer) However, the 8u2 chip, which is on the uno r1 and r2, is.

The "no device present" was my original error, but after having shorted the pins correctly on my Arduino and no longer being able to see it in the Arduino IDE, I am pretty sure it entered DFU mode correctly.  Maybe it did not? I have never successfully reflashed the 16u2 chip on my Arduino at any point, it still contains its original hex file

I think my main problem is that when I try to install usb-devel I get this error Please do not install this port since it has been replaced by 'libusb'

I've used the following tutorials and sources:

http://arduino.cc/en/Hacking/DFUProgramming8U2
http://mitchtech.net/arduino-usb-hid-keyboard/
http://arduino.cc/forum/index.php?topic=28734.0

A source which has claimed to have updated dfu programmer for r3:
https://code.google.com/p/unojoy/issues/detail?id=1

Thanks so much for any help
« Last Edit: November 25, 2012, 04:58:49 pm by Ender_sD » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

you don't have to compile dfu-programmer because there is a precompiled and patched binary at the googlecode-project you discovered:
https://unojoy.googlecode.com/hg/ATmega8u2Code/HexFiles/dfu-programmer

I attached it to this post for your convenience.


Regards,
nueh

* dfu-programmer.zip (22.21 KB - downloaded 46 times.)
Logged

San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see.  Thank you.

Can I move forward with performing the binary install by looking up steps on how to do that, or do I need to uninstall my current dfu 0.5.4 first?

I'm getting this when I try to run the configure file in the install you attached

Code:
Last login: Mon Nov 26 11:17:43 on ttys000
Adam-Rolphs-iMac-3:~ adamrolph$ /Users/adamrolph/Desktop/OSX-dfu-programmer-binary/dfu_programmer_install_src/dfu-programmer/configure ; exit;
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /Users/adamrolph/Desktop/OSX-dfu-programmer-binary/dfu_programmer_install_src/dfu-programmer/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
configure: error: source directory already configured; run "make distclean" there first
logout

[Process completed]



This is what I got when I ran the executable file
Code:
Last login: Mon Nov 26 11:18:26 on ttys000
Adam-Rolphs-iMac-3:~ adamrolph$ /Users/adamrolph/Desktop/OSX-dfu-programmer-binary/dfu-programmer ; exit;
dyld: Library not loaded: /usr/local/lib/libusb-1.0.0.dylib
  Referenced from: /Users/adamrolph/Desktop/OSX-dfu-programmer-binary/dfu-programmer
  Reason: image not found
Trace/BPT trap: 5
logout

[Process completed]



Thanks for any help.  I just want to be able to flash memory so I can start learning how to code drivers..  setting up the proper workspace in the terminal really has me hung up.
« Last Edit: November 26, 2012, 02:36:15 pm by Ender_sD » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm getting this when I try to run the configure file in the install you attached

I'm not sure what you mean. I didn't attach anything to install, just a plain binary of dfu-programmer.
You can use it by putting it in your $PATH or executing the file with the complete path, e.g.

Code:
Last login: Mon Nov 26 20:39:06 on ttys000
bampf:~ nueh$ /Users/nueh/Downloads/2012-11/dfu-programmer atmega16u2 reset
« Last Edit: November 26, 2012, 02:57:17 pm by nueh » Logged

San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I try to run it with the Arduino plugged in and set to DFU mode I see this:

Code:
Adam-Rolphs-iMac-3:~ adamrolph$ /Users/adamrolph/Downloads/dfu-programmer atmega16u2 reset
dyld: Library not loaded: /usr/local/lib/libusb-1.0.0.dylib
  Referenced from: /Users/adamrolph/Downloads/dfu-programmer
  Reason: image not found
Trace/BPT trap: 5

I'm sorry that my knowledge of the terminal is so limited..  I have learned how to use IDE's at my school but I have never done this before and I am having a lot of trouble.  Your help is very appreciated thank you
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
dyld: Library not loaded: /usr/local/lib/libusb-1.0.0.dylib
  Referenced from: /Users/adamrolph/Downloads/dfu-programmer
  Reason: image not found

Sorry, my mistake!
I didn't realize that this is a dynamically linked binary. You're missing the required library.

I had success compiling all libraries and dfu-programmer itself by using the attached install script.
The package was originally created by Uriah Baalke. I just updated the included dfu-programmer to 0.5.4 and patched it.

Installation:
- In Terminal navigate to your dfu_programmer_install directory.
- Type: ./install_dfu_programmer.sh
- This executes the install.
- You will be prompted for your password. Type in your password.
- If the install is sucessful you should see the dfu-programmer
manual
- press ‘q’ to exit the manual.

Regards
nueh


* dfu_programmer_install.zip (1278.33 KB - downloaded 52 times.)
« Last Edit: November 29, 2012, 04:43:57 pm by nueh » Logged

San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been able to successfully install and patch dfu-programmer now, thanks to the information you've provided.  Thanks.

Unfortunately I'm still having trouble flashing firmware.  When I short the two pins on the ISP header closest to the USB port in order to put the Uno r3 16u2 into DFU mode, the serial port in the native Arduino IDE goes away.  So, I am relatively certain the board is in DFU mode.

However, when I run sudo
Code:
dfu-programmer at90162 erase
I still get the error
Code:
dfu-programmer: no device present.

I have the menu for dfu programmer printing, as well as the menu from Macports, which can be seen here:

Code:
Adam-Rolphs-iMac-3:~ adamrolph$ port search libusb
libusb @1.0.9 (devel)
    library for USB device access

libusb-compat @0.1.4 (devel)
    library for USB device access

libusb-devel @1.0.8.20101017 (devel)
    library for USB device access

libusb-legacy @0.1.12 (devel)
    Library providing access to USB devices

Found 4 ports.

This post by member Stimmer may be helpful to me but I do not know how to run the commands mentioned in it:

Quote
Both dmesg and lsusb should confirm the device mode change. If there's just a reset without a mode change dmesg should confirm that too.

Any help is appreciated thank you.
« Last Edit: December 01, 2012, 06:41:46 pm by Ender_sD » Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the PM. dmesg and lsusb are linux commands, not mac, so that won't be useful to you. I think you are correct that if the serial port has disappeared then it is probably in DFU mode. Unfortunately I know nothing about Mac OSX at all so can't be of any help.
Logged


San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been able to confirm that my Arduino Uno is in DFU mode.  By checking in "About this mac", "System Report", and "USB" I have been able to see the my Arduino recognized in two states, depending on whether or not the pins have been shorted.  (when I short the pins it is no longer recognized as an Arduino, but a different device from "atmega corp")  This means the chip is in DFU programming mode and can have its firmware updated.

I am still having trouble with dfu-programmer though.  The dfu-programmer menu prints out, but when trying to erase the firmware on the Arduino I still get the error
Code:
no device present

I have found a thread where somebody seems to have had the exact same problem I am having, and was able to solve it, but they did not post exactly how they did it.  They just said that they weren't actually running things as a root user and were able to and that solved it for them.

The thread is here: http://arduino.cc/forum/index.php?topic=99902.15

If anybody can make more sense of it than I can I would really appreciate some insights.  I am very discouraged at this point.  All libraries seem to have been installed, the chip is clearly in DFU mode, so I really don't know what else to do, except to uninstall and reinstall all of the tools I have downloaded..

Edit: upon further investigation, I am relatively sure that my issue is that I am running the unpatched version of dfu-programmer from within the terminal, even though there is a patched version on my machine.  Can anybody help me figure out how I would use the patched one over the unpatched one?  Or is this issue even possible? There are like 10 different versions of dfu-programmer on my machine right now.

Thanks for any help
« Last Edit: December 02, 2012, 02:48:04 am by Ender_sD » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure this command is correct?
Quote
dfu-programmer at90162 erase

The UNO R3 uses an Atmega16U2.

Code:
sudo dfu-programmer atmega16u2 erase
Logged

San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I do that, the menu prints back out and the
Code:
no device present
error is gone.  This is awesome, but no matter what combination of erase, reset, or flash (a different hex file) I do, even with the menu printing back after each command, the arduino still functions normally in the Arduino IDE and continues to appear as an Arduino in the port manager after each plug cycle, even though it appears as a "composite device" before I plug cycle it, and after I short the pins. (which would be when I perform the operations via dfu-programmer).  Any ideas?  Thanks for all your help nueh

edit: There is no atmega16u2 option when the menu prints, so when I am entering what you suggested I think the dfu-programmer menu is just reprinting because the terminal is recognizing the first part of the command, which is "dfu-programmer".  I think that the atmega16u2 may not be visible because I am using an unpatched version of dfu-programmer somehow.  Should I attempt to reinstall?
« Last Edit: December 02, 2012, 01:50:20 pm by Ender_sD » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you used the package I provided, dfu-programmer should have been installed to '/usr/local/bin'.
Try to invoke it using the full path:
Code:
sudo /usr/local/bin/dfu-programmer atmega16u2 erase
Logged

San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I downloaded the file you attached to my desktop and ran the .config from there.

This is how I tried to run what you suggested (I wanted to make sure these were directories as I went along):

Code:
Adam-Rolphs-iMac-3:~ adamrolph$ /usr
-bash: /usr: is a directory
Adam-Rolphs-iMac-3:~ adamrolph$ /usr/local
-bash: /usr/local: is a directory
Adam-Rolphs-iMac-3:~ adamrolph$ /usr/local/bin
-bash: /usr/local/bin: is a directory
Adam-Rolphs-iMac-3:~ adamrolph$ /usr/local/bin/dfu-programmer
-bash: /usr/local/bin/dfu-programmer: No such file or directory

Obviously something is wrong there.

But, I took what you said and tried running it from where I think I installed it and this is what I got:

Code:
Adam-Rolphs-iMac-3:~ adamrolph$ /Users/adamrolph/Desktop/DFU/dfu_programmer_install/dfu-programmer
-bash: /Users/adamrolph/Desktop/DFU/dfu_programmer_install/dfu-programmer: is a directory
Adam-Rolphs-iMac-3:~ adamrolph$ sudo /Users/adamrolph/Desktop/DFU/dfu_programmer_install/dfu-programmer atmega16u2 erase
sudo: /Users/adamrolph/Desktop/DFU/dfu_programmer_install/dfu-programmer: command not found


I also tried creating a new directory, redownloading the patch you attached, and installing from there, but after I get to the actual dfu-programmer part of the file directory, it's saying the directory I created doesn't  exist even though I am copy pasting the directory of the newly downloaded dfu-programmer from the "get info" tab
« Last Edit: December 02, 2012, 04:44:57 pm by Ender_sD » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh boy.

Installation:
- In Terminal navigate to your dfu_programmer_install directory.

Not /Users/adamrolph/Desktop/DFU/dfu_programmer_install/dfu-programmer but /Users/adamrolph/Desktop/DFU/dfu_programmer_install

This means type 'cd /Users/adamrolph/Desktop/DFU/dfu_programmer_install'

- Type: ./install_dfu_programmer.sh
Type DOT SLASH install_dfu_programmer.sh

- This executes the install.
- You will be prompted for your password. Type in your password.
- If the install is sucessful you should see the dfu-programmer
manual
- press ‘q’ to exit the manual.

Try to start the program:
/usr/local/bin/dfu-programmer

See if the output contains 'atmega16u2'
Logged

San Diego
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Marathon
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hahaha it worked.  that firmware didn't know what hit it.  ITS GONE.  erased.

Watch me take over the world by creating sick USB interfaces.  PEACE

thank you nueh
Logged

Pages: [1] 2   Go Up
Jump to: