Arduino on Debian box - suddenly unable to upload sketch to Uno.

I have encountered a problem using my Uno with my PC, which is a Debian Lenny box. Please let me know if any further information will help diagnose it (I am not sure where to start with details) but here goes:

  1. Installed IDE (version 0021, I think) and plugged in my new Uno. Was able to upload sketches without any problems. Did so for several weeks.

  2. A while later (after upgrading to IDE 0022 in the meantime and some Debian automatic updates which included a kernel update, I think, to 2.6.26-2-686), I found that I suddenly could not upload sketches. I also noticed that the IDE Tools menu was very slow to open, and only one port is available to select (/dev/ttyS0), and when I try to upload a sketch I get

Binary sketch size: 3212 bytes (of a 32256 byte maximum)
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

If I start the IDE as root, I get two ports to choose from , /dev/ttyS0 and /dev/ttyACM0. Uploading to /dev/ttyACM0 responds with

Binary sketch size: 3212 bytes (of a 32256 byte maximum)

and then just sits there, with no error message

I looks like either the IDE upgrade or the kernel update has introduced a problem (although that may be two red herrings) but I am not a Linux expert so I don't quite know where to turn.

Can any one offer any help? Are there any logs, for example, that may offer more information? The other USB devices appear to be working normally - in fact I am temporarily plugging my Uno onto what is usually the printer USB cable, and the printer works fine off it.

TIA

The following commands will gather some information about your system. Run them in a terminal as a normal user (not root) with the Uno plug in and post the result. The avrdude command should be ran in the top directory of wherever you untared arduino-0022

added: checkout post #34 Problems with 0021 on Ubuntu 10.04 Lucid Lynx - #35 by stimmer - Development - Arduino Forum
added: tutorial - Tutorial - How to change firmware on 8u2 - Uno Punto Zero - Arduino Forum

uname -a
dpkg -l openjdkjre|grep ii
dpkg -l gcc-avr|grep ii
dpkg -l avr-libc|grep ii
arduino-0022/hardware/tools/avrdude -v
id
ls -l /dev/ttyACM

Here are the responses:

uname -a

Linux debian 2.6.26-2-686 #1 SMP Thu Jan 27 00:28:05 UTC 2011 i686 GNU/Linux

dpkg -l openjdk*jre|grep ii

ii openjdk-6-jre 6b18-1.8.3-2 OpenJDK Java runtime, using Hotspot JIT

dpkg -l gcc-avr|grep ii

ii gcc-avr 1:4.3.5-1 The GNU C compiler (cross compiler for avr)

dpkg -l avr-libc|grep ii

ii avr-libc 1:1.6.8-2 Standard C library for Atmel AVR development

arduino-0022/hardware/tools/avrdude -v

avrdude: Version 5.4-arduino, compiled on Oct 22 2007 at 13:15:12
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "/usr/local/etc/avrdude.conf"
avrdude: can't open config file "/usr/local/etc/avrdude.conf": No such file or directory
avrdude: error reading system wide configuration file "/usr/local/etc/avrdude.conf"

id

uid=1000(neil) gid=1000(neil) groups=20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),103(scanner),110(netdev),115(powerdev),1000(neil),1002(neilandmolly)

ls -l /dev/ttyACM*

crw-rw---- 1 root dialout 166, 0 2011-02-14 20:35 /dev/ttyACM0

Does that help?

Neil

I've noticed this in the trouble shooting guide:

If, however, you're using the RXTX package from your distribution, you may need to symlink from /dev/ttyACM0 to /dev/ttyUSB0 (for example) so that the serial port appears in the Arduino software.

Is that something that I need to do? If so, how?

More info: if I hold down Shift when I upload a sketch, this is what I see:

