rng: handle noise source / seed error.
If noise source error occurs, flag must be cleared and data register must be discarded (at least 12 reads to flush pipeline on G0). Other device mention start/restart of chip, so, do both (better safe than sorry). Reviewed-on: https://github.com/libopencm3/libopencm3/pull/1062
This commit is contained in:
parent
5a53f18a78
commit
5866852a90
@ -94,10 +94,16 @@ uint32_t rng_get_random_blocking(void)
|
||||
uint32_t rv;
|
||||
bool done;
|
||||
do {
|
||||
if (RNG_SR & RNG_SR_SECS) {
|
||||
rng_disable();
|
||||
rng_enable();
|
||||
|
||||
if (RNG_SR & RNG_SR_SEIS) {
|
||||
RNG_SR = RNG_SR & ~RNG_SR_SEIS;
|
||||
for (int i = 12; i != 0; i--) {
|
||||
rv = RNG_DR;
|
||||
}
|
||||
RNG_CR &= ~RNG_CR_RNGEN;
|
||||
RNG_CR |= RNG_CR_RNGEN;
|
||||
}
|
||||
|
||||
done = rng_get_random(&rv);
|
||||
} while (!done);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user