Skip to content
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

Closed
JAndrassy opened this issue Jan 7, 2019 · 3 comments
Closed

call to do_spm in optiboot.h should use EIND on 2560 #265

JAndrassy opened this issue Jan 7, 2019 · 3 comments

Comments

@JAndrassy
Copy link

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

@WestfW WestfW changed the title call to do_sdm in optiboot.h should use EIND on 2560 call to do_spm in optiboot.h should use EIND on 2560 Jun 28, 2019
@WestfW
Copy link
Member

WestfW commented May 29, 2020

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...

@JAndrassy
Copy link
Author

JAndrassy commented May 29, 2020

fix is in #269
in optiboot.h

many people use it with Mega and my popular ArduinoOTA library with Optiboot build from my my_boards hardware definitions

@WestfW
Copy link
Member

WestfW commented May 30, 2020

Done (copied from #269 as suggested.)
243ee94

@WestfW WestfW closed this as completed May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants