Optimization level 1 and s do not work with STM32F051 demo
Moderators: RoccoMarco, lbednarz, tfAteba
Optimization level 1 and s do not work with STM32F051 demo
Hi there,
I am using the STM32F051-DISCOVERY example. I find that when setting optimization to level 1 or s, the demo does not run. The demo works find when optimization is set to 0 or 2.
I am guessing this is probably similar issue to previous problems caused by optimization (an exception occurs and the demo hangs). I haven't managed to get my debugger going on it, so I am just going by the state of the LEDs.
I using latest ChibiOS from the github master branch. Compiler is "(Sourcery G++ Lite 2011.03-42) 4.5.2".
Are there any ideas of how to resolve this? I would really like to use -Os in my project, there never seems to be enough Flash...
Cheers
I am using the STM32F051-DISCOVERY example. I find that when setting optimization to level 1 or s, the demo does not run. The demo works find when optimization is set to 0 or 2.
I am guessing this is probably similar issue to previous problems caused by optimization (an exception occurs and the demo hangs). I haven't managed to get my debugger going on it, so I am just going by the state of the LEDs.
I using latest ChibiOS from the github master branch. Compiler is "(Sourcery G++ Lite 2011.03-42) 4.5.2".
Are there any ideas of how to resolve this? I would really like to use -Os in my project, there never seems to be enough Flash...
Cheers
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Optimization level 1 and s do not work with STM32F051 de
Hi,
Thanks for reporting, I found the problem in crt0.c. You can set CRT0_INIT_STACKS=0 as workaround, in the meanwhile I will open a ticket and handle this.
I think this is the cause of all the similar optimizations-related problems.
Giovanni
Thanks for reporting, I found the problem in crt0.c. You can set CRT0_INIT_STACKS=0 as workaround, in the meanwhile I will open a ticket and handle this.
I think this is the cause of all the similar optimizations-related problems.
Giovanni
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Optimization level 1 and s do not work with STM32F051 de
Does not help me.
Moving __early_init() call after stack initialization code too.
Looks like disabling FLASH_ACR_ICEN or FLASH_ACR_DCEN bits when initializing
flash access in hal_lld.c helps.
UPD:
That bits must be both disabled.
Moving __early_init() call after stack initialization code too.
Looks like disabling FLASH_ACR_ICEN or FLASH_ACR_DCEN bits when initializing
flash access in hal_lld.c helps.
UPD:
That bits must be both disabled.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Optimization level 1 and s do not work with STM32F051 de
You are right, __early_init() must be moved too, I don't understand the issue with those bits, doing so kills the MCU performance.
Giovanni
Giovanni
Re: Optimization level 1 and s do not work with STM32F051 de
Giovanni wrote:doing so kills the MCU performance.
hm... for the first look performance does not affected at all.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Optimization level 1 and s do not work with STM32F051 de
But those bits should not affect anything, so it is possible you are masking the effect but there is another cause.
After moving __early_init() I don't see other problems in all demos I tested, let's wait some more feedback.
Giovanni
After moving __early_init() I don't see other problems in all demos I tested, let's wait some more feedback.
Giovanni
Re: Optimization level 1 and s do not work with STM32F051 de
From stm32f4 errata:
Is it our problem?
2.1.1 ART Accelerator prefetch queue instruction is not supported
Description
The ART Accelerator prefetch queue instruction is not supported on revision A devices.
This limitation does not prevent the ART Accelerator from using the cache enable/disable
capability and the selection of the number of wait states according to the system frequency.
Workaround
Revision A devices: none
Revision Z devices: fixed.
Is it our problem?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Optimization level 1 and s do not work with STM32F051 de
Do you have a revision A device? I am not sure if the unit is simply not functional or if it should not be enabled at all.
Giovanni
Giovanni