Adding user code to STM32G0B1KC main.c boots to a random address with Error: failed to download Segment[0]
Not quite sure how to best document this problem. But I am porting a current project of mine from an STM32G4 to STM32G0. All of the peripherals are configured correctly and the code base is mature and running well.
When I debug the project with no user function calls in main.c, everything is fine but obviously nothing happens. When I add a call to my user function, it resets to a hard fault, shows an error in the debug launcher (Error: failed to download Segment[0]), and all kinds of strange things happen such as entering halfway through a random function. Is this a bug in the Cube generation or am I missing something?
EDIT 1:
Here is an example of the execution trace when the debug is initializing. I've had success bringing some lines of code from my external file into the main.c loop, but due to the project structure it is very difficult to bring more than I have in to test (a few peripheral calls etc...). But then when calling my external init and main functions, it all goes wrong again. I just updated to the latest version of CubeIDE (1.10.1 I believe), and it didn't fix anything.
**EDIT 2**
I've traced the issue down to a particular function which, when compiled, causes the error to download and various issues. It's a strcat call that when commented out, the 'failed to download Segment[0]' error goes away. It's just concatenating a '}' character to a local char array within that function.
