ADSP-SC594
Recommended for New Designs
Reaching speeds of up to 1 GHz, the ADSP-SC59x processors are members of the SHARC® family of products. The ADSP-SC59x processor is a dual-SHARC+® core...
Datasheet
ADSP-SC594 on Analog.com
I am trying to adapt an SSL based on the open-part example for SC589. I can't get it to work on SC594. I never get the cause = ROM_HOOK_CALL_CONFIG_COMPLETE call to the boot callback function. I get one call with cause = ROM_HOOK_REG_COMPLETE, then the second callback with cause = ROM_HOOK_CALL_INIT_COMPLETE but after secure boot is enabled, I get no final callback.
Any ideas what I'm doing wrong ? An open-part booting example would have been really handy in EE-447 !
void configureBlw(ADI_ROM_BOOT_CONFIG* pBootConfig) {
uint8_t * pKey = (uint8_t *)&pBootConfig->publicKey;
uint8_t * aes = (uint8_t *)&pBootConfig->aesKey;
uint8_t i;
for(i=0; i<56; i++) {
pKey[i] = secure_boot_public_key[i];
}
for(i=0; i<16; i++) {
aes[i] = wrapper_key[i];
}
}
/**
* @brief setup kernel for memory mapped SPI mode
* @param pBootConfig boot configuration structure
*/
void setupMemoryMappedSPI(ADI_ROM_BOOT_CONFIG * pBootConfig) {
/* kernel anomaly workarounds for SPI */
/* memory mapped mode must be used when using the API for secure boot in an open part, this is not required for a normal boot */
ADI_SPI_TypeDef *pSpiRegs = ( ADI_SPI_TypeDef *)pBootConfig->pPeripheralBase;
ADI_ROM_BOOT_SPI *pSpiStruct = ( ADI_ROM_BOOT_SPI *)pBootConfig->pModeData;
/* update boot kernel to use memory mapped mode */
pBootConfig->pDmaBaseRegister = pADI_DMA9;
/* Update the control value uses to support memory mapped mode */
pBootConfig->dControlValue = BITM_SPI_CTL_EN | BITM_SPI_CTL_MSTR | (0 << BITP_SPI_CTL_SIZE) | BITM_SPI_CTL_MMSE | BITM_SPI_CTL_ASSEL;
/* Enable both transmit and receive parts of the SPI */
pSpiRegs->TXCTL |= BITM_SPI_TXCTL_TEN | BITM_SPI_TXCTL_TTI;
pSpiRegs->RXCTL |= BITM_SPI_RXCTL_REN | BITM_SPI_RXCTL_RTI;
/* Enable the SPI in memory mapped mode */
pSpiRegs->CTL = pBootConfig->dControlValue | pSpiStruct->nRxCtl;
/* Update our source pointer now to account for the memory mapped location */
pBootConfig->pSource = (void *)(((int)pBootConfig->pSource&0x0FFFFFFF) + pSpiStruct->pXIPAddress);
/* change dBootCommand to indicate now using the SPI XIP mode, this is needed for the load function */
pBootConfig->dBootCommand &= (!BITM_ROM_BCMD_DEVICE);
pBootConfig->dBootCommand |= ENUM_ROM_BCMD_DEVICE_SPIXIP;
}
/**
* ConfigureForSecureBoot
* @param pBootConfig boot configuration structure
* @param cause the reason the hook was called
* @brief The hook function is called twice by the ROM after configuration and after initialization
* Here we will setup the boot Kernel to do a secure boot.
*
* */
int32_t ConfigureForSecureBoot(ADI_ROM_BOOT_CONFIG * pBootConfig, ROM_HOOK_CALL_CAUSE cause) {
if (cause == ROM_HOOK_CALL_INIT_COMPLETE) {
/* executed after kernel has completed boot peripheral initialization */
/* 1. Set the boot type to secure */
pBootConfig->bootType=ADI_ROM_SECURE_BOOT;
/* 2. Set they key type to custom ( this disables reading the key from OTP ) */
pBootConfig->keyType = ADI_ROM_CUSTOM_SECURITY;
/* 3. load the key to be used, this is the key that would normally be read from OTP
*
* Choose the appropriate image type
*
* */
configureBlw(pBootConfig);
}
else if (cause == ROM_HOOK_CALL_CONFIG_COMPLETE)
{
/* executed after the initial boot kernel configuration is completed */
setupMemoryMappedSPI(pBootConfig);
}
return 0;
}
int main()
{
initcode(NULL);
adi_initComponents();
/*Configuring the SPU secureP registers for boot peripheral to do secure access to memory*//*Configuring the SPU secureP registers for boot peripheral to do secure access to memory*/
*pREG_SPU0_SECUREP103= 0x3; //SPI2
*pREG_SPU0_SECUREP146= 0x3; //MDMA0_SRC
*pREG_SPU0_SECUREP147= 0x3; //MDMA0_DST
uint8_t* bootImage = (uint8_t*)(SPI2_MEMORY_MAP_ADDRESS + FLASH_FACTORY_IMAGE_ADDRESS);
/* ROM API Call which can be invoked based on some conditions */
uint32_t BootCmd = (1<<BITP_ROM_BCMD_SPIM_BCODE)|(2<<BITP_ROM_BCMD_DEVENUM)|
(0<<BITP_ROM_BCMD_SPIM_NOAUTO)|(7<<BITP_ROM_BCMD_DEVICE);
/*Use the Hook function to change from enable secure boot*/
adi_rom_Boot(bootImage + sizeof(flashImageHeader), BITM_ROM_BFLAG_HOOK,0, &ConfigureForSecureBoot,BootCmd);
return 0;
}
I just realised by first mistake, I was still using the old signtool. Now I'm using adi_signtool -add-sbh-hash-224 I get the final callback but there's still something wrong with what I'm doing in that callback to try & setup SPI in memory mapped mode.
https://www.analog.com/media/en/technical-documentation/application-notes/ee447v01.pdf
I just realised by first mistake, I was still using the old signtool. Now I'm using adi_signtool -add-sbh-hash-224 I get the final callback but there's still something wrong with what I'm doing in that callback to try & setup SPI in memory mapped mode.
https://www.analog.com/media/en/technical-documentation/application-notes/ee447v01.pdf