-
Notifications
You must be signed in to change notification settings - Fork 145
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
[Regression] Optiboot for "modern AVRs" does not work with upstream version of Avrdude. #1120
Comments
This seems to indicate that optiboot_x is not exactly the same as vanilla optiboot, or maybe it is due to the different memory configuration of the new AVR tiny 0/1/2 part. I am not so sure how to fix this. One easy solution is to create a new bootloader type Maybe @stefanrueger has a better idea to differentiate the bootloader implementation. |
Detailed explanation from @SpenceKonde
|
Indeed that change 3d06457 is because of a long standing bug that typical optiboot implemnetation does not follow the stk500v1 exactly. There were three options to go as per @stefanrueger and in the end the team aligned and went with Option 1 as the Real STK500v1 is dead. Unfortunately optiboot_x got affected because of the change.
|
Hm, that problem is about EEPROM, but this bug is reported when uploading to flash. That's the one thing I don't understand here. Why does a change to eeprom impact flash writes? |
Good point. Maybe @MCUdude and @stefanrueger can help here. |
If you look closely at the 3d06457 diff, you can see that |
@SpenceKonde I see two solutions (there may be more)
|
Another possibility without need for a new |
It suddenly hit me, @SpenceKonde Optiboot X fork uses the exact same codebase as my own (originally written by @WestfW). This mean that this bug also should affect the megaAVR-0 series (ATmega808/809/1608/1609/3208/3209/4808/4809). And in fact, it does! This means that all Optiboot bootloaders + forks for "modern" AVRs are using
|
In that case, optiboot_dx for AVR128DA should be fine But optiboot_dx for AVR64Dx isn't. The incantation i have in my avrdude.conf is this:
Its the load_ext_addr that makes it do adiv = 2 currently it seems. (Note also that readsize could be up to 0x200, but it is capped artificially by avrdude to 0x100) |
@MCUdude and @SpenceKonde OK, so rather than putting into
Clearly, I have been making this table up, but it's much neater if the code expresses what your bootloaders expect rather than resorting to avrdude.conf trickery. |
@stefanrueger I can't speak for AVR-Dx'es, but for megaAVR-0's it's supposed to be |
OK, so, let's wait and hear from @SpenceKonde when his bootloaders need
Do bootloaders for these devices expect the ISP command for load extended address? |
My test results with optiboot_dx for avr128db48. There is a problem with EEPROM. I will test Flash later. With current code, the optiboot_dx will fail using PR #1110.
But with
|
It looks like the root optiboot_x (https://github.com/Optiboot/optiboot) assumes byte-addressable flash, and also that all of flash is mapped into the RAM address space. That probably means that optiboot_x won't work on chips with more than 48k of FLASH (it was originally written for ATmega4809) or with chips that don't/can't map all of their flash at once (if there are any.) (except for "short" programs, I guess.) @MCUdude and @SpenceKonde code seems to be the same code. That rather sucks :-( optiboot assumes that both flash and eeprom are word-addressed, while optiboot_x assumes that both are byte addressed. Sigh.
|
@stefanrueger |
is a_div determined from the chip type, or a combination of chip and programmer? |
@WestfW That's OK for eeprom with a page size hat exceeds 1. Turns out newer parts with @SpenceKonde I can certainly put code in Of course, the proper physical STK500 programmer (for which stk500.c was originally written) only handles classic AVR parts and has long since been upgraded to v2 firmware. Nevertheless, happy to "upgrade" the old and venerable stk500.c code to the vagaries of various bootloaders that latch onto this protocol. |
When you are at it (upgraing stk500.c code to the bootloaders and things like "Arduino as ISP" programmer), probably you can consider removing the old codes only for the real STK500 hardware programmer. |
We are talking about stk500.c here. The real STK500 only deals with classic AVRs and the V1 FW has been been obsoleted and replaced by V2 FW back in 2006. So we are not talking about any hardware UPDI programmers here. The hardware UPDI programmers will still work as we are not changing the avrdude.conf parts definitions of the new AVR chips targeted by optiboot_x and optiboot_dx. Rather the change should be in stk500.c (or a new file -- which does not seem to be necessary now). |
DxCore apparently works, but only for the first upload -- the LED blinking works fine as well. The second time it will fail to load. I am not so sure if this is because of the 8s non-auto-reset problem. I am using Microchip AVR128DB48 Curiosity Nano evaluation board. click for the details of bootloader burning and blinking LED sketec upload: 1st time good and 2nd time bad
But avrdude git main will not even work for one time (flash the bootloader again).
avrdude 7.0 release works fine for one time. So this is inline with @MCUdude's result, there is a regression here for flash.
Somehow the PR #1110 EEPROM mod no longer works. I have no idea why. Apparently it does nothing (still read as 0xff).
|
Once I change
|
@stefanrueger There is an Arduino implementation here. The bootloader is using either CATERINA (USB variant of AVR109) or STK500v2. It seems to support extended address. I do not have the facility to test them as of now. I am not so sure if @MCUdude can test them or not. |
It is a pity that my Arduino Nano Every (official board using ATmega4809)) and Nano 4808 clone (using ATmega4808) do not support bootloader. My ATtiny817 Curiosity Nano is also not a good board to work with bootloaders due to all kinds of limitation. The only board I have for UPDI AVR is the AVR128DB48 Curiosity Nano board -- it is supposed to work with optiboot_dx but somehow it is also not working very well. |
@mcuee send me an email, and I'll see if I can get you some more convenient hardware for testing.
hansibull at google's mail service , com
|
I currently only have an ATxmega128A3U and an ATmega256A3BU I can test with, but I'll look into it.
When working with bootloaders, I usually break the Rx/Tx lies from the MCU to the debugger chip, and instead wire up a dedicated USB to serial adapter. It appears to be more reliable for bootloader use at least. |
By the way, terminal mode does not seem to be affected by this issue for optiboot_dx.
|
I can also get you AVR Dx boards with Optiboot-dx and Optiboot-x on them - just email me if you still need (if you're in US, it's easier and faster to get from me, whereas (assuming he has Dx-series boards) MCUdude can get them to you faster if you're in europe. You can also use the curiosity nano with bootloader on a different set of pins, by selecting NEDBG as programmer, AVR128DA/DB48 with Optiboot as chip (instead of the Microchip board def), and then bootloading, just specify serial pins that you can connect to an external serial adapter, and either manually press reset or wire up an autoreset circuit - I don't think anything keeps it from autoresetting there. I'd probably send you like... a AVR128DB64, tinyAVR 1624 or 3224 on a rev C (no working LED) PCB, and maybe something with a double D on it to see the differences between large and small memory Dx's - they aren't the same. If I can't get a credible DD available, it'd just be like a AVR64DD48 or something. |
Rather than sending h/w, better for me to know what you'd expect from the @WestfW and @SpenceKonde: are the chip sets that your respective bootloaders deal with mutually exclusive? If so, we can make
For all devices I would send the load_ext_addr command as SPI extension when needed (ie, when flash has more than 128k memory then it's sent once at the beginning and every time the programmer jumps from one section to the other) irrespective of any ISP commands that are mentioned for that part in Does that plan work out? If there are parts that are served by two or more of optiboot, optiboot-dx and optiboot-x and the different bootloaders require a different treatment for the same part then we will need to create another programmer in AVRDUDE as @mcuee has suggested. Not a biggie, but I'd need to know how you want the flash/eeprom addresses served. If above table is too big a simplification, please feel free to create one that reflects your respective bootloaders. |
@SpenceKonde There is a strange verification error message for large hex file for avrdude 7.0 release and the 6.3 version bundled with DxCore. I am not so sure about the reason. But verification later using the onboard pkobn_updi shows flash writing is correct.
Same result for the avrdude 6.3 version bundled with DxCore.
There is no such warning message with just the blink hex file.
Ref: Test hex file: 64KB hex file with 0xaa, but the first part are replaced with the blink hex file from DxCore (where the first 512B are skipped as 512B is reserved for the bootloader). |
Once I use the following quick mode (to make all a_div =1), git main will also work as avrdude 7.0 release.
|
This is my best guess based on the results from @MCUdude and my own test results. And we do not need to worry about ATxmega parts as the popular bootloader there is based on AVR109 (eg: xboot and caterina), flip2 and STK500v2 ( https://github.com/XMegaForArduino/arduino/blob/master/bootloaders/xmega/xmegaBOOT.c). I have not seen any optiboot implementation for ATxmega part. Note: all the current parts supported by optiboot_x (megaTinyCore and MegaCoreX) have flash size not greater than 64KB.
|
@WestfW, @SpenceKonde and @MCUdude, please review the above. |
@mcuee I don't have any AVR-Dx's with less than 128kiB flash, so I'm not able able to help out figuring out the last unknown |
@MCUdude BTW, Mouse Singapore does have DIP version of AVR64DD28-I/SP part at reasonable price (S$4.72/pc or US$3.33/pc), but then the shipping cost is high at S$25 (about US$17.62) so it is not really worth to buy the bare chips. The development tools will usually have free shipment so the board costs S$32.35 (about US$22.80). |
I am guessing this must be 1. Please look at PR #1140 that implements what I believe to be a solution to this issue. |
Let's continue the discussion in #1165. |
(Probably) related to #1090.
I'm able to upload programs to an ATtiny1616 using optiboot (-c arduino) with Avrdude 6.0 and 7.0, but not the upstream version.
I've tracked down the issue to commit 3d06457.
The bootloader source code is located here: https://github.com/SpenceKonde/megaTinyCore/tree/master/megaavr/bootloaders/optiboot_x
Here's Avrdude output.
Avrdude 6.3:
Avrdude 7.0:
Upstream version:
Hex file:
The text was updated successfully, but these errors were encountered: