2021-10-06 10:22 AM
Hello guys!
How are u all?
I'm having few issues to develop self-test on my application. I setup everything from the SBSFU side to check image handling flags, and its working fine. I'm able to set my new firmware to self-test state and check the state of my active slot.
My problem begin when i need to self-test. I have the following code on my application:
printf("Before SE_APP_GetActiveFwState..");
SE_APP_GetActiveFwState(&se_Status, slot_number, &fw_state);
printf("After SE_APP_GetActiveFwState..");
if (fw_state != FWIMG_STATE_SELFTEST) {
printf("Firmware not is SELF_TEST state\r\n");
} else {
printf("Firmware is in self test!\r\n");
se_retCode = SE_APP_ValidateFw(&se_Status, slot_number);
if ((SE_SUCCESS == se_retCode) && (SE_OK == se_Status)) {
printf("Firmware validated\r\n");
} else {
printf("Firmware validation failure\r\n");
}
}
All i want is just to validate my firmware image. After code enters in SE_APP_GetActiveFwState, it fails to satisfy the check to see if the caller is from the secure engine interface ( IS_CALLER_SE_IF() function).
#define IS_CALLER_SE_IF() \
do{ \
if (LR< SE_IF_REGION_ROM_START){\
NVIC_SystemReset();}\
if (LR> SE_IF_REGION_ROM_END){\
NVIC_SystemReset();}\
}whil
The LR at this part of my code is from my application and not inside the SE_IF_ROM region.
How should i call SE_APP_GetActiveFwState and SE_APP_ValidateFw from my application satisfying the conditions imposed by IS_CALLER_SE_IF()?
I already tried to link the pre-compiled se_interface_application.o contained in the SBSFU build, but if i don't import the source file to my project, compilation process still fails missing the reference of both SE_APP_GetActiveFwState and SE_APP_ValidateFw.
I'm using 1 active slot and 0 download slots, if self-test fails i want to erase active slot, not rolling back (because it would be impossible anyway). I configured a swap area, i saw the other examples and apparently it is needed.
Solved! Go to Solution.
2021-10-07 07:04 AM
Hello @MBuen.1
OK I understand.
The call to SecureEngine goes through SE interface mapped in the SE_IF_Region.
Then SBSFU provides the mapping to the exported function through the se_interface.txt => se_interface_app.o linked with user application.
So, as long as you call the API located in the SE_IF_Region the call should work.
Best regards
Jocelyn
2021-10-07 05:26 AM
Hello @MBuen.1
The image validation feature has been designed for 2 images case. If you don't have any download slot, I'm not sure the API is present in the SBSFU.
In your configuration, you actually do not really need this feature. If your auto test fails, you can just write some bytes in the firmware and reset.
The SBSFU will detect a problem when verifying the firmware and will erase it.
And you don't need any swap area
Best regards
Jocelyn
2021-10-07 06:45 AM
Hello @Jocelyn RICARD ,
Thanks for your response.
In fact my SBSFU is already configured, i manage to set and check firmware image state from my bootloader. My deal is calling secure engine functions from my application, that it fails as i mentioned above.
Anything i should pay attention for integrating secure engine functions in my application?
2021-10-07 06:48 AM
I fells like your proposal wouldn't be the best approach because i need to check if my application actually needs to execute auto test, so that i don't execute auto test at each reset.
I could use another flash position to write a flag in there indicating my firmware state , but i'm not sure how secure is that.
2021-10-07 07:04 AM
Hello @MBuen.1
OK I understand.
The call to SecureEngine goes through SE interface mapped in the SE_IF_Region.
Then SBSFU provides the mapping to the exported function through the se_interface.txt => se_interface_app.o linked with user application.
So, as long as you call the API located in the SE_IF_Region the call should work.
Best regards
Jocelyn
2021-10-07 09:11 AM
Thank @Jocelyn RICARD
I was not seeing the se_interface.txt file. I added the functions i needed there and everything worked out!
Now we know that is possible image handling with only one active slot! :face_with_tears_of_joy:
Thanks again mate!