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)