Other Parts Discussed in Thread: CC2652R
Tool/software:
Hello,
I want to add keys to secure area. I am using "12.9.1 Crypto Registers" to complete this task. Then I looked reference manuals document up and I write a code thanks to "12.7.4.2.1 Load Keys From External Memory". However, I got an error. I use some registers that are readable and writable type, however I can not read these registers. Because these registers are crypto registers and I can only see "?" in the address via memory browser during debug.
My board is cc26x2
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 // base address of the key in ext. memory
write DMACH0LEN // 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
In this pseudocode I want to always check the value in the register whether is correct value or not. Also, I got an error in the while and if (wait and check) blocks. Because I can not read the value in the address. Is there any possible way to read the value in the crypto registers? You can see my code in the below.
void loadKeys(uint32_t keyIndex, uint32_t *extMemoryAddr, uint32_t keyLength) {
ALGSEL = 0x00000001; // Enable DMA to key store module
IRQCLR = 0x00000001; // Clear any outstanding events
KEYSIZE = 0x00000001; // 128-bit key size
KEYWRITEAREA = (1 << keyIndex); // Select the key slot (e.g., key 0)
DMACH0CTL = 0x00000001; // Enable DMA channel 0
DMACH0EXTADDR = (uint32_t)extMemoryAddr; // Set external memory address (where the key is stored)
DMACH0LEN = keyLength; // Set key length (e.g., 16 bytes for 128-bit key)
while ((IRQSTAT & 0x01) == 0); // Wait until the operation is completed (IRQSTAT[0] is set)
// Check if the operation was successful (no errors in DMA or key store)
if ((IRQSTAT & 0xC0000000) == 0) {
// Operation completed successfully
IRQCLR = 0x00000001; // Clear interrupt flag
} else {
// Handle errors (DMA or key store write error)
}
// Verify that the key was written to the correct area
if (KEYWRITTENAREA & (1 << keyIndex)) {
// Key was successfully written to the key store
} else {
// Handle failure (key not written)
}
// Disable DMA path to the key store module
ALGSEL = 0x00000000; // Disable DMA path
}
Thanks