Skip to content

mega2560 bootloader doesn't support eeprom writes or erases [imported] #543

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

Closed
cmaglie opened this issue Nov 15, 2012 · 1 comment
Closed
Assignees
Labels
Component: Bootloader The bootloader is the program used to load the uploaded program into the microcontroller's memory Component: Firmware Limited to the contents of the firmwares folder in the core packages
Milestone

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 543 moved from a Google Code project.
Added by 2011-05-18T17:09:42.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium

Original description

What steps will reproduce the problem?

  1. avrdude -e
  2. avrdude -U eeprom:r:-:h

What is the expected output? What do you see instead?
Should be all 0xff, isn't actually erased.

  1. avrdude -U eeprom:w:blah.eep

What is the expected output? What do you see instead?
Should succeed, fails verification.

This is because the stk500v2 bootloader on the 8u2 chip on the arduino mega 2560 board has these pretty useful functions either defined out, or as a noop.

Please provide any additional information below.

At line 804, (case CMD_CHIP_ERASE_ISP:) in https://github.com/arduino/Arduino/blob/master/hardware/arduino/bootloaders/stk500v2/stk500boot.c you can see that chip erase is a NOOP. I think this should at least return something indicating that it wasn't done, not that it succeeded.

At line 858 in the same file,

if (!defined(AVR_ATmega1280) && !defined(AVR_ATmega2560) && !defined(AVR_ATmega2561))

You can see that the code for programming the EEPROM on the megas is simply defined out. if that code doesn't work on the megas, it should be replaced with code that does.

@cmaglie
Copy link
Member Author

cmaglie commented Feb 11, 2013

Please look at the pullrequest here #1183

The updated hex bootloader is available here:

https://github.com/cmaglie/Arduino/blob/mega2560-bootloader/hardware/arduino/bootloaders/stk500v2/stk500boot_v2_mega2560.hex

Please check it out and report here #1183 success or failures.
Thank you!

C

@cmaglie cmaglie closed this as completed Mar 11, 2013
phord added a commit to Traumflug/Teacup_Firmware that referenced this issue May 17, 2016
Some target devices need extra avrdude command line switches to
get them to upload successfully.  There are dozens of options which
may be useful to different people. Instead of breaking all the possible
options out into separate fields, provide a generic "Program Flags" text
field which the user can fill in similar to the CFLAGS and LDFLAGS
settings.

The Arduino Mega2560 bootloader was changed[1] to report an error when
asked to erase flash because it has never actually implemented erasing
flash. To program this bootloader with avrdude requires the -D switch
to avoid flash erase. But it seems that every arduino will work fine
with -D, as evidenced by the fact that the Arduino IDE always [2]
includes -D in the avrdude commandline. Presumably the flash is erased
during/before programming anyway and the separate erase step is unneeded.

Perhaps the -D should be always added to avrdude command line in
configtool and in Makefile-AVR.  But I haven't tested any other boards
yet, and I'm being more cautious even though the Arduino IDE does
otherwise.

[1] arduino/Arduino#543
[2] https://github.com/arduino/Arduino/blob/d8e5997328b76c570c1803baef4c5399783fded0/app/src/processing/app/debug/AvrdudeUploader.java#L168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Bootloader The bootloader is the program used to load the uploaded program into the microcontroller's memory Component: Firmware Limited to the contents of the firmwares folder in the core packages
Projects
None yet
Development

No branches or pull requests

1 participant