[En-Nut-Discussion] Nut/OS on ATmega 2561
Dusan Ferbas
dferbas at etech.cz
Sat Mar 7 17:23:33 CET 2009
Hi,
I wrote here on 11 Jul 2008, what were problems to port an
application from ATmega128 to its 3 byte PC son.
Issue is, that a gcc compiler generates eicall instructions without
seeding the eind register.
(eicall is generated e.g. for indirect calls through arrays or device
structures)
So in fact eicall instruction with current gcc cannot call a function
in upper half flash.
With this in mind, we found all functions, that were addressed by
eicall calls and with attribute placed them in special "lower" sections.
These sections are then linked first to fit in lower half.
We need to cooperate with bootloader from our application, so we call
an auxilliary function, jump to bootloader,
set eind here to 1 ith asm instructions, rely on eicall from gcc.
But it was not working reliably.
Magic is, that when an interrupt occurs, CallHandler() is called and
eicall is in it.
But at that time eind is set to 1, which misplace the call.
So we disable ints while having eind=1.
------------
This problem is I think common, not only with a bootloader. Once
eicall is generated in a function in upper half flash, targeting call
is misplaced.
The easiest way should be to prepend eicall with eind setup and
linker should modify eind with 1 or 0.
Unless this is implemented instead of eicall, simpler icall is sufficient.
I like this 3 byte PC :-).
------------
I would like to hear from others with 256x applications ho they are running ?
Can you check eicall instructions in your listings and report if all
targeting functions are in lower flash half ?
Anyone, who fixed this issue ?
Dusan
More information about the En-Nut-Discussion
mailing list