Mon 25 Apr 2016 05:07:28 AM UTC, original submission:
When attempting to dump the single OSCCAL/calibration byte from a Tiny10, a zero byte file is written.
Apologies if this is a PEBCAK situation.
example:
# avrdude -p attiny10 -c usbtiny -U calibration:r:cal:h
# ls -la cal
-rw-rw-r-- 0 pld pld 9 Apr 25 14:55 cal
problem source:
In file avr.c, function int avr_mem_hiaddr(AVRMEM * mem), the for() loop terminates prematurely due to memsize being 1, meaning the initial comparison is 0>0 which of course is false.
for (i=mem->size-1; i>0; i--)
***proposed fix #1, handle the corner case directly, add the test before the for() loop.
if ((mem->size == 1) && (mem->buf[0] != 0xff)) return 1;
The problem with this is that it technically violates the word-size return results expected from avr_mem_hiaddr().
# cat cal
0x70
***proposed fix #2, change the for() loop comparison to;
for (i=mem->size-1; i>=0; i--)
The problem with this is that it'll return a size of '2', and write 2 bytes to the file, for what is actually a single byte result.
# cat cal
0x70,0x3b
Regards,
Paul.
|