cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030K8 Linker-error When I modify the linkerfile for absolute adressing of a variable within the Flash-Memory I get an unexpected Error "FLASH' overflowed by 31912 bytes".

ASatt.1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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.

H​ow 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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

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.

H​ow 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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ASatt.1
Associate II

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.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..