2021-02-11 10:43 PM
I created a motor control programm for the STM32G030K8 with the MCDSK Software and imported it into the STM32CubeIDE. The programm compiles and works fine on my hardware. When I try to allocate some data on the last 2k Page of the Flash I get an error-Message, telling me, that the Flash overflowed. For the code please see the attached pdf-file.
I have no idea, why this happens although the adress im writing to is within the adressrange of the 64k Flash-memory.
When I create an extra memory-space (please see attached pdf-file), using the same code, everything works fine.
Unfortunately I have not very much experience with the gcc linker yet. Can anyone tell me why one version works, while the other version leads to an error?
Thanks,
Andreas
Solved! Go to Solution.
2021-02-12 01:51 AM
The one fails because you suddenly advance the high water mark to the end of the section and it tries to put subsequent data after that point.
How much is before or after is determined by the order in which the linker encounters the items. If this data was in the last file the linker processed (in order) you wouldn't see the same issue.
2021-02-12 01:51 AM
The one fails because you suddenly advance the high water mark to the end of the section and it tries to put subsequent data after that point.
How much is before or after is determined by the order in which the linker encounters the items. If this data was in the last file the linker processed (in order) you wouldn't see the same issue.
2021-02-14 10:00 PM
Thank you very much. I moved ".mybufsection" to the end of the "SECTIONS" code space. Now it works fine. I was not aware, that the order of the statements within the code space matters that much. I always thought that the Linker would automatically arrange everything according to the given memory adresses.
2021-02-15 02:26 AM
While it is certainly possible to write multi pass and best fit linkers these are significantly more complex and slower, and prone to get stuck in loops.
Currently the preference is to do something more linear in a pass or two to get closure, and then eliminate dead code at a subroutine level. This is helped if the libraries and objects break down sections on a subroutine level granularity. Also if subroutines are limited in scope to a single file via static directive, the linker can discard during the initial pass of one object.