Hello everybody. I'm a absolute newbie on Keil Microvision and the Cortex Mx platform. I'm currently facing an issue that I believe is linked to a memory shortage on my test 8KB RAM Cortex M0 chip.
I do not quite understand how one should interpret the log displayed at compile time...
Actually, my test app compiles & runs fine when assigning a small buffer variable (let's say 10 bytes) >> Program Size: Code=33084 RO-data=3380 RW-data=212 ZI-data=6520
But, as soon as I assign a heavier buffer (let's say 1'000 bytes), the app still compiles neatly, but crashes or does not execute on the host 8K RAM chip.>> Program Size: Code=33084 RO-data=3380 RW-data=212 ZI-data=7504
Does anyone could take some time to explain me what's happening and how I should deal with this problem (maybe upgrading to a 32K RAM chip... at heavier expense)
Many thanks for your help.
Sounds like you need to go into the options, and set up the Target part correctly, describing the memory your device actually has, ie IRAM 0x20000000, 0x2000 then the linker will throw an error if you exceed the available space.
You might want to review the .MAP file now to see where all your memory is going, it will break out in detail what contributes to the line you are referencing.
What, exactly, do you mean by that?
If you're creating a 1000-byte automatic variable, that comes out of the stack - so won't be reported in the memory statistics...
www.avrfreaks.net/.../memory-sram-compiler
You're right, my settings in the options dialog are correct (0x2000) for an 8Kb RAM chip. The compiler does not throw any error however, still the code does not execute on the chip... Maybe this .map of the bugging file will help you figure out my problem :
19444 1454 2988 164 108 18048 Library Totals 40 0 10 1 0 0 (incl. Padding)
----------------------------------------------------------------------
Code (inc. data) RO Data RW Data ZI Data Debug Library Name
5314 384 1421 87 40 5376 cpp_ps.l 730 28 20 0 0 1604 cpprt_p.l 4910 766 1404 48 28 5356 mbed.ar 6680 242 133 28 40 4308 mc_p.l 1770 34 0 0 0 1404 mf_p.l
---------------------------------------------------------------------- 19444 1454 2988 164 108 18048 Library Totals
==============================================================================
Code (inc. data) RO Data RW Data ZI Data Debug
33112 2372 3380 212 7504 549914 Grand Totals 33112 2372 3380 212 7504 549914 ELF Image Totals 33112 2372 3380 212 0 0 ROM Totals
Total RO Size (Code + RO Data) 36492 ( 35.64kB) Total RW Size (RW Data + ZI Data) 7716 ( 7.54kB) Total ROM Size (Code + RO Data + RW Data) 36704 ( 35.84kB)
Thanks for your reply Andrew. My variable is declared as an 1'000 bytes array. It is show in the statistics.
Where did automatic come into it? In the original post, the OP clearly stated he had a heavier buffer and even showed the different map statistics with original ZI-data=6520 then after adding the 1000, ZI-data=7504. Allowing for possible alignment, that's probably close enough.
It's clear that the OP is simply running close to the limit on available RAM.
Stack overflow is a "great" way to have a program crash.
And the linker can't (normally) detect any stack overflow, unless the code is 100% free of any case of recursion (and the linker has access to a full call tree from inside the libraries).