patchAVR Downloader/UploaDEr - Patches: patch #9110, Let reserved fuse bits to be read...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #9110: Let reserved fuse bits to be read as *don't care*

Submitter:  Martino Facchin <facchinm>
Submitted:  Wed 07 Sep 2016 02:46:56 PM UTC
   
 
Category:  None Priority:  7 - High
Status:  Done Privacy:  Public
Assigned to:  joerg_wunsch Open/Closed:  Closed

Thu 18 Nov 2021 07:53:32 AM UTC, comment #3: 

Yay, thanks for merging.

Any plans for doing a release in the near future? No pressure, but I'm hoping to get the merged version of this patch into the avrdude build that Arduino ships, and if we can expect a release soon, I'd rather ask them to wait for that than ship the SVN version.

Matthijs Kooijman <matthijs>
Fri 12 Nov 2021 10:03:01 PM UTC, comment #2: 

Applied (with a few minor stylistic changes) in r1470, thanks!

Joerg Wunsch <joerg_wunsch>
Group administrator
Fri 18 Aug 2017 07:12:19 PM UTC, comment #1: 

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)

Matthijs Kooijman <matthijs>
Wed 07 Sep 2016 02:46:56 PM UTC, original submission:  

Reserved fuse bits have been checked in many different ways throughout avrdude history.

Commonly used 6.0.1 treats them as "zeroes" when reading, so all safety checks needed the fuses to be filled with zeroes.

Newer avrdude reads them as "ones" (correctly) but still ignores them when writing.

At Arduino we need to ship a newer version of avrdude with both the behaviours, to avoid breaking outdated cores or older installations with updated cores.

The patch replaces the bytewise check with a bitwise one and, if the only difference is in the unused bits, it emits a "deprecation" warning

See https://github.com/arduino/avrdude-build-script/issues/2

Martino Facchin <facchinm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by matthijs (Updated the item)
  • -email is unavailable- added by facchinm (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-12 joerg_wunsch StatusNone Done
        Assigned toNone joerg_wunsch
        Open/ClosedOpen Closed
    2017-08-18 matthijs Attached File- Added 80-Avoid-failing-fuse-check-if-different-bits-are-reserved.patch, #41574
    2016-09-07 facchinm Attached File- Added 80-Avoid-failing-fuse-check-if-different-bits-are-reserved.patch, #38440

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code