2019-09-10 02:41 AM
Hello!
I want to use Asymmetric Crypto algorithms like ECC or RSA for my FreeRTOS project running on STM32F051K8.
The controller has 64 KB of flash.
Since X-CUBE-CRYPTOLIB occupies quite large memory footprint, my FLASH is getting overflowed by the .text area, on linking the X-CUBE-CRYPTOLIB library.
I have made following changes to optimize the memory required for X-CUBE-CRYPTOLIB:
But still my flash is getting overflowed by around 7000 bytes.
Please tell me what else can I do for memory optimization?
Otherwise, I might have to change the microcontroller with big FLASH memory.
I also have attached error screenshot for the reference.
2019-09-10 03:00 AM
The library is provided in binary form so -Os will apply only to your own code, not the library.
You can try to enable link-time optimizations (LTO), but it has history of being error prone. Anyway, you can try it. If your IDE doesn't support it, you'll have to do it manually by adding "-flto" to both compiler and linker settings. Also adding "-ffunction-sections" and "-fdata-sections" (both compiler and linker settings), and "--gc-sections" (linker-only setting) will help too.
Alternatively, use other crypto libraries, like mbed-crypto, micro-ecc, TinyECC, cifra