AVR Doper

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

AVR Doper

Post by cordless89 » Sat Jan 20, 2007 7:02 pm

Hello,

I recently built a AVR Doper and I am having problems writing to an AVR. I can read/verify the flash and even read the signature of the chip. But when I try to write the flash, I get an error.

STK500 command line programmer, v 2.2 Atmel Corp (C) 2004-2005.
Connected to STK500 V2 on port com3
Device parameters loaded
Programming mode entered
FLASH input file C:\test.hex read
Programming FLASH... Could not program FLASH
Programming mode left
Connection to STK500 V2 closed
WARNING! One or more operations failed! Please examine the output log above!


Entering programming mode.. OK!
Reading signature .. 0x1E, 0x93, 0x01 .. OK!
Signature matches selected device .. OK
Erasing device.. OK!
Leaving programming mode.. OK!

Reading FLASH input file.. OK
Entering programming mode.. OK!
Programming FLASH .. FAILED!
Leaving programming mode.. OK!


I can write to the AVR with Bascom and a simple parallel cable. But not a thing with the Doper. Any help is appreciated. BTW - Windows XP SP2

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Wed Jan 24, 2007 8:46 pm

This may be due to the somewhat unreliable operation of bulk endpoints. Osamu Tamura maintains a list of hardware/operating system combinations which work or don't work with bulk endpoints. And he has some hints how to improve things. See his project at http://www.recursion.jp/avrcdc/.

Other than that I can recommend avrdude. If it fails, too, you can at least generate a debug log of the failure and maybe that helps debugging the problem.

If you can get a debug log from the STK500 command line programmer, too, please mail it to me.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Wed Jan 24, 2007 9:17 pm

Please forgive my novice attempts at this. I am not very proficient at this in the least but I am willing to try just about anything. I attempted the AVRDUDE but I was unable to to get a patched version that will work on XP to function. I will try avrdude if I can locate a complied version ready to go, as I am sure my capabilities don't go that far. As fas as the debug log, if you tell what to do to get this ready for you, I'll do that also. There has got to be some more in this hobby like me with out the knowlegde and knowhow... :oops: If you can assist me, I am willing. And I do appreciate everyone's help.

Thanks again.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Wed Jan 24, 2007 10:42 pm

If you use AVR-Doper in serial emulation mode, you should not need any patches for avrdude. A binary is included with WinAVR.

To get very verbose debug information with avrdude, use option "-v" multiple times. I don't know how debug info can be obtained from the STK500 command line programmer, though.

You can also get very verbose debug information from AVR-Doper itself (if compiled with debugging enabled), but that's a bit tedious because you need a level converter for RS232 and a terminal emulator.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 12:09 am

I am really unsure as to the correct line parms for avrdoper but here it goes.

Cut and paste starts here ---->

C:\WinAVR\bin>avrdude -p 8515 -c stk500v2 -v -u -U flash:w:test.hex

avrdude: Version 5.3.1, compiled on Jan 1 2007 at 14:25:19
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "C:\WinAVR\bin\avrdude.conf"

Using Port : com3
Using Programmer : stk500v2
AVR Part : AT90S8515
Chip Erase delay : 20000 us
PAGEL : P00
BS2 : P00
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 Max
W ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
eeprom 4 12 128 0 no 512 0 0 4000 90
00 0x80 0x7f
flash 4 12 128 0 no 8192 0 0 4000 90
00 0x7f 0x7f
signature 0 0 0 0 no 3 0 0 0
0 0x00 0x00
fuse 0 0 0 0 no 1 0 0 0
0 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 90
00 0x00 0x00

Programmer Type : STK500V2
Description : Atmel STK500 Version 2.x firmware
Programmer Model: STK500
Hardware Version: 1
Firmware Version: 2.04
Topcard : STK501
Vtarget : 0.8 V
Varef : 0.0 V
Oscillator : 1.229 MHz
SCK period : 2.2 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 1.31s

avrdude: Device signature = 0x1e9301
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: reading input file "test.hex"
avrdude: input file test.hex auto detected as Intel Hex
avrdude: writing flash (384 bytes):

Writing | | 0% 0.00savrdude:
stk500v2_command(): unknown status 0x80
avrdude: stk500v2_paged_write: write command failed
Writing | ################################################## | 100% 0.08s

avrdude: failed to write flash memory, rc=-1

avrdude done. Thank you.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 12:34 am

The previous post was non-HID. This is the HID text --->

C:\WinAVR\bin>avrdud -c stk500v2 -p 8515 -P avrdoper -v -u -U flash:w:test.hex

avrdud: Version 5.3.1, compiled on Jan 10 2007 at 14:17:33
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "C:\WinAVR\bin\avrdude.conf"

Using Port : avrdoper
Using Programmer : stk500v2
AVR Part : AT90S8515
Chip Erase delay : 20000 us
PAGEL : P00
BS2 : P00
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 4 12 128 0 no 512 0 0 4000 900
0 0x80 0x7f
flash 4 12 128 0 no 8192 0 0 4000 900
0 0x7f 0x7f
signature 0 0 0 0 no 3 0 0 0
0 0x00 0x00
fuse 0 0 0 0 no 1 0 0 0
0 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 900
0 0x00 0x00

Programmer Type : STK500V2
Description : Atmel STK500 Version 2.x firmware
Programmer Model: STK500
Hardware Version: 1
Firmware Version: 2.04
Topcard : STK501
Vtarget : 0.8 V
Varef : 0.0 V
Oscillator : 1.229 MHz
SCK period : 2.2 us

