2024-04-11 01:15 AM
Hi all,
I have a simple project using a STM32C011J4. Using STM32CubeIDE V1.15. I compile it for both Debug & Release.
I program it via STM32Programmer V2.10.
The Debug elf file works okay, however, the Release elf does NOT run…
Yes! I have checked that the Debug & Release files are up to date (and time)...
Yes! The NRST pin is correct level…
What else should I check?
Kind regards
Pedro
Solved! Go to Solution.
2024-04-14 08:58 PM
Hi all,
I'm happy to report that 'volatile' has fixed it! @Andrew Neil thank you for planting that seed.
@MM..1 using Debug as Release is a waste of resources, particularly in parts with very limited resources.
Anyway, if I hadn't been so lazy, I would have coded it up in assembler, and saved myself a week... :face_with_tears_of_joy:
Kind regards
Pedro
2024-04-11 01:33 AM
Look at what's different between your Release and Debug versions
2024-04-11 03:19 AM
Thank you for your reply.
There is no difference in the c code for the Release and Debug versions.
STM32CubeProgrammer reports Debug elf contains approx 2900 bytes, and 1050 bytes for the Release elf.
The only difference is the compiler options set by STM32CudeIDE.
Kind regards
Pedro
2024-04-11 03:26 AM
@PGump.1 wrote:There is no difference in the c code for the Release and Debug versions.
No conditional compilation; including things like ASSERT - which will behave differently between release & debug ?
@PGump.1 wrote:The only difference is the compiler options set by STM32CudeIDE.
So what is/are the difference(s) there?
2024-04-11 04:08 AM
2024-04-11 04:24 AM
PS: HAL functions are only called during initialization, as per STM32CubeMX code generator.
I'm not calling any HAL functions in my portion of the code.
Other than Systick(), there are no interrupts.
Watchdogs are not enabled (yet).
Kind regards
Pedro
2024-04-11 07:26 AM
So here's the differences:
-g3 enables debug info in the ELF file:
You could start by enabling that in the Release config, and then use the debugger to investigate what's going on.
-Os enables optimisation for size:
When changing (especially increasing) the optimisation level breaks your code, it usually indicates that there are latent bugs; eg, volatile missing where it should have been used.
2024-04-11 07:30 AM - edited 2024-04-11 07:36 AM
@Andrew Neil wrote:No conditional compilation; including things like ASSERT - which will behave differently between release & debug ?
You didn't address that question.
One way to check that would be to just define the DEDUG symbol in the Release build - change nothing else.
If that changes the behaviour, then you do have conditional code somewhere ...
2024-04-11 08:03 AM
Thank you for that informative reply.
This is stock solution using STM32CubeMX. I haven't made any changes to the compile options.
You could start by enabling that in the Release config, and then use the debugger to investigate what's going on.
I would like to do that, however, there's an issue with STM32CubeIDE V1.15, see
When changing (especially increasing) the optimisation level breaks your code, it usually indicates that there are latent bugs; eg, volatile missing where it should have been used.
"volatile" maybe an issue... I'll try that tomorrow...
Kind regards
Pedro
2024-04-11 08:13 AM
PS: I have not added any conditional compiling. Any conditional compiling is due to STM32CubeMX code generator.
As far as I'm aware, in this application, only HAL functions use ASSERT. Apart from the initialization code (generated by STM32CubeMX) I'm not calling any HAL functions...
Kind regards
Pedro