2022-05-30 09:04 PM
if (SE_Startup() == SE_SUCCESS)
{
......
SE_Startup() --> __IS_SFU_RESERVED();
__get_LR() = 0x80055d7
SB_REGION_ROM_START) = 0x8005d00
SB_REGION_ROM_END = 0x801 ffff
Solved! Go to Solution.
2022-09-26 07:04 PM
Hello, Today I encountered the same issue as you had
IS_SFU_RESERVED() return failed as link register value is out of secure boot code range.
But I found that it happens when I change the optimization option as none.
so I checked the code and found that current code need to be changed for no optimization option.
Below is original code get_LR is inline function.
It will be replace with the codes inside when optimization is active.
But without optimization option, it works as normal function and it returns link register of the current function. so it will return unexpected SE_ERROR.
#define __IS_SFU_RESERVED() \
do{ \
if ((get_LR())< SB_REGION_ROM_START){\
return SE_ERROR;}\
if ((get_LR())> SB_REGION_ROM_END){\
return SE_ERROR;}\
}while(0)
so I removed the get_LR function and test with none optimization option.
It worked without errors.
#define __IS_SFU_RESERVED() \
do{ \
register uint32_t result;\
__asm volatile("MOV %0, LR\n" : "=r"(result));\
if (result < SB_REGION_ROM_START){\
return SE_ERROR;}\
if (result > SB_REGION_ROM_END){\
return SE_ERROR;}\
}while(0)
2022-06-03 06:14 AM
Hi @klang.1 ,
you wrote porting, but what is your staring point? There is already a L496 variant of SBSFU 2.6.
What you need to do is to check the linker files and memory ranges. The SBSFU is checking the process security by tightly controlling the addresses, using firewalls, PCROP and other techniques.
The AN5056 should be helpful.
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-06-06 07:22 AM
Thank you Jhoud,
I made the modification based on the example of L496 Discovery Board, instead of using UART2, I want to use USB Virtual Com port. I did it first by adding USB Device components to the project, but unfortunately USB connection was not reliable. I guess it could be related to Clock setting.
As there is no IOC file in the example project, I can not use GUI to do Clock configuration.
Then I created a new project with USB Device (COM port) , tested USB com works fine, then added all SBSFU components to this project, modified the linker files and memory ranges respectively.
But now it failed at __IS_SFU_RESERVED()
Best Regards,
Kevin
2022-09-26 07:04 PM
Hello, Today I encountered the same issue as you had
IS_SFU_RESERVED() return failed as link register value is out of secure boot code range.
But I found that it happens when I change the optimization option as none.
so I checked the code and found that current code need to be changed for no optimization option.
Below is original code get_LR is inline function.
It will be replace with the codes inside when optimization is active.
But without optimization option, it works as normal function and it returns link register of the current function. so it will return unexpected SE_ERROR.
#define __IS_SFU_RESERVED() \
do{ \
if ((get_LR())< SB_REGION_ROM_START){\
return SE_ERROR;}\
if ((get_LR())> SB_REGION_ROM_END){\
return SE_ERROR;}\
}while(0)
so I removed the get_LR function and test with none optimization option.
It worked without errors.
#define __IS_SFU_RESERVED() \
do{ \
register uint32_t result;\
__asm volatile("MOV %0, LR\n" : "=r"(result));\
if (result < SB_REGION_ROM_START){\
return SE_ERROR;}\
if (result > SB_REGION_ROM_END){\
return SE_ERROR;}\
}while(0)
2023-05-11 10:36 AM
Confirming that __IS_SFU_RESERVED() depends on get_LR() being inline, but using GCC with optimization fully disabled, the inline doesn't work. @eziya76 's code above fixes the issue.