Programming with USBTinyISP
Moderators: adafruit_support_bill, adafruit

Programming with USBTinyISP

by n6rob on Sun Sep 16, 2012 10:02 pm

Hi,

Just built by USBtiny and have successfully loaded the software, etc. on Ubunutu Linux (Natty). The computer recognises the USBtiny and I can probe the attached chip (part ID, fuses, settings, etc).

My objective is to upgrade the firmware in my Ice Tube Clock.

The apparent problem is when I go to download a hex file to my clock the write progress bar freezes (see output below).

I have disabled the jumper for power. I have followed the instructions on the Ice Tube mod webpage (I removed the tube, etc.). I have also tried reading the contents of the flash memory but received the same result. I have tried different hex files. Initially the Ice Tube Clock would beep when powered-up, after the first run it hasn't beeped since. I figure the flash has been erased in preparation for the write.

This is my first time programming a microcontroller, I've read a lot about all this prior to starting. I've check the programmer; the LED indicators work as expected (per instructions), i've double checked the wiring (especially diodes, polarized caps, IC's, etc.). Again the computer-to-programmer interface appears to work just fine. The clock has been working well for just over a year (though it doesn't keep good time, hence the new Ultimate GPS module and USBtiny programmer which should keep it sorted).

Am I missing something? Any suggestions on things I should check? Thank you in advance for any assistance.

OUTPUT FOLLOWS:

rob@tubby:~/Desktop/dec_22_2011$ avrdude -c usbtiny -p m168 -U flash:w:iv.hex -v

avrdude: Version 5.11svn-20111019, compiled on Sep 15 2012 at 21:04:41
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 "/home/rob/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/parport0
Using Programmer : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: 002:013
AVR Part : ATMEGA168
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 512 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 16384 128 128 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : USBtiny
Description : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9406
avrdude: safemode: lfuse reads as E2
avrdude: safemode: hfuse reads as C6
avrdude: safemode: efuse reads as 1
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: Using SCK period of 10 usec
avrdude: reading input file "iv.hex"
avrdude: input file iv.hex auto detected as Intel Hex
avrdude: writing flash (15296 bytes):

Writing | | 0% 0.00s^C
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by adafruit_support_rick on Mon Sep 17, 2012 6:27 am

Have you downloaded a version of avrdude with usbtiny support? See here:
http://www.ladyada.net/make/usbtinyisp/download.html

adafruit_support_rick
 
Posts: 12769
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Programming with USBTinyISP

by adafruit_support_bill on Mon Sep 17, 2012 6:29 am

If you post photos of the front & back of the board we can check it over for any assembly issues. It sounds like it is partially working. You may have some intermittent connection somewhere that is causing it to drop-out in the middle of programming.
User avatar
adafruit_support_bill
 
Posts: 30712
Joined: Sat Feb 07, 2009 10:11 am

Re: Programming with USBTinyISP

by n6rob on Mon Sep 17, 2012 9:51 am

DSC01590.JPG
DSC01590.JPG (814.03 KiB) Viewed 2622 times

DSC01589.JPG
DSC01589.JPG (851.43 KiB) Viewed 2622 times


As the output shows, the avrdude version is 5.11 and it recognizes the USBtiny.

Thank you for your assistance.

EDIT: If it's dropping out due to an intermittent connection, then it is very consistent - it freezes at the same point each time, whether reading the flash or writing to it. When I control-c from avrdude the red LED on USBtiny stays on; so I unplug the USB cable to reset it.
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by adafruit_support_rick on Mon Sep 17, 2012 10:11 am

EDIT: If it's dropping out due to an intermittent connection, then it is very consistent - it freezes at the same point each time, whether reading the flash or writing to it. When I control-c from avrdude the red LED on USBtiny stays on; so I unplug the USB cable to reset it.


Doesn't have to be intermittent - it could simply always be wrong. It seems to be getting through the preliminaries OK, so it could be a data rate issue once it gets to the heavy lifting.

What kind of computer is this? Can you try a different USB port? There have been problems with USB3 ports. Maybe try a powered hub, if you've got one.

You might also try installing R4 and R7in the USBTiny.

Does the USBTiny show up as anything else besides /dev/parport0?

adafruit_support_rick
 
Posts: 12769
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Programming with USBTinyISP

by n6rob on Mon Sep 17, 2012 10:53 am

I've been over the solder joints a few times with a loupe and I've reflowed some of them; no joy. I've checked the programming cables and I've inspected the board on the Ice Tube Clock.

Unfortunately I don't have another micro controller device to test with; so I cannot eliminate the clock as a culprit. But I have inspected it the header solder joints and inspected the board (the ISP in the clock is just a header that connects to the micro controller).

I built the PC myself so it's a little complicated to tell you what kind it is, specifically. It's a run-of-the mill i3 core i386 platform (not 64-bit) Sandy Bridge chip set (if I remember correctly). The USB ports are 2.0, not 3.

I don't have a powered hub, but I might dig around and see what I can find.

Does the USBTiny show up as anything else besides /dev/parport0?


I noticed the output says that (/dev/parport0), but yet avrdude is clearly talking to the USB port, per the rest of it's output. I haven't messed around with the config file and I don't know why it says /dev/parport0. Checking the kernel log, the computer recognizes the USBtiny as a USB device:

"Sep 17 07:46:48 tubby kernel: [ 4370.409828] usb 2-1.6: new low speed USB device using ehci_hcd and address 6"

As far as I know there the USBtiny shows up as only a USB device; there are no other references in the log. BTW: I've installed the rule in the udev file to enact permissions; no issues there.

I guess I can try the resistors; I am disappointed to have to hack it, but I guess there's not much left to try. Could the micro in the USBtiny be having a problem?
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by n6rob on Mon Sep 17, 2012 12:05 pm

I've installed the two resistors (R4 and R7, each 1.5K ohms) and tested it again. This time we get the initialization failed message. Previously it would just hang when trying to read or write to the flash (the progress bar would stop at 0% complete). This time it can't initialize. I have confirmed the kernel log recognizes the USBtin on the port:

"Sep 17 09:00:19 tubby kernel: [ 8780.334146] usb 2-1.6: new low speed USB device using ehci_hcd and address 8"

OUTPUT:

rob@tubby:~/Desktop/july_27_2012$ avrdude -c usbtiny -p m168 -U flash:w:iv.hex -v

avrdude: Version 5.11svn-20111019, compiled on Sep 15 2012 at 21:04:41
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 "/home/rob/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/parport0
Using Programmer : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: 002:007
AVR Part : ATMEGA168
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 512 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 16384 128 128 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : USBtiny
Description : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.


avrdude done. Thank you.
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by adafruit_support_rick on Mon Sep 17, 2012 2:58 pm

Do you have another computer you could try? Windows, Mac?

adafruit_support_rick
 
Posts: 12769
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Programming with USBTinyISP

by n6rob on Mon Sep 17, 2012 9:30 pm

No, I don't have access to another computer for this type of work.

I am suspicious of the microcontroller in the USBtiny; is there some way to "re-burn" it or verify that it's working properly?
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by n6rob on Mon Sep 17, 2012 11:07 pm

I am going to find/buy a hub and try it - though it seems like a stretch to me. I've used used these USB ports for a variety of things without trouble and they seem to talk to the USBtiny's micro controller chip just fine (before I added the resistors) . I think I will take the resistors back out; it seemed like a step backwards.

Did anyone have a comment on the photos?

Are there diagnostics that I can look for on the USBtiny microcontroller? I have an oscilloscope and could check for various levels at each of the pins, that is if I knew what to look for. :D
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by n6rob on Tue Sep 18, 2012 12:39 am

I've put a power USB hub in-between the USBtiny and the computer; the results are the same. I've tried it with, and without, R4 & R7. Now it won't talk to the Ice Tube Clock board at all.

I've run it with sudo as well, just in case my udev rule didn't work. No joy.

I get the initialization error with, or without the clock board connected, with, or without the resistors. I've tested the USB cable on another device and it works (it's a decent quality, Belkin).

