This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

pstorage - pstorage_block_identifier_get() and GCC flags -Os -O0 -flto

Hello!

I have encountered an interesting issue:

When I use compiler flags (GCC CFLAGS) -Os or -O0 together with -flto the pstorage function pstorage_block_identifier_get() fails with error NRF_ERROR_INVALID_PARAM.

If I remove the -flto or if I use it together with -O3 it works fine again.

  • Any idea why?
  • Is it a good idea to use -flto flag? When? (I am confused about this)

I am using SDK9.0.0 and S130 softdevice with nrf51 (16KB RAM / 256 FLASH)

Thanks!

Parents
  • Hi,

    -flto is a link time optimization in GCC that enables the linker to perfom optimization as if all function bodies were actually in one single file. If you are very constrained with flash, this option can help reduce the ROM size of you project.

    -Os performs a compile time optimization, which favors size.

    The SDK is tested using -O3, so strictly speaking -O3 is the safest :) Combining -Os and -flto is a very aggressive optimization and can have side effects.

    My guess is that the variable m_app_table in pstorage.c is not properly initialized at startup. It may help to try to manually zero it during initialization.

Reply
  • Hi,

    -flto is a link time optimization in GCC that enables the linker to perfom optimization as if all function bodies were actually in one single file. If you are very constrained with flash, this option can help reduce the ROM size of you project.

    -Os performs a compile time optimization, which favors size.

    The SDK is tested using -O3, so strictly speaking -O3 is the safest :) Combining -Os and -flto is a very aggressive optimization and can have side effects.

    My guess is that the variable m_app_table in pstorage.c is not properly initialized at startup. It may help to try to manually zero it during initialization.

Children
No Data
Related