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.

LAUNCHXL-CC26X2R1: Loading Keys to Key Store Memory

Part Number: LAUNCHXL-CC26X2R1
Other Parts Discussed in Thread: SYSBIOS

Tool/software:

Hello,

I want to add keys to key store memory from external memory. I looked up the reference manual document and I decided to use "12.7.4.2.1 Load Keys From External Memory" part. However, these registers are crypto registers so I can not reach directly. As I understand from the part "12.5.6 Key Area Registers", I can change these registers only via DMA. In this situation I got an error and probably this error about not configuring DMA appropriately. So, what is the way configuring DMA properly? You can see the pseudocode in the below.

12.7.4.2.1 Load Keys From External Memory
The following software example in pseudocode describes the actions that are typically executed by the host software to load one or more keys into the key-store module.
// configure master control module
write ALGSEL 0x0000_0001 // enable DMA path to the key store module
write IRQCLR 0x0000_0001 // clear any outstanding events
// configure key store module (area, size)
write KEYSIZE 0x0000_0001 // 128-bit key size
write KEYWRITEAREA 0x0000_0001 // enable keys to write (e.g. Key 0)
// configure DMAC
write DMACH0CTL 0x0000_00001 // enable DMA channel 0
write DMACH0EXTADDR <ext_memory_address> // base address of the key in ext. memory
write DMACH0LEN <length> // total key length in bytes (e.g. 16 for 1 x 128-bit key)
// wait for completion
wait IRQSTAT[0]==’1’ // wait for operation completed
check IRQSTAT[31:30] == ‘00’ // check for absence of errors in DMA and key store
write IRQCLR 0x0000_0001 // acknowledge the interrupt
write ALGSEL 0x0000_0000 // disable master control/DMA clock
// check status
check KEYWRITTENAREA 0x0000_00001 // check that Key 0 was written
// end of algorithm

I am looking forward to your respond.

Thanks.

  • Hello Cetin,

    This appears to be a continuation of your prior E2E thread.  

    Other than the DMA section of the TRM (Chapter 12.5.3), here are the driverlib and registers for this module.  You can try reviewing error values, resetting the DMA, and checking its status.

    Regards,
    Ryan

  • Hello Ryan,

    I tried your suggestions and I can not fix my problem. Actually my main problem is a situation I noticed while debugging (Also it doesn't work when I run the code). I defined the relevant registers and assigned the correct addresses thanks to TRM. Then when these registers are tried to be read in blocks like while and if blocks, flowing of code first fall into the following code block in the Hwi_asm_gcc.s file (first code part). Then in that code, it jumps from the blx line to the Hwi.c file and enters the following code fragment (second code part). In this part, it enters the Hwi_excHandlerFunc(excStack, lr) function and then it falls into the for(;;) part in the if block (you can see it below) inside the void Error_raiseX(Error_Block *eb, int prefix, const char * id, intptr_t a0, intptr_t a1) function in the Error.c file (third code part) and cannot exit.

    My main goal is to get rid of this problem and what are the solutions for this? Maybe there are different methods, I am open to using those methods. Also, I should state that I am a university student, I am not as knowledgeable as an engineer in this field.

    -----ONE OF THE PROBLEMATIC BLOCK IN MY CODE--------

    while (!(HWREG(IRQSTAT_REG) & 0x00000001)){}

    ----FIRST CODE PART THAT I MENTIONED----
    ti_sysbios_family_arm_m3_Hwi_excHandlerAsm:
    tst lr, #4 @ context on PSP?
    ite NE
    mrsne r0, psp @ if yes, then use PSP
    moveq r0, sp @ else use MSP
    mov sp, r0 @ use this stack
    stmfd sp!, {r4-r11} @ save r4-r11 while we're at it
    mov r0, sp @ pass sp to exception handler
    mov r1, lr @ pass lr too
    mov r4, lr @ preserve LR in r4

    ldr r2, excHandlerAddr
    blx r2

    mov r0, sp @ for ROV
    mov r1, r4 @ for ROV

    ------SECOND CODE PART THAT I MENTIONED------

    void Hwi_excHandler(unsigned int *excStack, unsigned int lr)
    {
    Hwi_module->excActive = true;

    /* return to spin loop if no exception handler is plugged */
    if (Hwi_excHandlerFunc == NULL) {
    return;
    }

    Hwi_excHandlerFunc(excStack, lr);
    }

    -----THIRD CODE PART THAT I MENTIONED-------
    if (Error_policy_D == Error_SPIN) {
    for(;;) {
    }
    }
    else if (((eb == &defErr) && (Error_policy_D == Error_UNWIND)) || (Error_policy_D == Error_TERMINATE)) {
    System_abort("ti_sysbios_runtime_Error_raise: terminating execution\n");
    }

    Kind Regards,
    Cetin

  • Here is a Debugging Guide include HWI exceptions.

    There is an example of this crypto key store usage in the F2 SDK inside of source\ti\devices\cc13x2_cc26x2\driverlib\aes.c, from the AESWriteToKeyStore & AESStartDMAOperation functions.  If you are not going to use the AES TI Drivers which were recommended in the related E2E thread then hopefully you can learn how to apply this operation using the driverlib functions.

    Regards,
    Ryan

  • Hello Ryan,

    These functions helped me to complete my task. Thank you.

    Kind regards,
    Cetin