[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avrdude-dev] avrdude slow to start in OS X with AVRISP-mkII USB - patch
From: |
Jason von Nieda |
Subject: |
[avrdude-dev] avrdude slow to start in OS X with AVRISP-mkII USB - patch included |
Date: |
Mon, 18 Jan 2010 10:38:23 -0800 |
Hi all,
I am new to the list but old to avrdude. I am the creator of AVRFuses
( http://www.vonnieda.org/AVRFuses ) and have recently been
considering trying to integrate the avrdude library into it instead of
doing command line calls and output capture.
Anyway, this has caused me to look deeper into a problem I have had
with avrdude under OS X for quite some time. It seems that with the
AVRISP-mkII USB after the first run of avrdude after plugging in the
programmer avrdude is very slow to start. This seems to be related to
a missing sync byte.
Here is an example of a run:
----
> time ./avrdude -B 1 -P usb -p atmega168 -c avrispmkii -C ./avrdude.conf
avrdude: stk500v2_recv_mk2: error in USB receive
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9406
avrdude: safemode: Fuses OK
avrdude done. Thank you.
real 0m16.702s
user 0m0.169s
sys 0m0.326s
----
This is from a freshly downloaded and compiled avrdude-5.9,
libusb-1.0.6 and libusb-compat-0.1.3.
You see the error "avrdude: stk500v2_recv_mk2: error in USB receive".
This instance of stk500v2_recv_mk2 is being called from
stk500v2_getsync in stk500v2.c on startup. At the very beginning of
that code we have:
----
if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII)
return 0;
----
This seems to indicate that this function is not needed for the
JTAGICE_MKII, which I believe is pretty similar in protocol the
AVRISP-mkII. I wondered if this was the reason for the slowdown. To
test the theory I added the following patch:
----
diff -r -u avrdude-5.9-clean/stk500v2.c avrdude-5.9/stk500v2.c
--- avrdude-5.9-clean/stk500v2.c 2010-01-15 13:45:07.000000000 -0800
+++ avrdude-5.9/stk500v2.c 2010-01-18 10:15:28.000000000 -0800
@@ -667,7 +667,8 @@
DEBUG("STK500V2: stk500v2_getsync()\n");
- if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII)
+ if (PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII
+ || PDATA(pgm)->pgmtype == PGMTYPE_AVRISP_MKII)
return 0;
retry:
----
That seems to have solved the problem. Here is a run with the patch applied:
----
> time ./avrdude -B 1 -P usb -p atmega168 -c avrispmkii -C ./avrdude.conf
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9406
avrdude: safemode: Fuses OK
avrdude done. Thank you.
real 0m5.633s
user 0m0.170s
sys 0m0.324s
----
So, I wanted to submit this patch for the review of someone who might
be more familiar with the code. I've done a lot of Googling for this
problem and lots of people seem to have it but I have never found any
answers to it. If this patch seems sane I'd like to ask that it be
included in the codebase.
Thanks,
Jason von Nieda
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avrdude-dev] avrdude slow to start in OS X with AVRISP-mkII USB - patch included,
Jason von Nieda <=