Skip to content

Commit 9c83a8a

Browse files
HoZHelkartben
authored andcommitted
drivers: entropy: Modify the recover_seed_error function for WB0x
Exclude the WB0x series from discarding data 12 times from the RNG data register. Add a comment to the recover_seed_error function explaining the reason for reading and discarding data from the RNG data register 12 times. Signed-off-by: Ali Hozhabri <[email protected]>
1 parent e77ee0f commit 9c83a8a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/entropy/entropy_stm32.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,14 @@ static int recover_seed_error(RNG_TypeDef *rng)
301301
{
302302
ll_rng_clear_seis(rng);
303303

304+
#if !defined(CONFIG_SOC_SERIES_STM32WB0X)
305+
/* After a noise source error is detected, 12 words must be read from the RNG_DR register
306+
* and discarded to restart the entropy generation.
307+
*/
304308
for (int i = 0; i < 12; ++i) {
305309
(void)ll_rng_read_rand_data(rng);
306310
}
311+
#endif /* !CONFIG_SOC_SERIES_STM32WB0X */
307312

308313
if (ll_rng_is_active_seis(rng) != 0) {
309314
return -EIO;
@@ -419,7 +424,7 @@ static uint16_t generate_from_isr(uint8_t *buf, uint16_t len)
419424
byte = random_byte_get();
420425
#if !IRQLESS_TRNG
421426
NVIC_ClearPendingIRQ(IRQN);
422-
#endif /* IRQLESS_TRNG */
427+
#endif /* !IRQLESS_TRNG */
423428

424429
if (byte < 0) {
425430
continue;

0 commit comments

Comments
 (0)