Skip to content

[stm32wb_rng, rng] Implement RNG device type. Implement RNG driver ad test for stm32wb#7

Merged
AlexLanzano merged 1 commit intowolfSSL:mainfrom
AlexLanzano:rng
Feb 17, 2026
Merged

[stm32wb_rng, rng] Implement RNG device type. Implement RNG driver ad test for stm32wb#7
AlexLanzano merged 1 commit intowolfSSL:mainfrom
AlexLanzano:rng

Conversation

@AlexLanzano
Copy link
Member

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new RNG abstraction to wolfHAL and provides an STM32WB (stm32wb55xx) TRNG implementation, wiring it into the STM32WB platform config and test suite.

Changes:

  • Introduce generic RNG device/driver API (wolfHAL/rng/rng.h, src/rng/rng.c).
  • Add STM32WB RNG driver + board/platform wiring (device + clock descriptors, RCC HSI48 helper).
  • Add STM32WB hardware tests and hook them into the STM32WB test runner/build.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
wolfHAL/wolfHAL.h Exposes RNG module via umbrella include.
wolfHAL/rng/rng.h Defines generic RNG device struct + driver vtable + dispatch API.
wolfHAL/rng/stm32wb_rng.h Declares STM32WB RNG driver config/API (and currently declares an RCC helper).
src/rng/rng.c Implements generic RNG dispatch functions.
src/rng/stm32wb_rng.c Implements STM32WB RNG init/deinit/generate and driver vtable.
wolfHAL/platform/st/stm32wb55xx.h Adds STM32WB55 RNG device and its peripheral clock descriptor macros.
src/clock/stm32wb_rcc.c Adds helper to enable/disable HSI48 oscillator needed by RNG.
examples/stm32wb/stm32wb55xx_nucleo.h Exposes g_whalRng board instance.
examples/stm32wb/stm32wb55xx_nucleo.c Instantiates g_whalRng with RCC clock gating config.
tests/stm32wb/test_rng.c Adds STM32WB RNG hardware tests.
tests/stm32wb/test_main.c Registers RNG tests in STM32WB test runner.
tests/stm32wb/Makefile Adds test_rng.c to STM32WB test build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 91 to 96
err = WHAL_EINVAL;
goto exit;
}
whal_Reg_Get(reg->base, SRNG_SR_REG, SRNG_SR_CECS, &status);
if (status) {
err = WHAL_EINVAL;
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SECS/CECS indicate hardware/clock/seed errors, not invalid arguments. Returning WHAL_EINVAL here is misleading; use WHAL_ENOTREADY (or introduce a more specific RNG error) so callers can distinguish argument validation from hardware failure.

Suggested change
err = WHAL_EINVAL;
goto exit;
}
whal_Reg_Get(reg->base, SRNG_SR_REG, SRNG_SR_CECS, &status);
if (status) {
err = WHAL_EINVAL;
err = WHAL_ENOTREADY;
goto exit;
}
whal_Reg_Get(reg->base, SRNG_SR_REG, SRNG_SR_CECS, &status);
if (status) {
err = WHAL_ENOTREADY;

Copilot uses AI. Check for mistakes.
@AlexLanzano AlexLanzano force-pushed the rng branch 2 times, most recently from e58b2f1 to d615ebf Compare February 17, 2026 04:27
@AlexLanzano AlexLanzano merged commit b6dbd65 into wolfSSL:main Feb 17, 2026
2 checks passed
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.

1 participant