hwrnd how to implement

Hello all,

While implementing the at86rfr2 transceiver for the jiminy board I thought of also implement the hwrng.

What I did is implementing in cpu/atmega256rfr2/periph/hwnrg.c

hwrng_init

hwrng_read

Added feature and module to makefiles.

Now I have some questions:

image001.png

Hi Josua,

when the RNG component of the at86rf2xx driver was provided in [1] we decided to not implement the periph/hwnrg with it. Main reasons are that it is

  1. Not a periph (i.e. a CPU feature)
  2. Hard to integrate when e.g. the CPU already provides a hwnrg.

Hope this helps, Martine

[1] https://github.com/RIOT-OS/RIOT/pull/4989

image001.png

Thanks Martine,

But as the atmegarfr2 is a soc this is the hwrng for this device.

So what would be the best place to put it if not as cpu/periph in this special case?

I would then implement it as CPU feature and remove the depency to the at86rf2xx driver.

Still the remaining question is it made sure that random32 calls or any calls to random are directed to hwrng_read

Is this already done by just enabling the module when building with FEATURES_REQUIRED = periph_hwrng ?

image001.png

Hi Josua,

IMO: cpu/periph is right if its part of the SOC (as you already said, there should be no dependency to the at86rf2xx driver -if possible- ).

Regarding your other question: I think the answer is no, at the moment its not guaranteed that calls to random32 are directed to hwrng, see [1].

regards,

Michel

[1]:

image001.png

Hi,

the random should IMHO also stay strictly an API for pseudo random number generators, I agree however with Michel’s issue, that hwnrg should be used for seed generation if available.

Cheers, Martine

image001.png