Bug 149283 - [uftdi] avrdude unable to talk to Arduino board (via uftdi)
Summary: [uftdi] avrdude unable to talk to Arduino board (via uftdi)
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 9.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-04 17:30 UTC by Marcin Cieślak
Modified: 2015-08-10 19:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcin Cieślak 2010-08-04 17:30:09 UTC
Any attempt to contact the board using avrdude fails.
Checked with the same hardware (dual-boot) and Microsoft
Vista (with arduino-0018 IDE) and the board can be
contacted and programmed without any problems.

Syslog with:
hw.usb.ucom.debug: 15
hw.usb.uftdi.debug: 15

avrdude -c arduino -p m328p -P /dev/cuaU0 

Aug  4 18:10:04 radziecki saper: Connecting board
Aug  4 18:10:07 radziecki kernel: ugen4.3: <FTDI> at usbus4
Aug  4 18:10:07 radziecki kernel: uftdi0: <FT232R USB UART> on usbus4
Aug  4 18:10:07 radziecki kernel: uftdi_attach: 
Aug  4 18:10:07 radziecki kernel: ucom_attach_tty: tp = 0xffffff0003cd8400, unit = 0
Aug  4 18:10:07 radziecki kernel: ucom_attach_tty: ttycreate: U0
Aug  4 18:10:07 radziecki kernel: ucom_open: tp = 0xffffff0003cd8400
Aug  4 18:10:07 radziecki kernel: ucom_dtr: onoff = 1
Aug  4 18:10:07 radziecki kernel: ucom_line_state: on=0x01, off=0x00
Aug  4 18:10:07 radziecki kernel: ucom_rts: onoff = 1
Aug  4 18:10:07 radziecki kernel: ucom_line_state: on=0x02, off=0x00
Aug  4 18:10:07 radziecki kernel: ucom_ring: onoff = 0
Aug  4 18:10:07 radziecki kernel: ucom_line_state: on=0x00, off=0x08
Aug  4 18:10:07 radziecki kernel: ucom_break: onoff = 0
Aug  4 18:10:07 radziecki kernel: ucom_line_state: on=0x00, off=0x04
Aug  4 18:10:07 radziecki kernel: ucom_param: sc = 0xffffff0003cd9458
Aug  4 18:10:07 radziecki kernel: uftdi_pre_param: 
Aug  4 18:10:07 radziecki kernel: ucom_cfg_open: 
Aug  4 18:10:07 radziecki kernel: uftdi_cfg_open: uftdi_cfg_param: 
Aug  4 18:10:46 radziecki saper: Starting avrdude
Aug  4 18:10:48 radziecki kernel: ucom_param: sc = 0xffffff0003cd9458
Aug  4 18:10:48 radziecki kernel: uftdi_pre_param: 
Aug  4 18:10:48 radziecki kernel: ucom_dtr: onoff = 1
Aug  4 18:10:48 radziecki kernel: ucom_line_state: on=0x01, off=0x00
Aug  4 18:10:48 radziecki kernel: ucom_rts: onoff = 1
Aug  4 18:10:48 radziecki kernel: ucom_line_state: on=0x02, off=0x00
Aug  4 18:10:48 radziecki kernel: uftdi_cfg_param: 
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x402c7413
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x402c7413
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x802c7414
Aug  4 18:10:48 radziecki kernel: ucom_param: sc = 0xffffff0003cd9458
Aug  4 18:10:48 radziecki kernel: uftdi_pre_param: 
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x8004667e
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x8004667d
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x4004746a
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x8004746d
Aug  4 18:10:48 radziecki kernel: ucom_dtr: onoff = 1
Aug  4 18:10:48 radziecki kernel: ucom_line_state: on=0x01, off=0x00
Aug  4 18:10:48 radziecki kernel: ucom_rts: onoff = 1
Aug  4 18:10:48 radziecki kernel: ucom_line_state: on=0x02, off=0x00
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x4004746a
Aug  4 18:10:48 radziecki kernel: ucom_ioctl: cmd = 0x8004746d
Aug  4 18:10:48 radziecki kernel: ucom_dtr: onoff = 0
Aug  4 18:10:48 radziecki kernel: ucom_line_state: on=0x00, off=0x01
Aug  4 18:10:48 radziecki kernel: ucom_rts: onoff = 0
Aug  4 18:10:48 radziecki kernel: ucom_line_state: on=0x00, off=0x02
Aug  4 18:10:48 radziecki kernel: uftdi_cfg_param: 
Aug  4 18:10:48 radziecki kernel: ucom_outwakeup: sc = 0xffffff0003cd9458
Aug  4 18:10:48 radziecki last message repeated 2 times
Aug  4 18:10:53 radziecki kernel: ucom_ioctl: cmd = 0x4004746a
Aug  4 18:10:53 radziecki kernel: ucom_ioctl: cmd = 0x8004746d
Aug  4 18:10:53 radziecki kernel: ucom_dtr: onoff = 1
Aug  4 18:10:53 radziecki kernel: ucom_line_state: on=0x01, off=0x00
Aug  4 18:10:53 radziecki kernel: ucom_rts: onoff = 1
Aug  4 18:10:53 radziecki kernel: ucom_line_state: on=0x02, off=0x00
Aug  4 18:10:53 radziecki kernel: ucom_ioctl: cmd = 0x802c7415
Aug  4 18:10:53 radziecki kernel: ucom_outwakeup: sc = 0xffffff0003cd9458
Aug  4 18:10:56 radziecki saper: avrdude timeout
Aug  4 18:11:18 radziecki saper: Sending INTR to avrdude
Aug  4 18:11:19 radziecki kernel: ucom_outwakeup: sc = 0xffffff0003cd9458
Aug  4 18:11:23 radziecki kernel: ucom_close: tp=0xffffff0003cd8400
Aug  4 18:11:23 radziecki kernel: ucom_shutdown: 
Aug  4 18:11:23 radziecki kernel: ucom_cfg_close: 
Aug  4 18:11:33 radziecki saper: avrdude ended
Aug  4 18:11:41 radziecki saper: Disconnecting board
Aug  4 18:11:44 radziecki kernel: ugen4.3: <FTDI> at usbus4 (disconnected)
Aug  4 18:11:44 radziecki kernel: uftdi0: at uhub5, port 3, addr 3 (disconnected)
Aug  4 18:11:44 radziecki kernel: ucom_detach_tty: sc = 0xffffff0003cd9458, tp = 0xffffff0003cd8400
Aug  4 18:11:44 radziecki kernel: ucom_close: tp=0xffffff0003cd8400
Aug  4 18:11:44 radziecki kernel: ucom_close: tp=0xffffff0003cd8400 already closed
Aug  4 18:11:44 radziecki kernel: ucom_close: tp=0xffffff0003cd8400
Aug  4 18:11:44 radziecki kernel: ucom_close: tp=0xffffff0003cd8400 already closed
Aug  4 18:11:55 radziecki saper: Board disconnected