Binary sketch size: 3198 bytes (of a 32256 byte maximum)
/media/data_neil/Downloads/arduino/arduino-0022/hardware/tools/avrdude -C/media/data_neil/Downloads/arduino/arduino-0022/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyS0 -b115200 -D -Uflash:w:/tmp/build7241444130185108937.tmp/sos_photo_2.cpp.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 22 2007 at 13:15:12
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "/media/data_neil/Downloads/arduino/arduino-0022/hardware/tools/avrdude.conf"
User configuration file is "/home/neil/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyS0
Using Programmer : stk500v1
Overriding Baud Rate : 115200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: Send: Q [51] [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I would try to update the 8u2 firmware

Can you explain a bit further?

Can you post the verbose output when you try to upload to /dev/ttyACM0 as root?

More info: if I hold down Shift when I upload a sketch, this is what I see:

Was Reply #4 done as root or a normal user?

When I upload to /dev/ttyACM0 as root, there is no response at all. I do get a dialog box inviting me to select a diferent port, ttyS0.

When I carry on and upload to /dev/ttyS0 as root, this is what I get:

Binary sketch size: 990 bytes (of a 32256 byte maximum)
/media/data_neil/Downloads/arduino/arduino-0022/hardware/tools/avrdude -C/media/data_neil/Downloads/arduino/arduino-0022/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyS0 -b115200 -D -Uflash:w:/tmp/build7735780557643392549.tmp/Blink.cpp.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 22 2007 at 13:15:12
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "/media/data_neil/Downloads/arduino/arduino-0022/hardware/tools/avrdude.conf"
User configuration file is "/root/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/ttyS0
Using Programmer : stk500v1
Overriding Baud Rate : 115200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: Send: Q [51] [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

I notice also that if the Arduino is connected, the Tools menu is much slower to appear than when the Arduino is not connected at all.

If nothing else works update the firmware on atmega8u2 chip on the uno:
I did this three times and it works all three times. I used cut & paste

You need the dfu-programmer utility:
sudo apt-get install dfu-programmer

Then follow these instructions to get the Uno into DFU mode. (added) Plug the usb cable into your computer and your Uno board. I did not notice any visual indications if Uno was in DFU mode but when I ran the dfu-programmer erase command I got the following error when Uno was not in dfu mode: dfu-programmer: no device present.

*** Warning Warning ***
Be careful with the second wire as the capacitor is quite near a 5v track. You can try using a low-value resistor instead of a wire if you are worried about blowing up your board.

See picture: picture is good. look closely at picture and then look again closely at picture. Repeat until you are sure you know which wire goes where.

The sequence is, hold the first wire on the top left 8u2 ICSP pad, then touch the second wire against the left side of the capacitor below the RX LED. Then remove both wires .

Then to flash the firmware, do this:
cd arduino-0022/hardware/arduino/firmwares/arduino-usbserial

sudo dfu-programmer at90usb82 erase
note - RX light is on

sudo dfu-programmer at90usb82 flash --debug 9 ./Arduino-usbserial-uno.hex
note - last two lines should say:
Validating...
4058 bytes used (49.54%)

sudo dfu-programmer at90usb82 reset
note RX light is off

Finally unplug the USB plug, wait a minute, plug back in.

start arduino software with blink example sketch

select board as Arduino Uno

select serial port /dev/ttyACM0

upload blink sketch

(added) Thanks to stimmer for the great picture and dfu instructions

Also see the tutorial here: http://arduino.cc/en/Hacking/DFUProgramming8U2

Thanks. It looks a bit scary though. Can I check that I have the latest firmware (or not) before embarking on this?

You probably don't, because I don't think we've started shipping it on new boards yet (we still need to test it thoroughly on all operating systems). But the original firmware was version 0, and the new one is version 1 (which you can see in some programs that show information about connected USB devices). (Note that this is different from the VID/PID.)

Thanks. In the end I took the coward's way out and removed the 0022 IDE, and reverted to the 0021 IDE and that fixed the problem.

Does that means there's a bug in the 0022 IDE, or just that it relies on the firmware being updated in order to work??

with the help of forum's users I've updated the firmware in a few minutes without any pain :wink:
look at comment #4 @ http://arduino.cc/forum/index.php/topic,52447.0.html

Oh no,, it's all gone horribly wrong. I followed these instructions

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

very carefully up to the point

UPLOAD THE NEW FIRMWARE (console commands)

The first upload instruction responded with

dfu-programmer: no device present.

which doesn't look good. Am I being stupid? The UNO was plugged in with the little TX light glowing.

I then tried to verify a simple sketch from the IDE. I got an eror: Cannot run program "avr-gcc" .... NO such file or directory. From this I deduced that my IDE had gone west, so I decided to reinstall it, starting with arduino-core. I went to Synaptic and searched for arduino packages - zilch. I have Lenny installed but there are no arduino packages available, apparently (I checked on the Debian website).

So now what, step by step, do I need to do to restore the situation? The Linux installation instructions on the Arduino website are confusing me.

TIA

dfu-programmer: no device present.

I get same error if the atmega8u2 chip is not in DFU mode

my Uno not in DFU mode:
sudo dfu-programmer at90usb82 erase
[sudo] password for mark:
dfu-programmer: no device present.

Uno in DFU mode. There no output if the command works
sudo dfu-programmer at90usb82 erase

if you have the TX led "always on" when you plug the board to your linux box you should first upload an "empty sketch" into the board. I've used something like:

void setup(){}
void loop(){}

but since you cannot upload sketches from your linux box (because of this bug!) you have to do that from a windows os (mac not tested).