-
Notifications
You must be signed in to change notification settings - Fork 150
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
Support optiboot, optiboot_dx and optiboot_x bootloaders for -c arduino #1140
Conversation
Yes it works with optiboot_dx on the AVR128DB48 Curiosity Nano board. But there is a false verification error message during the verification stage, which is the same as what I encountered before (for larger hex file). This may be a seperate issue. The programming itself is good as I verified with the onbpard pkobn_updi programmer as well. Standalone verification with the bootloader is also good.
I will test STK500V1 later. |
Yes, I think this could be a bug in optiboot_dx in the way it deals with the extended byte in the following lines Optiboot_dx uses I pushed a commit to repair Optiboot_dx's bug in AVRDUDE. Please test. @mcuee You did a really great job with testing here. This bug only surfaces with an input file with its highest flash page just below |
I'd argue that it's perfectly reasonable for the bootloader to expect that the next word interacted with after 32767 is word 32768, and to expect the host to tell it otherwise at the start of verify. You've gotta admit this is a corner case - and the upload would have succeeded, thought the verify would have erroneously reported a failure. (difficult to arrange when on a battery meant to last all winter and get recharged in the off season or a solar cell to stay charged and there's a mile of deep snow between you and the device, and you've got some custom OTA update scheme with some other means of resetting it remotely) (I know a system where this was implemented. It almost worked too - the killer was the virtual boot erase bug, which i didn't understand fully at the time, And they had a hundreds of em deployed in near wilderness in the middle of winter before the problem was discovered, Pity, he was a very good client, paid well and gave interesting assignments, Bit not fixing the virtual boot bug cost me any future work for him :-/ (and I knew there was tons more where that came from) And of course, on modern AVRs, updating the bootloader requires recompiling sketches for them . The hex files compiled assuming a 1024 byte bootloader are incompatible with a 512b bootloader (or to be pedantic, a binary generated for a BOOTSIZE = 2 is incompatible with BOOTSIZE = 1) |
@stefanrueger |
Interesting perspective. Thanks for the sharing of the background. |
@stefanrueger git main will fail and this PR will pass, for ATmega328P.
Same results for ATmega8A.
|
Yes now the false verification error message is gone. Now optiboot_dx works perfect for the avr128db48.
|
| this is a corner case @SpenceKonde Absolutely, and I am vvv happy that we can solve this AVRDUDE side! I have every sympathy for saving instructions in the bootloader particularly when you are on the boundary of 512 bytes. Well done, too, for going with byte addresses (saves the times two in the bootloader that's particularly costly for those > 64k flash devices). Please give this PR a shot with optiboot_x and optiboot_dx and your devices. You should be able to program with |
Brilliant, thanks @mcuee for testing the ATmega328P and the ATmega8A which represent the two main MCU classes. I know that there should be no one around who still uses the STK500 programmer with FW1.x, but it's kind of a satisfying feeling that AVRDUDE can do this :) |
Sorry for being so slow to test this PR! I can confirm that writing to flash and EEPROM works perfectly fine using optiboot_x and ATmega4808. Thanks, @stefanrueger! |
@MCUdude I have ordered that board as well from Mouser Singapore on Monday and I am waiting for the board (not yet shipped). Previously I was able to get AVR128DB48 Curiosity Nano to work with optiboot_dx (8s delay firmware) and tested this PR to be good.
|
Great, now this works with ATmega161. I am using the Bigboot optiboot hex file for ATmega328P with EEPROM support in this test.
It also works with the other three classic AVRs which has the same issue.
|
I just tried with an AVR64DD32, but I'm unable to write to either flash or EEPROM. However, DxCore does not provide a dedicated bootloader for the DD series (even though they're present in the DxCore boards.txt), so I used the default one that's used for AVR DA and DB. I can communicate with the target, but I can't get it to work. However, I can't get it to work with Avrdude 6.3 or 7.0 either, so it might be a bootloader issue, not sure... Maybe @SpenceKonde knows?
|
It may be the case that the bootloaders expects modified entries for these parts in a private |
@stefanrueger I can confirm that this PR solves the EEPROM issue for "classic" AVRs!
|
Would you like to create an issue regarding AVR-Dx parts with less than 128kiB flash? I'll throw in some AVR64DA* and AVR64DB* chips in my next Digikey order, so we should be able to resolve this in a timely manner. DxCore doesn't really support AVR-DDs yet either. A Basic blink example doesn't compile, there are bugs in the boards.txt file and working bootloaders are not present. I believe it's being worked on though... |
@MCUdude I just can not get this to work with ATtiny1627 Curiosity Nano board. I use Arduino IDE 2.01 and megaTinyCore and it seems to be able to burn the bootloader, but then it is not able to upload the blink sketech using Arduino. If I use Arduino 1.8.19, it even failed to burn the bootloader. WIth the bootloader burned from Arduino 2.01, it does not work with either avrdude git main or 7.0 release. It does not seem to write anything (checked with the on-board pkobn_updi programmer). I am thinking the bootloader does not work for this board (I am choosing official Microchip board with optiboot).
It seems to work with EEPROM though.
|
@MCUdude Then I chose the no bootloader option and tried to burn the bootloader and hope to set the right fuse settings -- now my board is bricked. It is my fault though as I did not notice that both the two options for reset require HV UPDI programmer. Stil this looks like a DxCore bug to me. I hope to revive it using PICKit 4 though. |
Yes I am able to revive the AVR64DD32 using PICkit 4. |
Neither of those options is the one you should be using. The one you should be using is the Reset and UPDI option. That said option is not present is clearly a bug. I didn't name the menu options distinctly. Do note that there is no currently working version of DxCore for the DD, and I need to get shared serial code that is currently hosed in mTC fixed and released on that core so I can start working on DxCore. |
I belive is what that section of board.txt should be. |
You asked me about something? I did not receive
The avrdude.conf is modified for the 128k parts, to add support for loading that last address bit; I didn't see any way around that. Other than that, the avrdude.conf that dxcore uses is AFAIK standard (though I synthesized the entries for the DDs, since there wasn't a place to crib from. I'm not sure what you asked me three times about, or where you asked me.... I didn't see any of that communication o_o |
Huh, I didn't knew this was necessary in Avrdude 6.3. In the upsteam version of Avrdude (soon to be Avrdude 7.1), I can flash 128kiB sized programs using a UPDI programmer, or Optiboot_dx without a custom avrdude.conf. But I didn't know Avrdude 7+ did anything to the stk500v1 addressing scheme. Avrdude/stk500v1 has supported extended addresses for a long time, and Optiboot on ATmega2560 works up to 265kiB. |
@MCUdude and @SpenceKonde DxCore 1.5.1 fixed the issue.
|
Supposed to fix Issue #1120
The stk500v1 code in
stk500.c
is now able to discriminate between usage for a real STK500 programmer with a (very) old firmware or a bootloader in which case the newprog_modes
variable has thePM_SPM
bit set:avrdude/src/avrdude.conf.in
Lines 751 to 757 in b864d7e
If it's
-c arduino
, ie, for bootloaders, then the part that is being programmed determines what the STK500v1 protocol variant does: if it's a classic part, all addresses are sent as word addresses (optiboot), if it's an XMEGA or a newer part (UDPI interface) then they are sent as byte addresses. Furthermore, for large parts, the stk500v1 code will then simply send the0x4d 0x00 ext_addr 0x00
sequence that all these bootloaders expect for the bits 16-23 of either the word or the byte address that's needed.@WestfW, @SpenceKonde and @MCUdude: Hopefully this will do the trick supporting optiboot, optiboot_dx and optiboot_x for
-c arduino
without having to resort to shenanigans inavrdude.conf
. @dl8dtl and @mcuee may be intrigued to learn that this also supports the original STK500v1 protocol for the-c stk500v1
programmer serving the STK500 hardware with a FW before 2005 (the latter clearly is for the software archaeologists under us).