No init memory configuration with SPU.

Hi!
I am developing project with nrf connect sdk 2.9.0 on nrf9160 platform. This is multi image project (b0 + mcuboot + tfm + non-secure application).
I needed to configure noinit section for one of software compontents.
Requirements were:
- This section has to always be in the same spot regardless of firmware version.
- This section cannot be used by image other than application.

I found this ticket, which was very helpful and directed me to zephyr, retention.

Based on these tickets I configured retention memory partition at the end of RAM as follows:

/ {
	app_noinit: sram@2003E800 {
		compatible = "zephyr,memory-region";
		reg = <0x2003E800 0x1800>;
		zephyr,memory-region = "app_noinit";
		status = "okay";

		retainedmem {
			compatible = "zephyr,retained-ram";
			status = "okay";
			#address-cells = <1>;
			#size-cells = <1>;

			section0: retention@0 {
				compatible = "zephyr,retention";
				status = "okay";
				reg = <0x0 0x800>;
			};

			section1: retention@800 {
				compatible = "zephyr,retention";
				status = "okay";
				reg = <0x800 0x14>;
			};
		};

	};
};
/* Reduce SRAM0 to isolate the defined memory regions */
&sram0 {
        reg = <0x20000000 0x3E800>;
};


which works fine. However after changing the size from 0x1800 to 0x2000, I can't access the memory.
I am getting 'attribute unit violation' hard fault.

I've done some reading and I believe this might be due to SPU. I found that in .config file:

CONFIG_NRF_SPU_RAM_REGION_SIZE=0x2000


I believe that since range <0x2003E000, 0x20040000> was excluded from sram0 in devictree, the last block might not be assigned to ns app by SPU.

I've done further test to confirm my hypothesis. I set section size to 8192 + 2048. I was able to access the first 2048 bytes but not latter 8192.

I think that if retention section size is smaller than SPU block size, it has to grant access to the entire block. So memory is available anyways.
Otherwise, entire memory or part of it is not available.

TLDR: I think that retention memory is not available in the non-secure app due to SPU protection.

My question: Is there a way to achieve partitioning that I want with the entire memory being accessible?

Kind Regards,
Piotr

Related