I haven't fired-up my clock with the tube, but like I said it stopped beeping right after the first attempt. I would guess the firmware in the clock has been wasted.

Any other suggestions?
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by adafruit_support_rick on Tue Sep 18, 2012 11:43 am

Your build looks fine. I'm running out of ideas. Would you have any way to pull the 168 out of the clock and program it separately?

adafruit_support_rick
 
Posts: 12769
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Programming with USBTinyISP

by n6rob on Tue Sep 18, 2012 1:00 pm

Uhmmm, do you mean like putting it in a breadboard? Sure, I have a breadboard and stand-alone power supply. I can do that; but you'll need to hold my hand a bit. Maybe you can point me to a schematic?

Any game with the oscilloscope? I was thinking if I could look for outputs under certain conditions that maybe I could trace the source of the problem. I still have my money on the microcontroller.

Also, I meant to run a continuity check on the 6-pin programming cable - though that's probably not useful, I get the same results with our without it connected to the clock.

At this point, I guess I'll buy another programmed ATtiny2313 for $4; I've got $22 in the programmer, $40 in the GPS, and $22 in the powered hub. I wanted to buy some other stuff anyway.
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA

Re: Programming with USBTinyISP

by adafruit_support_rick on Tue Sep 18, 2012 5:04 pm

Evil Mad Scientist has a good tutorial on bare-bones programming. Essentially, you just hook up the power, ground, and SPI pins from the USBTiny to the corresponding pins on the 168. The tutorial shows a protoboard and a ZIF socket, but you can just use a breadboard.

Someone here wondered if you were running as root?
Last edited by adafruit_support_rick on Tue Sep 18, 2012 5:05 pm, edited 1 time in total.
Reason: D'Oh! Forgot to paste the link!

adafruit_support_rick
 
Posts: 12769
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Programming with USBTinyISP

by n6rob on Tue Sep 18, 2012 5:40 pm

Okay, I'll give it a shot tonight when I get home.

Regarding root:
I've run it with sudo as well, just in case my udev rule didn't work. No joy.


But I am still suspicious it's the microcontroller.
n6rob
 
Posts: 18
Joined: Sun Sep 16, 2012 9:39 pm
Location: Silicon Valley, California, USA



cron