Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Jan 2016 09:55:02 -0330
From:      "Jonathan Anderson" <jonathan@FreeBSD.org>
To:        freebsd-questions@freebsd.org
Subject:   AVR programming on 11-CURRENT
Message-ID:  <2DCB2502-F0C9-42F6-B1DF-293AE2E098C8@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
Good morning,

I'm attempting to program a Pololu 3pi AVR-based robot [1] using an 
STK500v2-compatible programmer [2] on 11-CURRENT. I'm not having a lot 
of success. I've seen a discussion from 2012 on this list [3], but that 
seems to be a different issue: I'm using the same command lines that 
apparently worked then with no success now.

I've tried using the same avrdude command line as I would use from a 
Linux workstation, but with /dev/ttyACM0 replaced with /dev/cuaU0:

```
$ avrdude -p m328p -c stk500v2 -P /dev/cuaU0 -Uflash:w:assign0.hex:a
```

This command hangs indefinitely. When I enable more verbosity I see:

```
$ avrdude -vvvv -pm328p -c stk500v2 -P /dev/cuaU0 -t

avrdude: Version 6.1, compiled on Oct 24 2015 at 06:47:13
          Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
          Copyright (c) 2007-2014 Joerg Wunsch

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

          Using Port                    : /dev/cuaU0
          Using Programmer              : stk500v2
avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
```

Using trace, I can confirm that the relevant bytes are being written to 
the file descriptor, but then avrdude goes into a loop of `select()`'ing 
the descriptor and reading 0 bytes:

```
8440 avrdude  GIO   fd 2 wrote 65 bytes
        "avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
        "
   8440 avrdude  RET   write 65/0x41
   8440 avrdude  CALL  write(0x3,0x7fffffffdad0,0x7)
   8440 avrdude  GIO   fd 3 wrote 7 bytes
        0x0000 1b01 0001 0e01 14                        |.......|

   8440 avrdude  RET   write 7
   8440 avrdude  CALL  select(0x4,0x7fffffffdae8,0,0,0x7fffffffdb68)
   8440 avrdude  RET   select 1
   8440 avrdude  CALL  read(0x3,0x7fffffffdbef,0x1)
   8440 avrdude  GIO   fd 3 read 0 bytes
        ""
   8440 avrdude  RET   read 0
   8440 avrdude  CALL  select(0x4,0x7fffffffdae8,0,0,0x7fffffffdb68)
   8440 avrdude  RET   select 1
   8440 avrdude  CALL  read(0x3,0x7fffffffdbef,0x1)
   8440 avrdude  GIO   fd 3 read 0 bytes
        ""
```

For reference, here is my dmesg output when I first plug in the 
programmer:

```
ugen2.8: <Pololu Corporation> at usbus2
umodem0: <Pololu Corporation Pololu USB AVR Programmer, class 239/2, rev 
2.00/1.07, addr 8> on usbus2
umodem0: data interface 1, has no CM over data, has no break
umodem1: <Pololu Corporation Pololu USB AVR Programmer, class 239/2, rev 
2.00/1.07, addr 8> on usbus2
umodem1: data interface 3, has no CM over data, has no break
```

After I kill avrdude, the USB device disconnects and re-connects:

```
umodem0: at uhub5, port 3, addr 8 (disconnected)
umodem1: at uhub5, port 3, addr 8 (disconnected)
umodem0: <Pololu Corporation Pololu USB AVR Programmer, class 239/2, rev 
2.00/1.07, addr 8> on usbus2
umodem0: data interface 1, has no CM over data, has no break
umodem1: <Pololu Corporation Pololu USB AVR Programmer, class 239/2, rev 
2.00/1.07, addr 8> on usbus2
umodem1: data interface 3, has no CM over data, has no break
```

Any ideas what might be going wrong here? Does anybody use 11-CURRENT 
with STK500v2-compatible programmers successfully?

Thanks,


Jon

[1] https://www.pololu.com/product/975
[2] https://www.pololu.com/product/1300
[3] http://comments.gmane.org/gmane.os.freebsd.questions/288334

