2022-07-10 07:17 PM
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.
2022-07-13 05:38 AM
Hi @SSpen
I have not seen the Segment[0] issue, but some of the symptoms are consistent with problems I’ve had with stm32G0 system booting into system memory (bootloader).
If not done already, I’d recommend checking registers to ensure that “flash empty�? is not causing issues.
2022-07-24 10:11 PM
Interesting. Something I've found too is that with a default code generation from cube, literally nothing else going on, the SysTick interrupt handler is never called, so a generic main.c with a HAL_Delay() call completely stalls with the systick value = 0. I wonder if there is an underlying bug in the Cube generation.
2022-08-09 03:36 PM
**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.
2022-08-17 10:42 PM
EDIT 3
Turns out it is simply when the program compiles to over 50% of the available flash on the 256K variant (64 sectors or 128K). I really hope this can be fixed