sfs: enhance log messages

Add trace calls to the code to help investigating failures.

Change-Id: I2a3d0bb819a721e22b9a82610b44de8577d603d7
Signed-off-by: Gabor Toth <gabor.toth2@arm.com>
diff --git a/components/service/block_storage/factory/ref_ram_gpt/block_store_factory.c b/components/service/block_storage/factory/ref_ram_gpt/block_store_factory.c
index d72e6aa..b4461d3 100644
--- a/components/service/block_storage/factory/ref_ram_gpt/block_store_factory.c
+++ b/components/service/block_storage/factory/ref_ram_gpt/block_store_factory.c
@@ -19,6 +19,7 @@
 #include <media/disk/disk_images/ref_partition.h>
 #include <media/disk/formatter/disk_formatter.h>
 #include "block_store_factory.h"
+#include <trace.h>
 
 struct block_store_assembly
 {
@@ -51,8 +52,11 @@
 
 		volume_index_init();
 
-		/* Check assumptions about generated ref_partition data */
-		assert(!(ref_partition_data_length % REF_PARTITION_BLOCK_SIZE));
+		/* Reference partition must be multiple of the block size */
+		if (ref_partition_data_length % REF_PARTITION_BLOCK_SIZE) {
+			EMSG("Reference partition size is not multiple of the block size");
+			return NULL;
+		}
 
 		/* Initialise a ram_block_store to mimic the secure flash used
 		 * to provide underlying storage.
diff --git a/components/service/secure_storage/backend/secure_flash_store/flash_fs/sfs_flash_fs_mblock.c b/components/service/secure_storage/backend/secure_flash_store/flash_fs/sfs_flash_fs_mblock.c
index e989179..698c50e 100644
--- a/components/service/secure_storage/backend/secure_flash_store/flash_fs/sfs_flash_fs_mblock.c
+++ b/components/service/secure_storage/backend/secure_flash_store/flash_fs/sfs_flash_fs_mblock.c
@@ -7,6 +7,7 @@
 
 #include "sfs_flash_fs_mblock.h"
 #include <string.h>
+#include <trace.h>
 
 /* Physical ID of the two metadata blocks */
 /* NOTE: the earmarked area may not always start at block number 0.
@@ -355,6 +356,7 @@
     err = fs_ctx->flash_info->erase(fs_ctx->flash_info,
                                     fs_ctx->scratch_metablock);
     if (err != PSA_SUCCESS) {
+        EMSG("Failed to erase scratch metablock");
         return err;
     }
 
@@ -692,6 +694,7 @@
     if (num_valid_meta_blocks > 1) {
         cur_meta_block = sfs_mblock_latest_meta_block(&h_meta0, &h_meta1);
     } else if (num_valid_meta_blocks == 0) {
+        EMSG("Found no valid metablock headers");
         return PSA_ERROR_GENERIC_ERROR;
     }
 
@@ -784,16 +787,19 @@
     /* Initialize Flash Interface */
     err = fs_ctx->flash_info->init(fs_ctx->flash_info);
     if (err != PSA_SUCCESS) {
+        EMSG("Failed to initialize flash interface");
         return err;
     }
 
     err = sfs_init_get_active_metablock(fs_ctx);
     if (err != PSA_SUCCESS) {
+        EMSG("Failed to get active metablock");
         return PSA_ERROR_GENERIC_ERROR;
     }
 
     err = sfs_mblock_read_meta_header(fs_ctx);
     if (err != PSA_SUCCESS) {
+        EMSG("Failed to read metablock header");
         return PSA_ERROR_GENERIC_ERROR;
     }
 
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 37fa44f..521a681 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
@@ -12,6 +12,7 @@
 #include "secure_flash_store.h"
 #include <string.h>
 #include <stddef.h>
+#include <trace.h>
 
 #ifndef SFS_MAX_ASSET_SIZE
 #define SFS_MAX_ASSET_SIZE (4096) /* TODO: comes from flash layout */
@@ -385,6 +386,7 @@
          */
         status = sfs_flash_fs_wipe_all(&fs_ctx_sfs);
         if (status != PSA_SUCCESS) {
+            EMSG("Can not wipe sfs flash store");
             return NULL;
         }