avrdud: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 1.36s

avrdud: Device signature = 0x1e9301
avrdud: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdud: erasing chip
avrdud: reading input file "test.hex"
avrdud: input file test.hex auto detected as Intel Hex
avrdud: writing flash (384 bytes):

Writing | | 0% 0.00savrdud: s
tk500v2_command(): unknown status 0x80
avrdud: stk500v2_paged_write: write command failed
Writing | ################################################## | 100% 0.08s

avrdud: failed to write flash memory, rc=-1

avrdud done. Thank you.


Same result. Any ideas now? I'm getting frustrated. :roll: Gotta be something simple I guess.

BTW - I can write to flash via the laptop but it fails verify everytime. But if I write and remove ribbon cable, the programmed AVR does it thing, (simple program to turn a pin on/off) but stops again after I re-plug it. I tried another PC and would write about 1 outa 25-30 tries. Hmmmmmm.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Jan 25, 2007 12:24 pm

The relevant lines here are:
tk500v2_command(): unknown status 0x80
avrdud: stk500v2_paged_write: write command failed

Status code 0x80 means "command timed out".

Did you set the jumper for low speed programming ("Slow SCK" in circuit diagram)? This jumper currently reduces the ISP clock so much that programming an entire page can't be done within the timing limits.

If you need to program a device with 32 kHz crystal, please play around with the "-B" option to avrdude. There is an ISP clock which is slow enough to work with 32 kHz crystals but fast enough to avoid the timeout. But please remember: The -B setting is only used when the "Slow SCK" jumper is open.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 5:19 pm

The test circuit I am trying to program is a 8515 with a 10Mhz crystal. It programs fine with the simple parallel cable.

Any other ideas or things for me to try?

Thanks!

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Jan 25, 2007 5:53 pm

I'm not saying that the clock on your target device is too slow. It's the ISP clock which is probably too slow. You can configure the ISP clock either via the "-B" option to avrdude, through the STK500 programmer or simply with the "Slow SCK" jumper.

My first guess would be that you have set the jumper.

"Command timed out" means that the page or byte was not successfully programmed within the time interval specified by the programming software.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 6:39 pm

in HID mode with ISP jumper on:

C:\WinAVR\bin>avrdud -c stk500v2 -p 8515 -P avrdoper -u -U flash:w:test.hex

avrdud: AVR device initialized and ready to accept instructions

Reading | | 0% 0.00savrdud: a
vrdoper_send(): I/O Error.


And with -B option:

C:\WinAVR\bin>avrdud -c stk500v2 -p 8515 -P avrdoper -v -u -B flash:w:test.hex
avrdud: invalid bit clock period specified 'flash:w:test.hex'


Now what do you suggest? I'll try anything.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Jan 25, 2007 10:09 pm

You can get usage information for avrdude with "avrdude -h".

Which jumper is the ISP jumper? You already reported that it worked in HID mode (at least reading). What's different now?

Please ensure that JP2 (Slow SCK) is open. If you have a scope, please also check that the ISP clock is reasonably high.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 10:56 pm

Basically it does the same, in or out of HID mode. Reads but no write. SlowSCK is open now. If I close that jumper, it programmer fails in HID mode.

I can read the AVR just fine, but it will not write. I do have a scope here but what pin is the ISP clock?

Thanks.

christian
Objective Development
Objective Development
Posts: 1443
Joined: Thu Nov 09, 2006 11:46 am

Post by christian » Thu Jan 25, 2007 10:59 pm

The ISP clock is pin 6 of the 74HC126 or pin 25 of the ATMega8. It will only toggle when the AVR is programmed or read.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 11:03 pm

C:\WinAVR\bin>avrdud -c stk500v2 -p 8515 -P avrdoper -v -u -U flash:w:test.hex

avrdud: Version 5.3.1, compiled on Jan 10 2007 at 14:17:33
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "C:\WinAVR\bin\avrdude.conf"

Using Port : avrdoper
Using Programmer : stk500v2
AVR Part : AT90S8515
Chip Erase delay : 20000 us
PAGEL : P00
BS2 : P00
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 4 12 128 0 no 512 0 0 4000 900
0 0x80 0x7f
flash 4 12 128 0 no 8192 0 0 4000 900
0 0x7f 0x7f
signature 0 0 0 0 no 3 0 0 0
0 0x00 0x00
fuse 0 0 0 0 no 1 0 0 0
0 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 900
0 0x00 0x00

Programmer Type : STK500V2
Description : Atmel STK500 Version 2.x firmware
Programmer Model: STK500
Hardware Version: 1
Firmware Version: 2.04
Topcard : STK501
Vtarget : 2.7 V
Varef : 0.0 V
Oscillator : 1.229 MHz
SCK period : 2.2 us

avrdud: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 1.39s

avrdud: Device signature = 0x1e9301
avrdud: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdud: erasing chip
avrdud: reading input file "test.hex"
avrdud: input file test.hex auto detected as Intel Hex
avrdud: writing flash (384 bytes):

Writing | | 0% 0.00savrdud: s
tk500v2_command(): unknown status 0x80
avrdud: stk500v2_paged_write: write command failed
Writing | ################################################## | 100% 0.09s

avrdud: failed to write flash memory, rc=-1

avrdud done. Thank you.

cordless89
Posts: 17
Joined: Sat Jan 20, 2007 6:55 pm

Post by cordless89 » Thu Jan 25, 2007 11:47 pm

My old Heathkit scope is about to die but the SCK line does go high during the attempts. Now what?

Post Reply