-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels

Description
Description
Target: STM32L4x
Scope: USB and TRNG co-existence
In system_clock.c, the USB/SDMMC/TRNG source clock is set to either MSI or PLLSAI1, depending on the clock source (HSE/HSI use PLLSAI1 for 48MHz source, and MSI uses MSI for 48MHz source).
trng_api.c does not take this into account, and incorrectly sets the 48MHz clock source, in contradiction to what it was set to in system_clock.c
Bug Reproduction
- In json config, choose USE_PLL_MSI for clock source
- Use trng functionality (such as mbedtls_hardware_poll function call)
- USB operation ceases as soon as trng_init is called, as the 48MHz clock source is incorrectly changed to RCC_RNGCLKSOURCE_PLL, invalidating how it was set up in system_clock.c
Recommend a change in trng_api.c to choose the correct 48MHz source as it was set in system_clock.c, or remove this code as the 48MHz clock source was already set in system_clock.c, correct?
#if ((CLOCK_SOURCE) & USE_PLL_MSI)
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_MSI;
#else
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_PLLSAI1;
#endif
Issue request type
[ ] Question
[ ] Enhancement
[X] Bug