I started working with various ATSAM devices in AS7 after a decade of so of AVR; and one of the things that's been really bugging me, is understanding the memory usage output from Studio.
Two main questions:
1) I thought I understood that the stack size is set by __stack_size__ in the linker scripts generated by Studio (as per this), but - it doesn't appear to be. Changing the __stack_size__ changes the size of bss memory section. Why?
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\arm\arm-gnu-toolchain\bin\arm-none-eabi-size.exe" "x.elf" text data bss dec hex filename 1272 1076 8260 10608 2970 x.elf Done executing task "RunCompilerTask". Task "RunOutputFileVerifyTask" Program Memory Usage : 2348 bytes 0.9 % Full Data Memory Usage : 9336 bytes 28.5 % Full Warning: Memory Usage estimation may not be accurate if there are sections other than .text sections in ELF file Done executing task "RunOutputFileVerifyTask".
2) Statically allocated variables initialised to zero do not seem to cause an increase in the .data section size, as expected (expected, by me at least - not to say that is correct) - but rather in the .bss. My understanding was .data was for initialised variables, and .bss was not for uninitialized variables. The top rated answer on this Stackoverflow post suggests arrays initialised to 0 always end up in .bss, not .data. I can prove this easily just by initialising any element of an array to non-zero, and the array ends up in .data, not .bss. So perhaps this is a more generic question that I thought, why do zero initialised arrays end up in .bss? Is this implementation defined, or hardware dependant?