Open GoogleCodeExporter opened 9 years ago
PROGMEM indeed supports only the first 64k of flash. This is not fixed until
avr-gcc 4.7 which is not yet anywhere near ready for production use. (avr-gcc
4.7 adds memory spaces for AVR which allows additional 64k blocks beyond the
first one.)
Should be documented somewhere in the Arduino docs about using PROGMEM that
this limitation applies.
Original comment by david.s....@gmail.com
on 9 Oct 2012 at 6:18
It's not quite as dire as David says, but it's not good, and there are many
things wrong with the example sketch that would prevent it from working. There
is some summary explanation here:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=93874&highligh
t=remarks
1) you definitely need to use pgm_read_byte_far() instead of pgm_read_byte()
2) All pointers in avr-gcc are only 16bits, so to access more than 16bits you
need to use other data types, and can no longer use pointer-like constructs (&,
[]) for accessing the data.
3) GET_FAR_ADDRESS() needs to be added and used to load those non-pointer types
from C symbol names.
I've attached an attempt at corrected code. I don't actually have a MEGA to
try it on, but it does compile...
Original comment by wes...@gmail.com
on 10 Oct 2012 at 12:25
Attachments:
Hmm. On further analysis, it looks like the version of g++ used by Arduino
will fail whenever the global constructors get pushed beyond the 64k limit,
because the global constructor table is only 16bits wide and the code uses ijmp
to access it. This is somewhat related to the bug that used to keep 64k+
programs from working when compiled under linux, but not quite the same
(http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=97077 ) (I
did theorize there that all version of g++ were broken for large programs; I
guess I was right.)
Having a lot of PROGMEM data is one thing that will push the constructors past
64k.
Original comment by wes...@gmail.com
on 10 Oct 2012 at 6:30
Original issue reported on code.google.com by
tombroe...@gmail.com
on 9 Oct 2012 at 11:13