How to reduce the RAM size of TF-M

Hello,

Along the lines of this question about flash size, I’m looking to reduce the TF-M partition RAM usage to gain some space in my application partition. Here are the current reports of my application (MbedTLS is taking a lot of RAM space in my application, and I require that in order to do secure TCP connections to AWS using an Ethernet controller):

[53/57] Linking C executable bin\tfm_s.axf
Memory region         Used Size  Region Size  %age Used
           FLASH:      163136 B       256 KB     62.23%
             RAM:       56752 B        88 KB     62.98%

[441/443] Linking C executable zephyr\zephyr.elf
Memory region         Used Size  Region Size  %age Used
           FLASH:      566312 B       640 KB     86.41%
             RAM:      150637 B     154264 B     97.65%
        IDT_LIST:          0 GB         2 KB      0.00%

I have checked the docs but haven’t yet found a way to transfer some of those 88 kB from one partition to the other. It seems configuring addresses in the device tree doesn’t do anything:

/ {
	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		// Default SRAM planning when building for nRF9160 with
		// ARM TrustZone-M support
		// - Lowest 88 kB SRAM allocated to Secure image (sram0_s).
		// - 40 kB SRAM reserved for and used by the modem library
		//   (sram0_modem). This memory is Non-Secure.
		// - Upper 128 kB allocated to Non-Secure image (sram0_ns).
		//   When building with TF-M, both sram0_modem and sram0_ns
		//   are allocated to the Non-Secure image.
		sram0_s: image_s@20000000 {
			/* Secure image memory */
			//reg = <0x20000000 DT_SIZE_K(88)>;
			reg = <0x20000000 DT_SIZE_K(68)>;
		};

		//sram0_modem: image_modem@20016000 {
		sram0_modem: image_modem@20011000 {
			/* Modem (shared) memory */
			//reg = <0x20016000 DT_SIZE_K(40)>;
			reg = <0x20011000 DT_SIZE_K(40)>;
		};

		//sram0_ns: image_ns@20020000 {
		sram0_ns: image_ns@2001B000 {
			/* Non-Secure image memory */
			//reg = <0x20020000 DT_SIZE_K(128)>;
			reg = <0x2001B000 DT_SIZE_K(148)>;
		};
	};
};

Any idea where to configure this? Thanks!

Related