-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix avrdude 6.3 fuses inconsistency #5202
Conversation
leonardo.bootloader.unlock_bits=0x3F | ||
leonardo.bootloader.lock_bits=0x2F | ||
leonardo.bootloader.unlock_bits=0xFF | ||
leonardo.bootloader.lock_bits=0xCF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could certainly be wrong on this but shouldn't this(and all other ATmega32U4 entries) be 0xEF? http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega32u4&LOW=FF&HIGH=D8&EXTENDED=CB&LOCKBIT=2F shows the original lock bits setting(0x2F) is:
- Application protection mode 1
- Boot Loader protection mode 2
- Mode 1: No memory lock features enabled
http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega32u4&LOW=FF&HIGH=D8&EXTENDED=CB&LOCKBIT=CF shows 0xCF is:
- Application protection mode 1
- Boot Loader protection mode 3
- Mode 1: No memory lock features enabled
http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega32u4&LOW=FF&HIGH=D8&EXTENDED=CB&LOCKBIT=EF shows 0xEF is the same as the original setting:
- Application protection mode 1
- Boot Loader protection mode 2
- Mode 1: No memory lock features enabled
EDIT: formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out.
I believed that protecting bootloader with mode3 (like all the other boards) shouldn't have any side effect but I was wrong, reading the bootloader section from application space is used here https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/USBCore.cpp#L819
Reverting these fuses to 0xEF in next commit
@per1234 , the problems you exposed and the fact that merging this one would be a nightmare for 3rd party cores (unless we implement the |
@per1234 , could you test again using the new @ArduinoBot build? Thanks! |
✅ Build completed. Please test this code using one of the following: ⬇️ http://downloads.arduino.cc/javaide/pull_requests/arduino-PR-5202-BUILD-587-linux32.tar.xz ℹ️ The |
I understand that backward compatibility is an issue, but in my opinion, fixing this problem by only ignoring differences in unused bits is not the proper way to fix it. This will encourage users to keep using the previous value, and we will end up with some users using the old way, and some the new way.
My suggestion to solve this is the following.: In the future, when you are confident that most users have seen the warning and have cared about it, that will become an error. Of course, all change need to happen simultaneously, and you may have to decide to temporarily revert avrdude to a previous version, until all fixes are ready and tested, but in the long term, imho, it is the best option. What do you think about it? |
@descampsa, sounds like a sane argument you make, and adding the warning you suggest sounds good to me. This is certainly something to also talk about with avrdude upstream, see what they think about it. |
Hey, here is a version of @facchinm patch that implement the warning, and also take @matthijskooijman comments into account, if you want to test it : |
Hi @descampsa , |
Sure, go ahead and propose it. |
I added one more nitpick coment to that patch. Also, one other issue I discussed with @facchinm on Skype, but I now see I didn't mention here as well, is about how Based on the source above, I would propose:
This includes the nitpick mentioned above. The code is completely untested. |
Hey @matthijskooijman, i have taken a second look at the code after your last comment. I don't think you can base the bitmask on the read command only, because the origin of the problem is that new avrdude.conf now read the complete byte, including unused bits (so all height bits are OUTPUT). However, i agree that the current logic is probably more complex than necessary. What we could do is maybe include only bits that are INPUT in the write command, which would mean that we check only the bits that we actually write based on the user input? Also, i may be missing something, or it is just a strange coding convention of avrdude, but the first for loop over |
Ah, I missed that part. Your proposal sounds good, then. In any case, getting feedback from upstream would help here, I'm sure that Joerg has a better overview of the code than either of us :-)
Hm, now that you mention it... Perhaps this is a leftover from an older version where the operation type was stored as a string or something like that? The loop is indeed quite pointless as it is now... |
Superseeded by #5374 |
New avrdude build with applied patch https://savannah.nongnu.org/patch/index.php?8996 (not yet upstreamed).With this patch applied, all inconsistencies between unused fuse bit / programmers etc should be gone.THIS PATCH IS NOT BACKWARDS COMPATIBLE WITH AVRDUDE 6.0.1This shouldn't be a problem because we merged #5199Contains and supersedes #5182Please test with any programmer you may have in house (personally tested with Arduino as ISP (stk500v1) and AVRISP mkII (stk500v2) on all Arduino boards MCUs).
3rd party core could need to adjust their fuse setting if this patch gets mergedThe new revision uses a completely different approach, patching avrdude so it ignores differences between fuses if the offending bits are marked as reserved.
This approach is backwards-compatible with existing boards.txt and avrdude 6.0.1
Based on arduino/avrdude-build-script@7eab60d
@per1234 @descampsa @mikaelpatel @matthijskooijman @damellis @markaswift @aethaniel