How-To-Repeat: 
Use command: 

# avrdude -c arduino -p m328p -P /dev/cuaU0 -v

avrdude: Version 5.10, compiled on Aug  3 2010 at 23:59:35
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/local/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cuaU0
         Using Programmer              : arduino
avrdude: stk500_recv(): programmer is not responding

At the time the timeout message comes out Arduino's bootloader LED
blinks once indicating firmware restart.
Comment 1 Hans Petter Selasky 2010-08-04 17:39:30 UTC
Hi,

What happens if you use "-P usb" ?

--HPS
Comment 2 Marcin Cieślak 2010-08-04 18:18:29 UTC
> What happens if you use "-P usb" ?

# ldd /usr/local/bin/avrdude 
/usr/local/bin/avrdude:
 	libusb.so.2 => /usr/lib/libusb.so.2 (0x80068e000)
 	libm.so.5 => /lib/libm.so.5 (0x80079c000)
 	libreadline.so.8 => /lib/libreadline.so.8 (0x8008bb000)
 	libncurses.so.5.7 => /usr/local/lib/libncurses.so.5.7 (0x8009f7000)
 	libncurses.so.8 => /lib/libncurses.so.8 (0x800b14000)
 	libc.so.7 => /lib/libc.so.7 (0x800c5e000)
 	libtinfo.so.5.7 => /usr/local/lib/libtinfo.so.5.7 (0x800e91000)
