Random Generator in the DM42

If you're having problems with the hardware of a DM41X or DM42, post about them here.
Post Reply
Nissen
Posts: 18
Joined: Wed Jun 02, 2021 6:01 pm
Location: Copenhagen

Random Generator in the DM42

Post by Nissen »

Hello friends
The STM32L476 microcontroller used in the DM42 includes a TRUE random generator according to ST Microelectronics specifications.
The generator in the DM42 is only a PSEUDO-random generator.
Is it possible, to activate the TRUE random generator in the DM42?
Just curious :D
Regards, Nissen
reavy
Posts: 101
Joined: Tue Feb 06, 2018 9:08 pm
Location: Phoenix, AZ

Re: Random Generator in the DM42

Post by reavy »

Do they claim how it’s a TRNG? Does it have an antenna for picking up background radio waves or something?
Nissen
Posts: 18
Joined: Wed Jun 02, 2021 6:01 pm
Location: Copenhagen

Re: Random Generator in the DM42

Post by Nissen »

The Random Numbers are generated from the noise from a Zener diode.
newbrain
Posts: 4
Joined: Thu Aug 26, 2021 9:18 am

Re: Random Generator in the DM42

Post by newbrain »

There's a definite advantage in using a (good) PRNG, namely the reproducibility of results.
This is the reason for the SEED function - when seeded with the same starting number, the sequence will be the same.
For example when testing two different algorithms or simulations using the same sequence remove the possible bias due to "luck".

So the usage of the TRNG should be limited to the cases of cold startup and '0 SEED', which currently use the time of day as random number seed.

At first glance*, the changes needed would, at least, be:
  • DMCP would need to provide a new service call to read the TRNG
  • Function shell_random_seed in dm42_fns.cc should be changed to use the new service (instead of rtc_read)
For someone so inclined, it might be feasible to cobble up a prototype using direct register access to the TRNG in dm42_fns, without the need for a modified DMCP.
Only a few register accesses are needed, and nothing that might interfere with other things.

* No guarantee this is complete and correct, I'm not that familiar with DM43 codebase.
The Random Numbers are generated from the noise from a Zener diode.
What?
No, the TRNG in STM32L476 is based on XORing three free running ring oscillators, plus post processing stages to even out 0 and 1 distribution and "whiten" the distribution. See the RM, chapter 27.3.3.
Post Reply