-
Notifications
You must be signed in to change notification settings - Fork 403
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
call to do_spm in optiboot.h should use EIND on 2560 #265
Comments
Ugh. I guess this is more of a compiler limitation than a bug in optiboot itself. The code casts a constant integer to a "pointer to function", but pointers to functions are only 16bits on AVRs. If it were inside of a C program, it would probably be handled via a "trampoline" (a short piece of code in the first 64k that does the full 32bit call/jump, and/or sets EIND, but I guess that doesn't work for the hack of casting the constant... |
bootloader on 2560 starts at word address 0x1FE00. the compiler doesn't set EIND, so call to do_spm at atmega 2560, jumps to word address 0xFE01 where FFFF is in empty flash. FFFF is executed as skip one word if bit set. it is set, so it executes every other FFFF in the rest of the flash until bootloader where it hits the rjmp to do_sdm. it 'works' unless something is written in the flash above word address 0xFE01.
https://www.avrfreaks.net/forum/eicall-app-bootloader-atmega-2560-jumps-address-0x1fe01-without-eind-set
PS: I will not make a PR
The text was updated successfully, but these errors were encountered: