Release build won't run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 1: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.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-14 8: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 1:33 AM
Look at what's different between your Release and Debug versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 3: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 3: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 4:08 AM
Thanks again for your reply.
The compiler instructions are within the attached file...
I hope this helps.
Kind regards
Pedro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 4: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 7: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 7:30 AM - edited ‎2024-04-11 7: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 ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 8: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-04-11 8: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
