I am working with a large amount of data using s Mega processor and I need to put in PROGMEM.
I am instructing the compiler to place the data in Sections .fini9, .fini8 and .fini7. I am also instructing the compiler to place the data after the program data using the following:
and that is working. I know this because my program continues to work even when the data involved is larger than 64k.
The problem I am having is that the data is getting corrupted when the data crosses over a 64k boundary. To fix this problem I want to force the compiler/linker to place the sections at specific memory locations.
The "avr" manual says I can do this with a "-W1" command. The "avr" manual says that the command can be used from the "C" compiler using the following command:
My guess is that you would need to do this in the platform.txt of the selected board. I don't think you can do it from the sketch. I could certainly be wrong about this though. Maybe it's possible using attributes.
You need to use pgm_read_xxx_far() instead of pgm_read_xxx_near() to read things above 64k.
The --section-start parameter must be passed to the linker as a command line argument - it's not part of your code, it doesn't go in the sketch. As Pert said, the command line parameters are figured out from the platform.txt - making them rather inconvenient to modify.
...and you may not be able to fix the predefined .fini sections to specific addresses. The linker is bound by rules that apply to those sections (the rules are defined in a "linker script").
But, if you are doing such things, you can just as easily use your own sections. There is no compelling reason to continue using .fini sections.
I have figured out how to use the pgm_read_xxx_far/near()calls to read the data. The problem I am having involves the fact that:
I don't know which one to use as I really don't know where the compiler put the data; and
when the data crosses over a 64k barrier, the data tends to become corrupted.
By using the following "define" statement, I am able to make the compiler put the "PROGMEM" data after the program instead of before the program. At least the program runs and does not get correpted and crash.
Looks like I have a significant amount of studying ahead of me.
I found a manual for the "Platform.txt" file and for the linker. I have done a cursory review of the "Platform.txt"
manual. I guess I will have to do a lot more studying.