# avrdude -c arduino -p m328p -P usb -v

avrdude: Version 5.10, compiled on Aug  3 2010 at 23:59:35
          Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
          Copyright (c) 2007-2009 Joerg Wunsch

          System wide configuration file is "/usr/local/etc/avrdude.conf"
          User configuration file is "/root/.avrduderc"
          User configuration file does not exist or is not a regular file, skipping

          Using Port                    : usb
          Using Programmer              : arduino
avrdude: ser_open(): can't open device "usb": No such file or directory

--Marcin
Comment 3 Joerg Wunsch 2010-08-04 19:14:29 UTC
As Marcin Cieslak wrote:

> Checked with the same hardware (dual-boot) and Microsoft
> Vista (with arduino-0018 IDE) and the board can be
> contacted and programmed without any problems.

Your check on Windows has been using a stock AVRDUDE (e.g., a WinAVR
compilation), too?  Or another tool?

IIRC, the Arduino bootloader requires some special tricks in order to
talk to it.  I think AVRDUDE v5.10 still lacks that feature.  Could
you try the SVN version of AVRDUDE?

(I don't see a GNATS ID in the subject.  Has this been actually filed
via send-pr?)

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Comment 4 Hans Petter Selasky 2010-08-04 19:33:46 UTC
I think you need to define one more parameter when using USB.

-t stk600

--HPS
Comment 5 Joerg Wunsch 2010-08-04 20:07:37 UTC
As Hans Petter Selasky wrote:

> I think you need to define one more parameter when using USB.

The Arduino bootloader is /not/ an USB device from AVRDUDE's
point of view.  AVRDUDE wants to see it as a generic tty device
(/dev/cua*).
-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Comment 6 Hans Petter Selasky 2010-08-04 20:29:01 UTC
On Wednesday 04 August 2010 21:07:37 Joerg Wunsch wrote:
> As Hans Petter Selasky wrote:
> > I think you need to define one more parameter when using USB.
> 
> The Arduino bootloader is /not/ an USB device from AVRDUDE's
> point of view.  AVRDUDE wants to see it as a generic tty device
> (/dev/cua*).

And what USB protocol is it running? If raw, then the ID should be added to 
the ugensa driver instead.

--HPS
Comment 7 Joerg Wunsch 2010-08-04 20:44:20 UTC
As Hans Petter Selasky wrote:

> > AVRDUDE wants to see it as a generic tty device
> > (/dev/cua*).
> 
> And what USB protocol is it running?

Whatever is hidden behind a /dev/cua*. ;-)  I suppose it's CDC.

AVRDUDE simply doesn't want to know that.  Those programmers where
AVRDUDE accepts a -P usb option are programmers where AVRDUDE talks
directly to using an application-specific protocol.  For all other
programmers, the parameter to -P must be a device node under /dev.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
Comment 8 Marcin Cieślak 2010-08-04 21:21:32 UTC
On Wed, 4 Aug 2010, Joerg Wunsch wrote:

> As Marcin Cieslak wrote:
>
>> Checked with the same hardware (dual-boot) and Microsoft
>> Vista (with arduino-0018 IDE) and the board can be
>> contacted and programmed without any problems.
>
> Your check on Windows has been using a stock AVRDUDE (e.g., a WinAVR
> compilation), too?  Or another tool?

On Windows I have used arduino Java IDE. Arduino IDE distribution
actually includes a whole WinAVR stack including avrdude.exe,
but I didn't pay attention what is actually used.
I will reboot to Windows now and check the commandline invocation.

On FreeBSD arduino the Java IDE tries to use avrdude and fails the same
was as from commandline.

> IIRC, the Arduino bootloader requires some special tricks in order to
> talk to it.  I think AVRDUDE v5.10 still lacks that feature.  Could
> you try the SVN version of AVRDUDE?

