[stm32wb_rng, rng] Implement RNG device type. Implement RNG driver ad test for stm32wb#7
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/rng/stm32wb_rng.c
Outdated
| err = WHAL_EINVAL; | ||
| goto exit; | ||
| } | ||
| whal_Reg_Get(reg->base, SRNG_SR_REG, SRNG_SR_CECS, &status); | ||
| if (status) { | ||
| err = WHAL_EINVAL; |
There was a problem hiding this comment.
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.
| 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; |
e58b2f1 to
d615ebf
Compare
…d test for stm32wb
No description provided.