Do you have any Idea why my alternative linkage wasn't wanted?
C:\Users\johan\AppData\Local\Temp\arduino_build_903646\sketch\src\samples\bpb606bd04.cpp:6:1: error: 'PROGMEM' does not name a type
PROGMEM const unsigned int bpb606bd04[10561] = {
^
Edit: Do we have a WIKI page about FLASHMEM/PROGMEM and memory layout?
@Defragster: Do you have any Idea why my alternative linkage wasn't wanted?
I have not included Arduino.h, I will try that, thanks. However, I still cannot understand how 8Mbyte Flash is insufficient when the Flash in T3.5 was enough to load my samples?
@luni the best ref to date is the pjrc.com/store/teensy40.html - and the thread that it came from - though it is long and spread out.
A functional example or two would be great.
Paul regularly uses the FLASHMEM in cores for CODE - the PROGMEM still works for DATA - but as noted when not in sketch INO ( header into cpp or other? ) it had to see arduino.h to know what it is.
And FLASHMEM was created because PROGMEM on CODE conflicted in the linker when PROGMEM was used on data in the same unit.
And const or static alone are not enough to get stuff kept on FLASH - it takes those linker segmentation commands.
int i;
const double x = 42; // <== constant
void setup(){
static int k;
while (!Serial) {}
printMemoryInfo(i);
printMemoryInfo(x);
printMemoryInfo(k);
}
void loop(){
}
i
Start address: 0x1FFF'11E4
End address: 0x1FFF'11E7
Size: 4 Bytes
Location: RAM (not initialized)
x
Start address: 0x0001'08C8
End address: 0x0001'08CF
Size: 8 Bytes
Location: FLASH
k
Start address: 0x1FFF'11E8
End address: 0x1FFF'11EB
Size: 4 Bytes
Location: RAM (not initialized)
And const or static alone are not enough to get stuff kept on FLASH - it takes those linker segmentation commands.
Great tool, luni
You may want to take a look at the .sym file, that gets generated on a build, too.
(In the wiki there is a page which describes a way for a better *.sym generation)
I started with a WIKI article about this stuff here: https://github.com/TeensyUser/doc/wiki/Memory-Mapping. It currently lives in the Basisc section. It is still a bit sketchy but good enough for a first review.
While I wrote the article I thought a simple tool to do experiments with various memory locations and attributes might be fun. Here a few examples what you can do with it. (please note, it currently only works with T3.x. I'll extend it to T4.x when I find some time):
I wasn't able to reproduce that can you do an example where a const variable doesn't end up in FLASH?Code:... [CODE]And const or static alone are not enough to get stuff kept on FLASH - it takes those linker segmentation commands.
// BEFORE
Memory region Used Size Region Size %age Used
ITCM: 64 KB 512 KB 12.50%
[B]DTCM: 17088 B 512 KB 3.26%[/B]
RAM: 12384 B 512 KB 2.36%
FLASH: 88356 B 7936 KB 1.09%
ERAM: 0 GB 16 MB 0.00%
// Added :: [B]const uint32_t myArr[30000]={0};[/B]
Memory region Used Size Region Size %age Used
ITCM: 64 KB 512 KB 12.50%
[COLOR="#FF0000"][B][U]DTCM: 139968 B 512 KB 26.70%[/U][/B][/COLOR]
RAM: 12384 B 512 KB 2.36%
[B]FLASH: 208548 B 7936 KB 2.57%[/B]
ERAM: 0 GB 16 MB 0.00%
// Edited to :: [B][U]PROGMEM[/U] const uint32_t myArr[30000]={0};[/B]
Memory region Used Size Region Size %age Used
ITCM: 64 KB 512 KB 12.50%
[B][U]DTCM: 17088 B 512 KB 3.26%[/U][/B]
RAM: 12384 B 512 KB 2.36%
[B]FLASH: 208548 B 7936 KB 2.57%[/B]
ERAM: 0 GB 16 MB 0.00%
int vvv=0;
for ( int uuu=0; uuu<30000; uuu++) {
vvv+=myArr[uuu];
}
Serial.println(vvv);
Serial.println(myArr[29000]);
...Just saw this coming back for another post. Below is confirmation what Paul said in his posts is correct - Wiki should get an update...