avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avrdude-dev] [patch #9110] Let reserved fuse bits to be read as *don't


From: Matthijs Kooijman
Subject: [avrdude-dev] [patch #9110] Let reserved fuse bits to be read as *don't care*
Date: Fri, 18 Aug 2017 15:12:19 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Follow-up Comment #1, patch #9110 (project avrdude):

AFAIU the original problem was that whether unused bits are read back as zero
or one, depends on the programmer and part used. The plan is to let all
programmers and parts return ones for unused bits, but I also understand that
for some legacy parts and the lock bits this is not (yet?) the case.

This patch helps with two things:
 - Preventing verification and safemode to fail when there is a mismatch in
the unused bits only.
 - Show a warning to the user indicating what is happening.

If everything would be changed to return ones, I believe this problem would be
nicely fixed. However, IIUC not all parts might actually support this, so
applying this patch might be useful. Also, the warnings might be convenient to
help users that are still passing in zeroes based on old scripts and
instructions.

For Arduino, having this patch applied would also be helfpul, since it's not
unlikely to have a newer avrdude version in the Arduino IDE, combined with
older third-party board definition files which still have zeroes in their
unused fuse bits. With this patch applied, these older boards can still work
with a newer avrdude (also, these boards can then be made to work with both
new and old avrdude versions).

I've uploaded a new version of this patch, which:
 - Improves `get_fuse_bitmask()` which figures out what bits are (un)used.
This removes some pointless loops, marks bits to be used if and only if they
are marked is "input" in the write command and as "output" in the read
command, and looks in all four command bytes instead of just the last one. It
now also uses bitno instead of assuming that the position within the command
dictates the bit number in the original value (which is currently only
different for address bits, but perhaps this could change in the future).

 - Improves the warning shown when changes in unused are ignored. It now
checks whether the programmer returned zeroes for unused bits, or whether the
user supplied zeroes for unused bits (with the previous version of this patch,
the former case would cause a confusing warning message).

 - Lets the safemode "Fuses OK" message show the values most recently read
instead of the original values. Without this patch, these are identical, but
with this patch the unused bits can be different. When a fuse byte is changed
and the user specified zeroes for the unused bits, the safemode "original fuse
value" is overwritten, so this change makes sure to show a value that is
actually read by the programmer.

Here's some output of avrdude with this patch applied, showing both
warnings. This was tested with a 328p, which has 3 efuse bits (set to
0xFD) and 6 lock bits (set to 0xCF). It uses an FTDI bit-banging
programmer and avrdude.conf is unmodified, so it returns ones for unused
fuse bits and zeroes for unused lock bits (see patch #8996).

 ./avrdude-6.3/avrdude -C avrdude-6.3/avrdude.conf -c ftdi -p m328p -U
efuse:w:0x05:m
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified

avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.


./avrdude-6.3/avrdude -C avrdude-6.3/avrdude.conf -c ftdi -p m328p -U
efuse:w:0xFD:m
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "0x05"
avrdude: writing efuse (1 bytes):

Writing |  ***failed;  
################################################## | 100% 0.25s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x05:
avrdude: load data efuse data from input file 0x05:
avrdude: input file 0x05 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: WARNING: ignoring mismatch in unused bits of "efuse"
         (0xfd != 0x05). To prevent this warning set unused bits
         to 1 when writing (double check with your datasheet first).
avrdude: 1 bytes of efuse verified

avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.


./avrdude-6.3/avrdude -C avrdude-6.3/avrdude.conf -c ftdi -p m328p -U
lock:w:0x0F:m
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.

./avrdude-6.3/avrdude -C avrdude-6.3/avrdude.conf -c ftdi -p m328p -U
lock:w:0xCF:m
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "0xCF"
avrdude: writing lock (1 bytes):

Writing |  ***failed;  
################################################## | 100% 0.25s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xCF:
avrdude: load data lock data from input file 0xCF:
avrdude: input file 0xCF contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.03s

avrdude: verifying ...
avrdude: WARNING: ignoring mismatch in unused bits of "lock"
         (0x0f != 0xcf). To prevent this warning fix the part
         or programmer definition in the config file.
avrdude: 1 bytes of lock verified

avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.

Note that in the cases where the warnings are shown, there is also a
"***failed" shown while writing. I'm not quite sure what causes that
yet, it is also present with the unpatched version. Perhaps the write
does some kind of implicit check based on the ISP value read or
something?


(file #41574)
    _______________________________________________________

Additional Item Attachment:

File name: 80-Avoid-failing-fuse-check-if-different-bits-are-reserved.patch
Size:5 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?9110>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]