nanohub: firmware: fix secret key lookup

existing implementation can only find one
secret key, at offset 0.
Make it work for other offsets as well.

Bug: 28265099
Change-Id: I90551d5f0adb77ac750c2f03c787c1722a1a5dff
Signed-off-by: Alexey Polyudov <[email protected]>
diff --git a/firmware/src/platform/stm32f4xx/eeData.c b/firmware/src/platform/stm32f4xx/eeData.c
index bde9f9f..bcd8893 100644
--- a/firmware/src/platform/stm32f4xx/eeData.c
+++ b/firmware/src/platform/stm32f4xx/eeData.c
@@ -25,9 +25,9 @@
 
 //STM32F4xx eedata stores data in 4-byte aligned chunks
 
-static void* eeFind(uint32_t nameToFind, uint32_t startOffset, bool findFirst, uint32_t *szP)
+static void* eeFind(uint32_t nameToFind, uint32_t *offset, bool findFirst, uint32_t *szP)
 {
-    uint32_t *p = __eedata_start + startOffset;
+    uint32_t *p = __eedata_start + (offset ? *offset : 0);
     void *foundData = NULL;
 
     //find the last incarnation of "name" in flash area
@@ -54,6 +54,9 @@
             break;
     }
 
+    if (offset)
+        *offset = p - __eedata_start;
+
     return foundData;
 }
 
@@ -71,7 +74,7 @@
         return false;
 
     //find the data item
-    data = eeFind(name, *offsetP, first, &sz);
+    data = eeFind(name, offsetP, first, &sz);
     if (!data)
         return false;
 
@@ -84,8 +87,6 @@
     else if (szP)        //get size
         *szP = sz;
 
-    *offsetP = (uint32_t)data + ((sz + 3) &~ 3);
-
     return true;
 }
 
@@ -122,7 +123,7 @@
         return false;
 
     //find the empty space at the end of everything and make sure it is really empty (size == EE_DATA_LEN_MAX)
-    space = eeFind(EE_DATA_NAME_MAX, 0, false, &sz);
+    space = eeFind(EE_DATA_NAME_MAX, NULL, false, &sz);
     if (!space || sz != EE_DATA_LEN_MAX)
         return false;