cmse_check_address_range does not work for CortexM33 code built with ARM CC 6.0


I am studying Cortex-M33 TrustZone with Armv8-M_security sample code coming from ARM Development Studio 2023.1.  When I add following code into main_s.c to test cmse_check_address_range intrinsic, but it seems does not work when running it in Armv8-M_security_FVP_M33, it always prints not in non-secure region, and checked its disassembly code, that intrinsic does not get called. Please help. 

The source code ( cmse_check_address_range is added within #if 1... #endif) is:

int __attribute__((cmse_nonsecure_entry)) ns_callable_fn1(int x)
     printf("Hello from Non-secure Callable Function 1!\n\r");
#if 1
     //Check a memory range is entirely in non-secure region or not
     uint32_t *p = (uint32_t *)0x00200000;
     uint32_t size = 4;
     uint32_t * vRet = 1;
     vRet = cmse_check_address_range( p, size, CMSE_MPU_NONSECURE);

     if (vRet == NULL)
         printf(" NULL returned, (%p, size=%d) is not entirely in non-secure region!\n", p, size);
         printf(" (%p, size=%d) is entirely in non-secure region!\n", p, size);
     return secure_fn1(x);

This disassembly code is:

0x100012B2 : MOV r0,#0x1423
0x100012B6 : MOVT r0,#0x1000
0x100012BA : BL __2printf ; 0x1000034C
0x100012BE : MOVS r0,#1
0x100012C0 : LSLS r1,r0,#21
0x100012C2 : MOV r0,#0x13de
0x100012C6 : MOVT r0,#0x1000
0x100012CA : MOVS r2,#4
0x100012CC : BL __2printf ; 0x1000034C
0x100012D0 : B {pc}+14 ; 0x100012DE
ns_callable_fn2 + 0x36


Parents Reply Children