Page 1 of 2
Optimization level 1 and s do not work with STM32F051 demo
Posted: Sun Oct 21, 2012 2:46 pm
by bobc
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
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 4:28 pm
by Giovanni
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
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 4:54 pm
by Giovanni
Fixed on the repository.
Giovanni
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 6:17 pm
by barthess
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.
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 6:43 pm
by Giovanni
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
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 7:50 pm
by barthess
Giovanni wrote:doing so kills the MCU performance.
hm... for the first look performance does not affected at all.
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 8:02 pm
by Giovanni
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
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 8:24 pm
by barthess
From stm32f4 errata:
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?
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 8:34 pm
by Giovanni
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
Re: Optimization level 1 and s do not work with STM32F051 de
Posted: Sun Oct 21, 2012 8:44 pm
by barthess
Yes, my device is rev.A