How to call SecureEngine functions from my application?
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();}\
}whilThe 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.
