SST: Add SST_CREATE_FLASH_LAYOUT flag
This patch renames the SST_RAM_FS flag to SST_CREATE_FLASH_LAYOUT
and clarifies its meaning. This flag indicates that it is required
to create an empty SST flash layout.
The patch also updates the SST integration guide accordingly.
Change-Id: I811aea986db351451042bdc70a47f1736b5b385b
Signed-off-by: Marc Moreno <marc.morenoberengue@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index 78993f6..954fce8 100755
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -191,8 +191,8 @@
set (SST_ENCRYPTION ON)
endif()
- if (NOT DEFINED SST_RAM_FS)
- set (SST_RAM_FS OFF)
+ if (NOT DEFINED SST_CREATE_FLASH_LAYOUT)
+ set (SST_CREATE_FLASH_LAYOUT OFF)
endif()
if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
diff --git a/docs/user_guides/services/tfm_sst_integration_guide.md b/docs/user_guides/services/tfm_sst_integration_guide.md
old mode 100755
new mode 100644
index 3c7b497..774d3df
--- a/docs/user_guides/services/tfm_sst_integration_guide.md
+++ b/docs/user_guides/services/tfm_sst_integration_guide.md
@@ -384,9 +384,15 @@
storage service.
- `SST_ENCRYPTION`: this flag allows to enable/disable encryption option to
encrypt the secure storage data.
- - `SST_RAM_FS`: this flag allows to compile in/out the current flash interface
- based on a memory map. This is useful to test SST service without reducing
- the flash lifetime.
+ - `SST_CREATE_FLASH_LAYOUT`: this flag indicates that it is required to
+ create a SST flash layout. If this flag is set, SST service will generate an
+ empty and valid SST flash layout to store assets. It will erase all data
+ located in the assigned SST memory area before generating the SST layout.
+ This flag is required to be set if the SST memory area is located in a
+ non-persistent memory.
+ This flag can be set if the SST memory area is located in a persistent
+ memory without a valid SST flash layout in it. That is the case when
+ it is the first time in the device life that the SST service is executed.
- `SST_VALIDATE_METADATA_FROM_FLASH`: this flag allows to enable/disable the
validation mechanism to check the metadata store in flash every time the
flash data is read from flash. This validation is required if the flash is
diff --git a/platform/ext/Mps2AN519.cmake b/platform/ext/Mps2AN519.cmake
index a9d1144..31f4d15 100755
--- a/platform/ext/Mps2AN519.cmake
+++ b/platform/ext/Mps2AN519.cmake
@@ -142,10 +142,10 @@
# There is no real flash memory for code on MPS2 board. Instead a code SRAM is
# used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash
# interface and behaviour on top of the SRAM memory.
- # As the SST area is going to be in RAM, it is required to set SST_RAM_FS to be sure the
- # SST service knows that when it starts the SST area does not contain any valid block and
- # it needs to create an empty one.
- set(SST_RAM_FS True)
+ # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
+ # to be sure the SST service knows that when it starts the SST area does not contain any
+ # valid SST flash layout and it needs to create one.
+ set(SST_CREATE_FLASH_LAYOUT ON)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE)
endif()
diff --git a/platform/ext/Mps2AN521.cmake b/platform/ext/Mps2AN521.cmake
index ec4d194..97d28d8 100755
--- a/platform/ext/Mps2AN521.cmake
+++ b/platform/ext/Mps2AN521.cmake
@@ -143,10 +143,10 @@
# There is no real flash memory for code on MPS2 board. Instead a code SRAM is
# used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash
# interface and behaviour on top of the SRAM memory.
- # As the SST area is going to be in RAM, it is required to set SST_RAM_FS to be sure the
- # SST service knows that when it starts the SST area does not contain any valid block and
- # it needs to create an empty one.
- set(SST_RAM_FS True)
+ # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
+ # to be sure the SST service knows that when it starts the SST area does not contain any
+ # valid SST flash layout and it needs to create one.
+ set(SST_CREATE_FLASH_LAYOUT ON)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers" ABSOLUTE)
endif()
diff --git a/platform/ext/musca_a.cmake b/platform/ext/musca_a.cmake
index 8c5b9ea..78434fe 100755
--- a/platform/ext/musca_a.cmake
+++ b/platform/ext/musca_a.cmake
@@ -143,10 +143,10 @@
message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
elseif(BUILD_FLASH)
list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_Flash.c")
- # As the SST area is going to be in RAM, it is required to set SST_RAM_FS to be sure the
- # SST service knows that when it starts the SST area does not contain any valid block and
- # it needs to create an empty one.
- set(SST_RAM_FS True)
+ # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
+ # to be sure the SST service knows that when it starts the SST area does not contain any
+ # valid SST flash layout and it needs to create one.
+ set(SST_CREATE_FLASH_LAYOUT ON)
embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE)
embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
endif()
diff --git a/secure_fw/services/secure_storage/CMakeLists.inc b/secure_fw/services/secure_storage/CMakeLists.inc
index fa2f4c8..735c078 100644
--- a/secure_fw/services/secure_storage/CMakeLists.inc
+++ b/secure_fw/services/secure_storage/CMakeLists.inc
@@ -39,8 +39,8 @@
message(FATAL_ERROR "Incomplete build configuration: SST_ENCRYPTION is undefined. ")
endif()
- if (NOT DEFINED SST_RAM_FS)
- message(FATAL_ERROR "Incomplete build configuration: SST_RAM_FS is undefined. ")
+ if (NOT DEFINED SST_CREATE_FLASH_LAYOUT)
+ message(FATAL_ERROR "Incomplete build configuration: SST_CREATE_FLASH_LAYOUT is undefined. ")
endif()
if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
@@ -71,8 +71,8 @@
set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_VALIDATE_METADATA_FROM_FLASH)
endif()
- if (SST_RAM_FS)
- set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_RAM_FS)
+ if (SST_CREATE_FLASH_LAYOUT)
+ set_property(SOURCE ${SECURE_STORAGE_C_SRC} APPEND PROPERTY COMPILE_DEFINITIONS SST_CREATE_FLASH_LAYOUT)
endif()
if (SST_ENABLE_PARTIAL_ASSET_RW)
diff --git a/secure_fw/services/secure_storage/sst_asset_management.c b/secure_fw/services/secure_storage/sst_asset_management.c
index ce93b45..fd156b1 100644
--- a/secure_fw/services/secure_storage/sst_asset_management.c
+++ b/secure_fw/services/secure_storage/sst_asset_management.c
@@ -220,17 +220,28 @@
}
err = sst_system_prepare();
-#ifdef SST_RAM_FS
- /* in case of RAM based system there wouldn't be
- * any content in the boot time. Call the wipe API
- * to create a storage structure.
+#ifdef SST_CREATE_FLASH_LAYOUT
+ /* If SST_CREATE_FLASH_LAYOUT is set, it indicates that it is required to
+ * create a SST flash layout. SST service will generate an empty and valid
+ * SST flash layout to store assets. It will erase all data located in the
+ * assigned SST memory area before generating the SST layout.
+ * This flag is required to be set if the SST memory area is located in a
+ * non-persistent memory.
+ * This flag can be set if the SST memory area is located in a persistent
+ * memory without a previous valid SST flash layout in it. That is the case
+ * when it is the first time in the device life that the SST service is
+ * executed.
*/
if (err != PSA_SST_ERR_SUCCESS) {
+ /* Remove all data in the SST memory area and creates a valid SST flash
+ * layout in that area.
+ */
sst_system_wipe_all();
- /* attempt to initialise again */
+
+ /* Attempt to initialise again */
err = sst_system_prepare();
}
-#endif /* SST_RAM_FS */
+#endif /* SST_CREATE_FLASH_LAYOUT */
return err;
}