Skip to content

runtime: use rand_hwrng hardwareRand for RP2040/RP2350#5135

Merged
deadprogram merged 3 commits into
tinygo-org:devfrom
makiuchi-d:rp2-hwrng
Dec 18, 2025
Merged

runtime: use rand_hwrng hardwareRand for RP2040/RP2350#5135
deadprogram merged 3 commits into
tinygo-org:devfrom
makiuchi-d:rp2-hwrng

Conversation

@makiuchi-d

Copy link
Copy Markdown
Contributor

This PR proposes using the existing rand_hwrng.go implementation of hardwareRand() for RP2040/RP2350.

On these targets, hardwareRand() calls machine.GetRNG() on every invocation, so the math/rand global RNG always obtains randomness and does not fall back to fastrand64().

This makes hardwareRand() behave as its name suggests, at the cost of lower performance.

Comment thread src/runtime/rand_hwrng.go
@deadprogram

Copy link
Copy Markdown
Member

Thanks for the improvement here @makiuchi-d and to @eliasnaur for all the help with this set of features.

Now squash/merging.

@deadprogram deadprogram merged commit f7fd5cf into tinygo-org:dev Dec 18, 2025
19 checks passed
burgrp pushed a commit to burgrp/tinygo that referenced this pull request Jan 3, 2026
* runtime: use rand_hwrng hardwareRand for RP2040/RP2350

* add a comment

* insert 'implementations'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants