cancel
Showing results for 
Search instead for 
Did you mean: 

Reducing SBSFU binary size

leeana
Associate III

My user application firmware is rather big. It runs on STM32G070, so I've adapted the example code from STM32G071. I've followed the example provided in AN5056 (see picture) to reduce the SBSFU size, it saved about 10 kB, but it is not enough (still overflows by about 5 kB).

The last row depicts the method that can give the most of saved space, but how I do it?

Does it mean to uncomment #define SECBOOT_DISABLE_SECURITY_IPS? Or something else?0693W00000FCWxTQAX.png

4 REPLIES 4
Frantz LEFRERE
ST Employee

In fact the MPU constraint is describe in

https://www.st.com/resource/en/application_note/dm00414677-integration-guide-for-the-xcubesbsfu-stm32cube-expansion-package-stmicroelectronics.pdf

3.2 Memory mapping definition

Figure 4. Mapping constraints with MPU isolation (NUCLEO-G071RB example)

To deactivate the MPU protection you just need to comment the following define in app_sfu.h

#define SFU_MPU_PROTECT_ENABLE   /*!< MPU protection:

                    Enables/Disables the MPU protection.

                    If Secure Engine isolation is ensured by MPU (see SFU_ISOLATE_SE_WITH_MPU in

                    SE_CoreBin\Inc\se_low_level.h), then this switch also enables/disables it, in

                    addition to the overall MPU protection. */

Jocelyn RICARD
ST Employee

Hello @leeana​ 

The last line is only about MPU.

So, if you deactivate MPU protection (but not other protections indeed :)) you can get rid of the associated memory alignment constraints.

So, you can check your SBSFU binary generated to look for gaps between predefined regions. Then you can adapt the linker file to put for instance the SBSFU just after the secure engine. In your case, I'm not sure you will gain that much.

Other way to gain space is check in the map file the functions, especially HAL that are using space. I'm thinking for example to HAL RCC related functions that are made to support all possible RCC configurations. So, they are not optimized You can replace the SBSFU clock setting by using LL calls. This will not gain 5K but at least 1K.

Then you can check other functions starting from the most memory consuming in the map file to see how to optimize.

Best regards

Jocelyn

Thank you for the suggestion. It fact, MPU protection was already deactivated. I'll try what you've suggested and get back with the results.

Okay, the process was extremely hard, so I failed to do this. I didn't change the mapping files. But in my user app I've turned optimization on and used LL drivers, and it worked! Another issue showed up, but this particular question is solved.