AVRDUDE is mentioned for example here http://www.arduino.cc/playground/FreeBSD/CLI
as the tool to use.

I have tried "-c arduino" or "-c stk500v1" with trunk and I get still
the same affect as with 5.10 (Programmer timeout).

What maybe important: TX/RX LED on the board don't react at all
when trying to use avrdude (there is only a single blink
on firmware LED - which means bootloader start).

With Windows - TX/RX indicated clearly some activity.

> (I don't see a GNATS ID in the subject.  Has this been actually filed
> via send-pr?)

Hm, yes, sorry... You were copied on the original send-pr.

--Marcin
Comment 9 Hans Petter Selasky 2010-08-04 21:53:39 UTC
On Wednesday 04 August 2010 22:21:32 Marcin Cieslak wrote:
> On Wed, 4 Aug 2010, Joerg Wunsch wrote:
> > As Marcin Cieslak wrote:
> >> Checked with the same hardware (dual-boot) and Microsoft
> >> Vista (with arduino-0018 IDE) and the board can be
> >> contacted and programmed without any problems.
> > 
> > Your check on Windows has been using a stock AVRDUDE (e.g., a WinAVR
> > compilation), too?  Or another tool?
> 
> On Windows I have used arduino Java IDE. Arduino IDE distribution
> actually includes a whole WinAVR stack including avrdude.exe,
> but I didn't pay attention what is actually used.
> I will reboot to Windows now and check the commandline invocation.
> 
> On FreeBSD arduino the Java IDE tries to use avrdude and fails the same
> was as from commandline.
> 
> > IIRC, the Arduino bootloader requires some special tricks in order to
> > talk to it.  I think AVRDUDE v5.10 still lacks that feature.  Could
> > you try the SVN version of AVRDUDE?
> 
> AVRDUDE is mentioned for example here
> http://www.arduino.cc/playground/FreeBSD/CLI as the tool to use.
> 
> I have tried "-c arduino" or "-c stk500v1" with trunk and I get still
> the same affect as with 5.10 (Programmer timeout).
> 
> What maybe important: TX/RX LED on the board don't react at all
> when trying to use avrdude (there is only a single blink
> on firmware LED - which means bootloader start).
> 
> With Windows - TX/RX indicated clearly some activity.
> 
> > (I don't see a GNATS ID in the subject.  Has this been actually filed
> > via send-pr?)
> 

You can try to comment out:

        /* clear stall at first run */
        mtx_lock(&sc->sc_mtx);
        usbd_xfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_WR]);
        usbd_xfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_RD]);
        mtx_unlock(&sc->sc_mtx);

In uftdi_attach in sys/dev/usb/serial/uftdi.c.

--HPS
Comment 10 Warren Block 2010-08-04 21:57:44 UTC
Steven Kreuzer and I had that type of problem when working on the 
devel/arduino port, but eventually ironed them out (AFAIK).

If you install the port and set build.verbose=true and 
upload.verbose=true in ~/.arduino/preferences.txt, you should be able to 
see what options it uses.  My hunch is a 19200 or 57600 baud rate, but I 
can't swear to that, and it's been some time since I tried it.
Comment 11 Marcin Cieślak 2010-08-05 10:35:10 UTC
On Wed, 4 Aug 2010, Hans Petter Selasky wrote:

> You can try to comment out:
>
>        /* clear stall at first run */
>        mtx_lock(&sc->sc_mtx);
>        usbd_xfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_WR]);
>        usbd_xfer_set_stall(sc->sc_xfer[UFTDI_BULK_DT_RD]);
>        mtx_unlock(&sc->sc_mtx);
>
> In uftdi_attach in sys/dev/usb/serial/uftdi.c.

That did not fix it ...

--Marcin
Comment 12 Marcin Cieślak 2010-08-10 16:15:58 UTC
The problem got solved. I got:

hw.usb.ucom.cons_unit=0

Resetting this value to -1 enabled the communication.

The problem was because ucom_get_data() didn't fetch
user-supplied data.

Please close this PR.

--Marcin