-
Notifications
You must be signed in to change notification settings - Fork 151
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
[bug #51117] Problems with extended address (>128K) and buffer size #454
Comments
Mike Any chance you have or could create a patch for version 6.1? I tried to applyu this patch but get a malformed patch at line 13. I assume due to differing butterfly.c files betwen version 6.1 and 6.3. |
Stephan Schreiber I'd love to help, but I'm actually still quite busy reinventing the wheel and porting the whole thing to Swift, using ORSSerial Library. |
Mike I totally understand. I made the changes manually. Reason I am not using 6.3 is because I ran into issues using GPIO on my raspberry pi with 6.3. Could never get it work but 6.1 would work fine. Thanks for the patch, I will report back if it is successful in 6.1 (running into other issues with my raspberry pi preventing me from testing it at the moment). |
Stephan Schreiber Thanks! |
Mike So I got avrdude reinstalled on my raspberry pi and working the way it was before...which was the verification was failing on a flash where file is 152kb. I made changes to the butterfly.c file but am not sure I am taking the proper steps afterwards. The steps I did take were to: make My thought process was that this would recompile avrdude with my changes to butterfly.c. Am I wrong on this? Apologies as this is a new realm for me and I am learning as I go. |
Mike And as I am looking at all of this, please excuse my ignorance, would changes to the butterfly.c file have any affect on my circumstance where I am attempting to use the "linuxgpio" programmer? |
This is probably the same as #360. |
Is there a place I can get a working avr109/911 bootloader so I can test the provided patch which a 128kiB and a 256kiB AVR? For some reason, related issues are all xmega-related, but since this is about the 109/911 protocol, I doubt the actual chip matters much, except for their page size and total flash memory size. |
@MCUdude
@dl8dtl is saying that this is a protocol extension for AVR109 bootloader. You can download the official AVR109 examples here and see if you can extend it for 128KB/256KB flash parts. I was able to get it work for ATmega328P (using the ATmega328PB as the template) but I have not tried it with ATmega2560. |
I have changed the label to |
@MCUdude There are enhancement requests for xboot here.
There is another avr109 compatible bootloader for ATmega1284P here. You may also want to take a look. |
AVR109 application note zip file should work out of the box for ATmega128. As per the following avrfreaks thread, you can get avr109 to work with ATmega2561/1280 or similar parts. In case avrdude does not work, you can try AVROSP or AVROSP2. avrdude is said to work with AVR109/911 bootloader here for ATxmega128D4 but not AVROSP2. |
This is what I get with the current git with my quick mod of the avr109 for ATmega2560 (tested on Arduino Mega CH340 clone). It failed to upload the blink hex file.
|
Applying the patch does not help. I think I need to modify the avr109 further to get it working with ATmega2560.
|
I got better results with xboot. xboot avrdude flash writing is good even though the verification does not work. And I can see the LED blinking. Note: the blinking hex file is not a good application in this case as I need to re-burn the bootloader after the flashing. I need to modify xboot to use a pin to enter bootloader mode.
Without the patch, the results are the same.
Testing with the more complex hex file shows the same results.
|
I believe the above xboot bootloader is good for ATmega2560 and there is an issue with avrdude. AVROSP2 seems to work fine with flash writing. I am using the following GUI version which seems to have more devices support. Run log from the above GUI (flash programming, verification and lastly reading). EEPROM programming and reading are also good.
|
@stefanrueger |
@MCUdude If you can get AVR109 (not xboot) to work with ATmega2560, please share here as well. Thanks. |
@mcuee sorry for the dumb question, but what's really the difference between AVR109, AVR910, AVR911 and Xboot? and is "STK600 xboot" the same as "Xdevs xboot"? I'm also quite surprised that the "proper" AVR109/910 source code is hard to find. Microchip has hidden it quite well, and there are multiple versions/forks floating around. We should collect the pieces and host them somewhere so we have a known good reference we can use when we troubleshoot AVR109/910/911 issues. |
AVR109 -- bootlader AVR910 -- simple pogrammer (mostly outdated other than to program ebn files) AVR911 -- The AVR Open-source Programmer (AVROSP) application for AVR109 and AVR910 ATxmega and AVR109 AN: xboot -- extension to AVR109, mostly for xmega AVRs but apparently also for mega AVRs. I am not so sure about the difference between |
The official Microchip AVR109 bootloader firmware source codes can be downloaded here. Indeed I have issues to get AVR109 to work with ATmega2560 using the above official codes. Even for ATmega8A and ATmega16A which should work out of the box, I am having issues now with minimum system (8MHz crystal and a reset button and power supply input) . I only managed to get it work with ATmega32A and ATmega328P (Arduino Uno Clone). I will start a discussion to collect info about AVR109 along with its extensions like xboot. |
@mcuee thanks for the clarification! I think we should focus on improving AVR109 and xboot support, and ignore AVR910 for now. AVR911/AVROSP looks like it's just a PC application. I'll see if I can compile some AVR109 and xboot bootloaders for various targets and help out with some testing. |
I've tested a little. The AVR109 build process was really painful, but I finally got something. AVR109 compiled for ATmega1284P (works):
AVR109 compiled for ATmega2560 (does not work):
|
Xboot seems to work well: AVR109 (XBOOT) ATmega1284P (works):
AVR109 (XBOOT) ATmega2560 (works):
EDIT: Tested with ATxmega128A3U (works, the only xmega I own):
|
I'm not so sure... I also had issues with AVR109/xboot when trying to either write or verify the flash. Try removing the -D flag and use -e instead, as I've done in my tests. The bootloader can't erase itself, so it's not "dangerous" in any way. It would be interesting to see how a 256kiB xmega performs. I just need to get a hold of one first. |
@MCUdude
Same good results for the more complicated test hex file.
And glad to hear that it works for ATxmega128A3U. Hopefully you can get the ATxmega256A3U for testing. I think it may well work other than the issue mentioned in #200. In that case, we can close this issue and #360. |
Just look at the history, avrdude already supports ATmega256x long ago with the following commit on 30-Jan-2007. The tests here show that it indeed works with proper AVR109 implementation with the right extension (as in xboot). This issue is saying that it somehow does not work for ATxmega2560A3. This needs to be confirmed. So I will change the label. |
Based on the test results here, I have also closed #304 as the test by Hans shows that the current avrdude works with ATxmega128A3U. #454 and #360 are labeled as
#200 is still labeled as |
I doubt the original AVR109 bootloader supports devices with more than 128kiB of flash, and the only popular 109 compatible bootloader I know of that does is xboot, which also has been around for a very long time. @mcuee I don't have a Windows computer available at the moment, but can you test if the AVR109_atmega2560.zip you provided works with the AVROSP application? If yes, that means that the original AVR109 bootloader does support 256kiB targets and that there is a bug in Avrdude. (And here is the binary I compiled. Short PB7 (Arduino pin 13) to ground to enter bootloader mode. Also, note that the hfuse needs to be set to |
BTW, for some reason, I couldn't get the ATmega16U2 USB to serial adapter on my ATmega2560 to work with the original AVR109 bootloader. Both the RX and TX LEDs flashed twice a second, but this was printed again and again in -vvvv mode. When using a dedicated USB to serial adapter (CP2012 based in my case), it was able to communicate with Avrdude. the ATmega16u2 did work with xboot though, even though the baud rate was the same for both (115200).
|
xboot was started in 2010 (first import to Google Code was on 10 May 2010. avrdude seems to support AVR109 for ATmega2560 back on 30-Jan-2007 (using extension command And the following avrfreak thread says that avrdude 5.41 works with ATmega2561 in 2007. So there must be some AVR109 implementation for ATmega2560 back in 2007. It is just Microchip's AVR109 FW release may need to be tuned to work with ATmega2560.
The hex file I compiled did not work with AVROSP either. So it is not an issue with avrdude.
I will try your binary as well. Thanks. |
Interesting to know that. My Arduino Mega2560 is the clone without the ATmega16U2, rather it is using CH340. So I do not have this issue you mentioned. It could be the USB to Serial FW implementation of ATmega16U2 (CDC-ACM) is not as good. Arduino is using very old version of LUFA. Their USB DFU implementation is using the same old version of LUFA and I found a bug.
BTW, I am having issues with ATmega8A/ATmega16A (1024B AVR109 bootloader) using an FT232R USB-TTL converter. I have not found the root cause yet. |
https://www.avrfreaks.net/comment/232269#comment-232269
@dl8dtl followed the info from Mike H to update avrdude to work with the Apparently the comments by Mike H never materialized. Atmel did not update the AVR109 AN or the FW codes to mention the |
Great find! The question is; does there exist a modified AVR109 bootloader that supports 256kiB targets that isn't xboot? It's a bit sad that the "official" AVR109 bootloader never got support for 256kiB targets. I wouldn't expect xmega support as that's a lot of work, but support for 256kiB targets shouldn't be too much work for those who already know the source code. Maybe we could annoy Microchip technical support enough that they will set someone to do the job? |
No need! I tried it on a Windows computer, and it didn't work with AVROSP either. |
I think we can close this issue once you confirm that avrdude/xboot combination works for the ATxmega2560A3U or other parts with higher than 128kiB flash memory. I think there was at least one AVR109 bootloader implementation for ATmega2560 before xboot (say in 2007 based on the 200i7 avrfreak forum post I mentioned before. However, I can not find anything now and I think the old implementations no long matter. Edit: the Codevision AVR109 example does support ATmega2560. But I do not have CVAVR myself. Maybe it can be ported to gcc. |
@MCUdude I was doing the same test with another Arduino Uno with CH340G and the same 57600bps FW works. But then 115200bps FW did not work. So maybe you can redude to 57600bps to see if that helps the ATmega16U2. Probably CP2102 works better in this aspect. 57600bps:
115200 bps
Edit to add: in my case, even with a FT232R USB-TTL converter, 115200bps still does not work for my Arduino Uno CH340G clone whereas 57600bps works fine. For my simple ATmega8/Atmega16 core board (8MHz crystal), I need to lower to 19200bps for them to work. |
I can confirm that the patch attached to the first post resolves this issue and #360. However, the patch isn't perfect. It hardcodes the page size to 512 bytes, so this has to be figured out. I was a bit worried that
|
It seems like the Output:
|
Fixed with PR #1101 |
Stephan Schreiber
Thu 25 May 2017 11:16:43 PM UTC
Programmer hardware: AVROSP (Butterfly)
Device type: ATXMega256A3(U)
Using a black-box (client-provided) which is connected via Ft232R USB adapter, most likely ancient boot loader, following AVROSP protocol (and working correctly with avrosp.exe).
My job here is to port a Windows Firmware Updater (using avrosp.exe) to Mac OS X.
ATXMega256A3 (might be -U, can't find out without disassembling the unit which I am clearly not supposed to do).
Due to NDA I cannot disclose any further details, but I can provide a partial serial log if you're interested.
I've analyzed serial communications and that's how I finally found out what is going wrong there.
For some reason, buffer size is reported as 0x0080 (128 bytes) and the update process fails, as 512 bytes (page size correctly given in avrdude.conf). are expected.
The even more serious problem, however, is that extended addressing is not being used by avrdude in this case.
"A" 0xff00" becomes "A" 0x0000 instead of "H" 0x010000", thus overwriting flash memory from the beginning instead of appending the code properly.
I have applied this (rough) patch, which makes it work; just wanted to let you know.
I probably can't use avrdude anyway, because of the restrictions GPL would impose.
Anyway, here's the patch:
Best regards,
Stephan
This issue was migrated from https://savannah.nongnu.org/bugs/?51117
The text was updated successfully, but these errors were encountered: