2024-02-14 09:56 AM
Hi,
Though my current work is on a Nucleo-STM32G070 board, I am going to target on multiple STM32MCUs later, and I would like to know the macro definition so that my code would be more adaptive to different target processors.
The ld file gives following information:
but the stm32g070xx.h gives different size of the RAM:
Anyone could explain it? And which macro I should use for the highest address of the RAM?
Regards
Chao
2024-02-14 10:14 AM - edited 2024-02-14 10:24 AM
The explanation of 32 vs. 36 KiB may be found in the Reference Manual. The software uses the linker-defined _estack symbol as stack bottom location. You may reconfigure the MCU and edit the linker file to change the amount of RAM available to software to 36 KiB.
Correction: This is supervisor mode stack in no-OS environment. User mode stacks are normally used by RTOS threads only.
2024-02-14 11:06 AM
In this case, the SRAM size depends on if you have parity enabled or not.
If it is disabled, you have 36 kB. If it is enabled, you have 32 kB.
Parity is enabled/disabled in the option bytes, which you can access with STM32CubeProgrammer.
As @gbm mentioned, _estack is the top of the stack, and memory gets allocated starting just below that point.
2024-02-14 12:20 PM
It's not a macro, it's a computation the linker can do, referencing the length you specified for the memory section/region in question.
Here's some documentation, if that's helpful, or you're unfamiliar with finding such things.
https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html
https://sourceware.org/binutils/docs/ld/Builtin-Functions.html
The SP/R13 auto-decrements, but needs/expects alignment, so pointing at the byte beyond the end is Ok.
ie 0x20009000 is Ok, 0x20008FFF would not be