#[non_exhaustive]pub struct Config {
pub disable_autocorrelation_test: bool,
pub disable_crngt_test: bool,
pub disable_von_neumann_balancer: bool,
pub sample_count: u32,
pub inverter_chain_length: InverterChainLength,
}Expand description
Configuration for the TRNG.
- Three built in entropy checks
- ROSC frequency controlled by selecting one of ROSC chain lengths
- Sample period in terms of system clock ticks
The RP2350 datasheet (12.12.2) suggests sample count settings of 20-25 for an average generation time of about 2 milliseconds. On real hardware that setting only works while the core is busy: with the core sleeping in WFE (which is what the async executor does while waiting for the TRNG interrupt) the ring oscillator output becomes regular enough that every generation fails the autocorrelation or CRNGT health check.
Measured on a Pico 2 with the core sleeping, filling 1024 bytes:
sample_count | result |
|---|---|
| 25 | never completes |
| 50 | 761 ms, many failed checks |
| 100 | 19 ms |
| 200 | 38 ms |
| 1000 | 232 ms |
The default is 200. Autocorrelation failures are retried automatically (up to 1000 times per block before panicking), so a marginal value degrades into slower generation rather than a hang. A value of 25 with a sleeping core fails every attempt and panics.
Note, Pico SDK and Bootrom don’t use any of the entropy checks and sample the ROSC directly by setting the sample period to 0. Random data collected this way is then passed through either hardware accelerated SHA256 (Bootrom) or xoroshiro128** (version 1.0!).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.disable_autocorrelation_test: boolBypass TRNG autocorrelation test
disable_crngt_test: boolBypass CRNGT test
disable_von_neumann_balancer: boolWhen set, the Von-Neuman balancer is bypassed (including the 32 consecutive bits test)
sample_count: u32Sets the number of rng_clk cycles between two consecutive ring oscillator samples. Note: If the von Neumann decorrelator is bypassed, the minimum value for sample counter must not be less than seventeen
inverter_chain_length: InverterChainLengthSelects the number of inverters (out of four possible selections) in the ring oscillator (the entropy source). Higher values select longer inverter chain lengths.