PR to add optimisation menu (to all boards individually)

fpiSTM
Posts: 192
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: PR to add optimisation menu (to all boards individually)

Post by fpiSTM » Tue Sep 19, 2017 4:22 am

victor_pv wrote:
Mon Sep 18, 2017 8:36 pm
I actually had hoped that you would say it's ok to use it :(
I tried to use the DWT CYCNT for F103 but I do not succeed to write properly the DWT CTRL register. I think it locked by default (probably because I used STLink) so it required to be unlocked.

I found this nice example and think I'm in this case:
https://github.com/PetteriAimonen/STM32 ... mple.c#L35
but I did not checked.

fpiSTM
Posts: 192
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: PR to add optimisation menu (to all boards individually)

Post by fpiSTM » Tue Sep 19, 2017 2:40 pm

To conclude, by adding:

Code: Select all

uint32_t __attribute__((optimize("Os"))) pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
This will avoid any issue and allow to keep hardcoded clock cycle to 16 even if opt is changed.

User avatar
RogerClark
Posts: 6918
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: PR to add optimisation menu (to all boards individually)

Post by RogerClark » Tue Sep 19, 2017 8:51 pm

Has this been tested with gcc 4.x ?

fpiSTM
Posts: 192
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: PR to add optimisation menu (to all boards individually)

Post by fpiSTM » Wed Sep 20, 2017 8:19 am

I've tested on the BP with Arduino_STM32 repo.
without the fix, using O1 provide wrong value while with the fix it's ok.

Code: Select all

uint32_t __attribute__((optimize("Os"))) pulseIn( uint32_t pin, uint32_t state, uint32_t timeout )
of course with the 4.8.3 toolchain ;)

User avatar
RogerClark
Posts: 6918
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: PR to add optimisation menu (to all boards individually)

Post by RogerClark » Wed Sep 20, 2017 8:27 am

OK.

Thats interesting.

Thanks

fpiSTM
Posts: 192
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: PR to add optimisation menu (to all boards individually)

Post by fpiSTM » Thu Sep 21, 2017 12:49 pm

Welcome, I have also to thank you, I've added this PR to the Arduino_Core_STM32.
https://github.com/stm32duino/Arduino_C ... 2/pull/110
Very useful to avoid to edit platform.txt :)

Just one information for those using arm gcc 6-2017-q1-update to use LTO feature, it is required to use the arm gcc 6-2017-q2-update
previous one has a bug causing a segmentation fault during the build.

User avatar
RogerClark
Posts: 6918
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: PR to add optimisation menu (to all boards individually)

Post by RogerClark » Thu Sep 21, 2017 8:48 pm

No worries...


Re:LTO

I have not noticed any problems in gcc 4.x, except LTO does not always result in smaller or faster code.

Also, in LibMaple I have noticed enabling LTO shows some warnings during compilation, but they dont seem to effect the operation of the code.

fpiSTM
Posts: 192
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: PR to add optimisation menu (to all boards individually)

Post by fpiSTM » Fri Sep 22, 2017 5:30 am

Yes in fact it's a regression of the v6. so v4.8 is not impacted.

Post Reply