This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

66AK2H06: enterNonSecure() function in GEL file

Part Number: 66AK2H06

Hi,

My customer is evaluating 66AK2H06 on their board.
When using CCS, the most of initialization is done by GEL files.
The gel file is attached.xtcievmk2x_arm.txt

Customer is now trying to test without CCS and put most of initialization sequences done by GEL to their code.
There is one function enterNonSecureMode() in GEL file. It works fine when CCS is connected.
When they put the similar sequence below in their code, the program run away somewhere.

    CSL_a15DisableMmu();
    CSL_a15DisableInstrCache();
    CSL_a15DisableDataCache();
    /* Set bit 10 and 11 in NSACR to allow NS access to cp10 and cp11 */
    asm("MRC p15, 0, r0, c1, c1, 2\n");
    asm("ORR r0, r0, #0x00000C00\n");
    asm("MCR p15, 0, r0, c1, c1, 2\n");
    /* Set bit 0 in SCR for NS mode */
    asm("MRC p15, 0, r0, c1, c1, 0\n");
    asm("ORR r0, r0, #0x1\n");
    asm("MCR p15, 0, r0, c1, c1, 0\n");
    //  "Enabling EnableNeon"
    asm("MRC p15, #0, r1, c1, c0, #2\n");
    asm("ORR r1, r1, #(0xf << 20)\n");
    asm("MCR p15, #0, r1, c1, c0, #2\n");
    asm("MOV r1, #0\n");
    //  "Enabling SMP bit in ACTLR"
    asm("MRC p15, #0, r1, c1, c0, #1\n");
    asm("ORR r1, r1, #(0x1 << 6)\n");
    asm("MCR p15, #0, r1, c1, c0, #1\n");
    // Ensure MMU and Caches are disabled after changing security mode
    CSL_a15DisableMmu();
    CSL_a15DisableInstrCache();
    CSL_a15DisableDataCache();



Q1) What is the purpose of the enterNonSecureMode() ?

Q2) Is the same sequence needed in customer code?

Q3) What wrong with the customer code sequence?

Thanks and regards,
Koichiro Tashiro

  • Hi,

    1) For secureMode or nonsecuremode, please see some info I found:

    https://www.macs.hw.ac.uk/~hwloidl/Courses/F28HS/Docu/DEN0013D_cortex_a_series_PG.pdf , chapter 21

    https://e2e.ti.com/support/legacy_forums/embedded/tirtos/f/355/t/512723, ====>We only support running in non-secure mode

    2) Yes, customer needs the same to put A15 in non-secure mode

    3) If you don't use GEL, then SBL serves this purpose. This is like to run a baremetal code on A15, please see all the files under pdk_k2hk_4_0_16\packages\ti\boot\sbl\soc\k2h. The sbl_init.s jumps into main(), it then calls SBL_socInit(), where you have  (*monitorFunction)(SBL_setNSMode); is called. 

    void SBL_setNSMode()
    {
    /* Set bit 10 and 11 in NSACR to allow NS access to cp10 and cp11 */
    asm("MRC p15, 0, r0, c1, c1, 2\n");
    asm("ORR r0, r0, #0x00000C00\n");
    asm("MCR p15, 0, r0, c1, c1, 2\n");

    /* Set bit 0 in SCR for NS mode */
    asm("MRC p15, 0, r0, c1, c1, 0\n");
    asm("ORR r0, r0, #0x1\n");
    asm("MCR p15, 0, r0, c1, c1, 0\n");
    }

    Regards, Eric