Skip to main content
TZeig.1
Associate
March 10, 2021
Solved

STM32L476G-EVAL CRYP Examples Problem

  • March 10, 2021
  • 3 replies
  • 1240 views

The code from the 1.16 example builds fine in the EWARM. It writes the source blocks to the terminal, but as I see in the debugger, it fails to encrypt the input block. That times out as it fails to return a HAL_OK status.

 /* Start decrypting aCyphertext, the decrypted data is available in aDecryptedtext */

  if (HAL_CRYPEx_AES(&CrypHandle, aCyphertext, AES_TEXT_SIZE, aDecryptedtext, TIMEOUT_VALUE) == HAL_OK)

  {

   /* Display decrypted Data */

   Display_DecryptedData(CBC, 128, AES_TEXT_SIZE);

  }

  else  

  {

   /* Processing Error */

   Error_Handler();

  }

I have read all the how-to info in the examples.

Has anyone else run into this issue and found a solution?

This topic has been closed for replies.
Best answer by Tesla DeLorean

@par Hardware and Software environment

  - This example runs on STM32L486xx devices.

  - This example has been tested with a STM32L486ZG embedded on an

  STM32L476G-EVAL board and can be easily tailored to any other supported

  device and development board.

3 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 10, 2021

@par Hardware and Software environment

  - This example runs on STM32L486xx devices.

  - This example has been tested with a STM32L486ZG embedded on an

  STM32L476G-EVAL board and can be easily tailored to any other supported

  device and development board.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
TZeig.1
TZeig.1Author
Associate
March 10, 2021

I have the STM32L476xx on my  STM32L476G-EVAL board. That does not have the crypto processor, is that correct?

Tesla DeLorean
Guru
March 10, 2021

It doesn't have the cryp/hash unit enabled, it is probably the same die with either it fused off at the die test stage, or with a different mask in the set lacking metalization, etc related to the unit. ST doesn't disclose the exact methodology, but the parts coming in a without/with pairing ie L476/L486 or F767/F777

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Pavel A.
Super User
March 10, 2021

It looks like twin models with and without crypto can be distinguished by checking that config register of a crypto thingy holds written value.

For example, below is a code we use to distinguish STM32H753 from 743.

Maybe the same will work for L486 vs 476.

-- pa

#ifndef STM32H753xx
#define STM32H753xx /* override! */
#undef STM32H743xx
#endif
 
#include "stm32h7xx_hal.h"
#include <stdint.h>
#include <stdbool.h>
 
// Return true if the MCU has crypto 
// so this is H7 variant with crypto (ex. H753 vs H743)
bool H7_hw_crypto_test()
{
 // Test if HASH->CR is writable
 __HAL_RCC_HASH_CLK_ENABLE();
 HAL_Delay(5);
 HASH->CR = 0;
 __DSB();
 HASH->CR = 0x20; // set HASH_CR_DATATYPE=HASH_DATATYPE_8B
 __DSB();
 uint32_t u = HASH->CR;
 bool y = ((u & 0x30) == 0x20);
 __HAL_RCC_HASH_CLK_DISABLE();
 return y;
}

TZeig.1
TZeig.1Author
Associate
March 10, 2021

okay thank you!