Increase secure storage maximum asset size

Increase the maximum asset size of the secure flash storage so the fTPM
non-volatile backend file fits into a single asset.

Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: Ibba8828393b2932fa5f2d1bc9462ca1bfe6518fe
diff --git a/components/service/secure_storage/backend/secure_flash_store/flash/ram/component.cmake b/components/service/secure_storage/backend/secure_flash_store/flash/ram/component.cmake
index 385514d..eb70f9c 100644
--- a/components/service/secure_storage/backend/secure_flash_store/flash/ram/component.cmake
+++ b/components/service/secure_storage/backend/secure_flash_store/flash/ram/component.cmake
@@ -12,6 +12,14 @@
 	target_compile_definitions(${TGT} PRIVATE SFS_FLASH_AREA_SIZE=${CFG_SFS_FLASH_AREA_SIZE})
 endif()
 
+if(DEFINED CFG_SFS_SECTORS_PER_BLOCK)
+	target_compile_definitions(${TGT} PRIVATE SFS_SECTORS_PER_BLOCK=${CFG_SFS_SECTORS_PER_BLOCK})
+endif()
+
+if(DEFINED CFG_SFS_MAX_ASSET_SIZE)
+	target_compile_definitions(${TGT} PRIVATE SFS_MAX_ASSET_SIZE=${CFG_SFS_MAX_ASSET_SIZE})
+endif()
+
 target_sources(${TGT} PRIVATE
 	"${CMAKE_CURRENT_LIST_DIR}/sfs_flash_info.c"
 	"${CMAKE_CURRENT_LIST_DIR}/sfs_flash_ram.c"
diff --git a/components/service/secure_storage/backend/secure_flash_store/flash/ram/sfs_flash_info.c b/components/service/secure_storage/backend/secure_flash_store/flash/ram/sfs_flash_info.c
index ced737e..b6f005e 100644
--- a/components/service/secure_storage/backend/secure_flash_store/flash/ram/sfs_flash_info.c
+++ b/components/service/secure_storage/backend/secure_flash_store/flash/ram/sfs_flash_info.c
@@ -19,13 +19,17 @@
 #define SFS_SECTOR_SIZE (0x1000)
 
 /* Adjust so that the maximum required asset size will fit in one block */
+#ifndef SFS_SECTORS_PER_BLOCK
 #define SFS_SECTORS_PER_BLOCK (0x1)
+#endif
 
 /* Adjust to match the size of the flash device's physical program unit */
 #define SFS_FLASH_PROGRAM_UNIT (0x1)
 
 /* The maximum asset size to be stored in the SFS area */
+#ifndef SFS_MAX_ASSET_SIZE
 #define SFS_MAX_ASSET_SIZE (4096)
+#endif
 
 /* The maximum number of assets to be stored in the SFS area */
 #define SFS_NUM_ASSETS (10)
diff --git a/components/service/secure_storage/backend/secure_flash_store/secure_flash_store.c b/components/service/secure_storage/backend/secure_flash_store/secure_flash_store.c
index 646ed15..37fa44f 100644
--- a/components/service/secure_storage/backend/secure_flash_store/secure_flash_store.c
+++ b/components/service/secure_storage/backend/secure_flash_store/secure_flash_store.c
@@ -13,7 +13,9 @@
 #include <string.h>
 #include <stddef.h>
 
+#ifndef SFS_MAX_ASSET_SIZE
 #define SFS_MAX_ASSET_SIZE (4096) /* TODO: comes from flash layout */
+#endif
 #define SFS_CREATE_FLASH_LAYOUT /* TODO: move this to a proper place */
 
 #define SFS_INVALID_UID 0 /* TODO: are there any invalid UID-s? */
diff --git a/components/service/secure_storage/factory/sp/rot_store/component.cmake b/components/service/secure_storage/factory/sp/rot_store/component.cmake
index b06adb5..3d51522 100644
--- a/components/service/secure_storage/factory/sp/rot_store/component.cmake
+++ b/components/service/secure_storage/factory/sp/rot_store/component.cmake
@@ -8,7 +8,10 @@
 	message(FATAL_ERROR "mandatory parameter TGT is not defined.")
 endif()
 
+if(DEFINED CFG_STORAGE_CLIENT_RPC_BUF_SIZE)
+	target_compile_definitions(${TGT} PRIVATE STORAGE_CLIENT_RPC_BUF_SIZE=${CFG_STORAGE_CLIENT_RPC_BUF_SIZE})
+endif()
+
 target_sources(${TGT} PRIVATE
 	"${CMAKE_CURRENT_LIST_DIR}/storage_factory.c"
 	)
-
diff --git a/components/service/secure_storage/factory/sp/rot_store/storage_factory.c b/components/service/secure_storage/factory/sp/rot_store/storage_factory.c
index ed0b999..05915f9 100644
--- a/components/service/secure_storage/factory/sp/rot_store/storage_factory.c
+++ b/components/service/secure_storage/factory/sp/rot_store/storage_factory.c
@@ -26,6 +26,10 @@
 #include <stdbool.h>
 #include <stddef.h>
 
+#ifndef STORAGE_CLIENT_RPC_BUF_SIZE
+#define STORAGE_CLIENT_RPC_BUF_SIZE (4096)
+#endif
+
 /* Defaults to using PSA storage partitions if no external configuration specified */
 #define MAX_CANDIDATE_UUIDS		(2)
 
@@ -76,7 +80,8 @@
 		for (int i = 0; i < num_candidate_uuids; i++) {
 			rpc_status = rpc_caller_session_find_and_open(&new_backend->session,
 								      &new_backend->caller,
-								      candidate_uuids[i], 4096);
+								      candidate_uuids[i],
+								      STORAGE_CLIENT_RPC_BUF_SIZE);
 
 			if (rpc_status == RPC_SUCCESS) {
 				result = secure_storage_client_init(
diff --git a/platform/providers/arm/fvp/fvp_base_revc-2xaemv8a/platform.cmake b/platform/providers/arm/fvp/fvp_base_revc-2xaemv8a/platform.cmake
index c71ed09..dca90cc 100644
--- a/platform/providers/arm/fvp/fvp_base_revc-2xaemv8a/platform.cmake
+++ b/platform/providers/arm/fvp/fvp_base_revc-2xaemv8a/platform.cmake
@@ -13,7 +13,12 @@
 	PROPERTY TS_PLATFORM_DRIVER_DEPENDENCIES
 )
 
-set(CFG_SFS_FLASH_AREA_SIZE "32*1024" CACHE STRING "Size of SFS ram store")
+set(CFG_SFS_FLASH_AREA_SIZE "128*1024" CACHE STRING "Size of SFS ram store")
+set(CFG_SFS_SECTORS_PER_BLOCK "4" CACHE STRING "Number of sectors per block in the SFS ram store")
+set(CFG_SFS_MAX_ASSET_SIZE "16*1024" CACHE STRING "Max asset size of SFS ram store")
+
+# Set the RPC buffer size of the storage client so the maximum supported asset size can be transmitted
+set(CFG_STORAGE_CLIENT_RPC_BUF_SIZE "${CFG_SFS_MAX_ASSET_SIZE} + 4096" CACHE STRING "RPC buffer size of storage client")
 
 # Test memory region base address for manifest testing in spm_test deployments.
 set(CFG_TEST_MEM_REGION_ADDRESS  0x6248000 CACHE STRING "Base address of memory region used to test mainfest processing.")