--
Jonathan Anderson
jonathan@FreeBSD.org
From owner-freebsd-questions@freebsd.org  Mon Jan 11 15:44:14 2016
Return-Path: <owner-freebsd-questions@freebsd.org>
Delivered-To: freebsd-questions@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 828C0A6AEE8
 for <freebsd-questions@mailman.ysv.freebsd.org>;
 Mon, 11 Jan 2016 15:44:14 +0000 (UTC)
 (envelope-from wblock@wonkity.com)
Received: from wonkity.com (wonkity.com [67.158.26.137])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (Client CN "wonkity.com", Issuer "wonkity.com" (not verified))
 by mx1.freebsd.org (Postfix) with ESMTPS id 548961554;
 Mon, 11 Jan 2016 15:44:14 +0000 (UTC)
 (envelope-from wblock@wonkity.com)
Received: from wonkity.com (localhost [127.0.0.1])
 by wonkity.com (8.15.2/8.15.2) with ESMTPS id u0BFi6no010851
 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO);
 Mon, 11 Jan 2016 08:44:07 -0700 (MST)
 (envelope-from wblock@wonkity.com)
Received: from localhost (wblock@localhost)
 by wonkity.com (8.15.2/8.15.2/Submit) with ESMTP id u0BFi6aG010848;
 Mon, 11 Jan 2016 08:44:06 -0700 (MST)
 (envelope-from wblock@wonkity.com)
Date: Mon, 11 Jan 2016 08:44:06 -0700 (MST)
From: Warren Block <wblock@wonkity.com>
To: Jonathan Anderson <jonathan@FreeBSD.org>
cc: freebsd-questions@freebsd.org
Subject: Re: AVR programming on 11-CURRENT
In-Reply-To: <2DCB2502-F0C9-42F6-B1DF-293AE2E098C8@FreeBSD.org>
Message-ID: <alpine.BSF.2.20.1601110823410.99930@wonkity.com>
References: <2DCB2502-F0C9-42F6-B1DF-293AE2E098C8@FreeBSD.org>
User-Agent: Alpine 2.20 (BSF 67 2015-01-07)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII; format=flowed
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3
 (wonkity.com [127.0.0.1]); Mon, 11 Jan 2016 08:44:07 -0700 (MST)
X-BeenThere: freebsd-questions@freebsd.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id: User questions <freebsd-questions.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions/>;
List-Post: <mailto:freebsd-questions@freebsd.org>
List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-questions>, 
 <mailto:freebsd-questions-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 11 Jan 2016 15:44:14 -0000

On Mon, 11 Jan 2016, Jonathan Anderson wrote:

> Good morning,
>
> I'm attempting to program a Pololu 3pi AVR-based robot [1] using an 
> STK500v2-compatible programmer [2] on 11-CURRENT. I'm not having a lot of 
> success. I've seen a discussion from 2012 on this list [3], but that seems to 
> be a different issue: I'm using the same command lines that apparently worked 
> then with no success now.
>
> I've tried using the same avrdude command line as I would use from a Linux 
> workstation, but with /dev/ttyACM0 replaced with /dev/cuaU0:
>
> ```
> $ avrdude -p m328p -c stk500v2 -P /dev/cuaU0 -Uflash:w:assign0.hex:a
> ```

Might be worth explicitly setting the baud rate with -b.

> Using trace, I can confirm that the relevant bytes are being written to the 
> file descriptor, but then avrdude goes into a loop of `select()`'ing the 
> descriptor and reading 0 bytes:

Waiting for a response from the programmer, presumably.

> For reference, here is my dmesg output when I first plug in the programmer:
>
> ```
> ugen2.8: <Pololu Corporation> at usbus2
> umodem0: <Pololu Corporation Pololu USB AVR Programmer, class 239/2, rev 
> 2.00/1.07, addr 8> on usbus2
> umodem0: data interface 1, has no CM over data, has no break
> umodem1: <Pololu Corporation Pololu USB AVR Programmer, class 239/2, rev 
> 2.00/1.07, addr 8> on usbus2
> umodem1: data interface 3, has no CM over data, has no break
> ```

The umodem0 and umodem1 are unexpected, but the Pololu website says they 
are a feature of this programmer.

I've successfully used both a homebuilt USBASP and the Arduino-as-ISP 
programmers with various AVRS, but not the STK500v2.  And those were not 
with -CURRENT.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2DCB2502-F0C9-42F6-B1DF-293AE2E098C8>