Downsizing the TFM with PSA support

Hi,

I am developing application on NRF9160 right now.

When I trying to enable AES CTR enc/dec follow the aes_ctr sample in my application, I got the FLASH overflow error.

I realized it cause by the TFM size increase from 48kB to 256kB after enable CONFIG_TFM_PROFILE_TYPE_NOT_SET.

flash_primary (0x100000 - 1024kB):
+--------------------------------------------------+
| 0x0: mcuboot (0xc000 - 48kB) |
| 0xc000: EMPTY_0 (0x4000 - 16kB) |
+---0x10000: mcuboot_primary (0x70000 - 448kB)-----+
+---0x10000: tfm_secure (0x40200 - 256kB)----------+
| 0x10000: mcuboot_pad (0x200 - 512B) |
+---0x10200: mcuboot_primary_app (0x6fe00 - 447kB)-+
| 0x10200: tfm (0x40000 - 256kB) |
+---0x50200: tfm_nonsecure (0x2fe00 - 191kB)-------+
| 0x50200: app (0x2fe00 - 191kB) |
+--------------------------------------------------+
| 0x80000: mcuboot_secondary (0x70000 - 448kB) |
+---0xf0000: nonsecure_storage (0x2000 - 8kB)------+
| 0xf0000: settings_storage (0x2000 - 8kB) |
+--------------------------------------------------+
| 0xf2000: EMPTY_1 (0x6000 - 24kB) |
+---0xf8000: tfm_storage (0x8000 - 32kB)-----------+
| 0xf8000: tfm_its (0x2000 - 8kB) |
| 0xfa000: tfm_otp_nv_counters (0x2000 - 8kB) |
| 0xfc000: tfm_ps (0x4000 - 16kB) |
+--------------------------------------------------+

That cause the app image size limit down to 191kB, and that is not enough for my application.

Can you give me some advices how to down szie the tfm image or another approach to avoid the FLASH overflow?

The feature I required it just the AES 128 CTR enc/dec and key import.

Thanks.

(ps. I already disable the debug build option, and I need the DFU for firmware upgrade support)

Parents Reply
  • Hi,

    The team working with our TF-M implementation have optimization on their agenda but it is an ongoing process. However, for now there is no straight-forward way to do this and the suggestion at this time is to do a graphical diff of the build before and after minimal config was changed and first look for changes in build/zephyr/.config. Maybe some of the TF-M features aren't needed by the application. After that I would inspect the CMakeCache.txt of the TF-M build, and after that the .map file of TF-M.

Children
Related