Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Power consumption cannot be reduced after using hardware encryption

Hi   

    Nordic engineer

    Power consumption cannot be reduced after using hardware encryption. Under normal conditions, the device power consumption is 30µA, but after calling aes_cbc_decrypt, it increases to 3.4mA.   SDK is nrf5 17.0.0,how can I reduce power consumption?

   

void aes_cbc_decrypt(uint8_t *in,uint32_t out_len,uint8_t *out,uint8_t *iv,uint8_t *key)
{
    int ret;
	SaSiAesUserContext_t    ContextID;
	SaSiAesUserKeyData_t    keyData;
	SaSi_LibInit();
    ret = SaSi_AesInit(&ContextID,SASI_AES_DECRYPT,SASI_AES_MODE_CBC,SASI_AES_PADDING_NONE);
    
    ret = SaSi_AesSetIv(&ContextID, iv);

    keyData.pKey = key;
    keyData.keySize = 16;
    ret = SaSi_AesSetKey(&ContextID, SASI_AES_USER_KEY, &keyData, sizeof(keyData) );
    uint16_t i=0;
	if(out_len>SASI_AES_BLOCK_SIZE_IN_BYTES)
	{
	    for(i=0 ; i<(out_len/SASI_AES_BLOCK_SIZE_IN_BYTES-1) ; i++)
	    {
	        ret = SaSi_AesBlock(&ContextID,
	   				in+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
	   				SASI_AES_BLOCK_SIZE_IN_BYTES,
	   				out+i*SASI_AES_BLOCK_SIZE_IN_BYTES);
	    }
	}
    uint32_t len=out_len-i*SASI_AES_BLOCK_SIZE_IN_BYTES;
	if(len%SASI_AES_BLOCK_SIZE_IN_BYTES)
	{
		uint8_t temp[32]={0};
		uint32_t cipher_len = ((len+15)/SASI_AES_BLOCK_SIZE_IN_BYTES)*SASI_AES_BLOCK_SIZE_IN_BYTES;
		ret = SaSi_AesFinish(&ContextID,
						cipher_len,
						in+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
						cipher_len,
						temp,
						&cipher_len); 
		memcpy(out+i*SASI_AES_BLOCK_SIZE_IN_BYTES,temp,len);
	}
	else
	{
		ret = SaSi_AesFinish(&ContextID,
							len,
							in+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
							len,
							out+i*SASI_AES_BLOCK_SIZE_IN_BYTES,
							&len);  
	}
	SaSi_AesFree(&ContextID);
	SaSi_LibFini();	    
}

Parents Reply Children
  • sd_app_evt_wait() should behave like __WFE() and return when there is a pending interrupt. Still, the fact that you see lower current with __WFI() suggests that the problem is related to clearing of the FPU event and interrupt as Turbo mentioned. Did you try changing the order so that the FPU interrupt is cleared before the sd_app_evt_wait() and not after?

  • Hi   Vidar

          Clear FPU interrupt before sd_app_evt_wait() can't resolve the problem, but __WFI resolve it.

  • Hi,

    Since I'm not able to reproduce this on my end I suggest you try to troubleshoot this more on your side. For example, you can try to build without FPU enabled (Note: this requires you to link in the non-FP variant of the cc310 runtime lib as well). Or you can try find you why you are not measuring -2-3 ua with the examples\crypto\nrf_cc310\aes example.

    mokoysh said:
      I'm sorry to misread the previous information,the project in the folder aes_test\.MDK_Project\AES_TEST.uvprojx.

    I see. I'm on macOS where directories with leading dot (.) like .MDK_Project will appear hidden by default. 

Related