SST: Set physical ID for logical block 0 on create

Changes sst_core_object_create so that, when an object is reserved in
logical block zero, the physical ID in the block metadata is updated to
the current scratch metadata block. This ensures the physical ID is
still correct once the metadata blocks are swapped at the end of the
function.

Change-Id: I6bc33191d1fc596963bf1c44b92fc5f710fb3b6b
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/secure_fw/services/secure_storage/sst_core.c b/secure_fw/services/secure_storage/sst_core.c
index 719b1ec..2420d79 100644
--- a/secure_fw/services/secure_storage/sst_core.c
+++ b/secure_fw/services/secure_storage/sst_core.c
@@ -1255,6 +1255,14 @@
         return TFM_SST_ERR_SYSTEM_ERROR;
     }
 
+    /* If the object is in logical block 0, then update the physical ID to the
+     * current scratch metadata block so that it is correct after the metadata
+     * blocks are swapped.
+     */
+    if (object_meta.lblock == SST_LOGICAL_DBLOCK0) {
+        block_meta.phys_id = sst_meta_cur_meta_scratch();
+    }
+
     err = sst_mblock_update_scratch_block_meta(object_meta.lblock,
                                                &block_meta);
     if (err != TFM_SST_ERR_SUCCESS) {