-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with low power and entropy on STM32WB55 #72640
Comments
Hi @gumulka! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
entropy generation and power management does not work together in current zephyr. See zephyrproject-rtos/zephyr#72640 for details.
@gumulka I confirm the ZEPHYR FATAL ERROR 26 with the condition you exposed, even with k_sleep(K_MSEC(10)); diff --git a/drivers/entropy/entropy_stm32.c b/drivers/entropy/entropy_stm32.c
index a9cbda2abc7..8bc79fdc898 100644
--- a/drivers/entropy/entropy_stm32.c
+++ b/drivers/entropy/entropy_stm32.c
@@ -112,6 +112,10 @@ static int entropy_stm32_suspend(void)
RNG_TypeDef *rng = dev_data->rng;
int res;
+#if defined(CONFIG_SOC_SERIES_STM32WBX) || defined(CONFIG_STM32H7_DUAL_CORE)
+ /* Prevent concurrent access with PM */
+ z_stm32_hsem_lock(CFG_HW_RNG_SEMID, HSEM_LOCK_WAIT_FOREVER);
+#endif /* CONFIG_SOC_SERIES_STM32WBX || CONFIG_STM32H7_DUAL_CORE */
LL_RNG_Disable(rng);
#ifdef CONFIG_SOC_SERIES_STM32WBAX
@@ -136,6 +140,10 @@ static int entropy_stm32_suspend(void)
res = clock_control_off(dev_data->clock,
(clock_control_subsys_t)&dev_cfg->pclken[0]);
+#if defined(CONFIG_SOC_SERIES_STM32WBX) || defined(CONFIG_STM32H7_DUAL_CORE)
+ z_stm32_hsem_unlock(CFG_HW_RNG_SEMID);
+#endif /* CONFIG_SOC_SERIES_STM32WBX || CONFIG_STM32H7_DUAL_CORE */
+
return res;
} It fixes the error on my side.
|
@FRASTM It also fixes the error on my side. Happy to see it getting merged into mainline! |
Great, I am preparing a PR |
Describe the bug
When using PM_DEVICE together with ENTROPY_GENERATOR on the STM32WB55 board, I get an BUS fault after a while.
The time until the bug occurs can vary, but it does occur after a few seconds every time.
I have tried the v3.6.0 and also mainline zephyr and both have the same error.
To Reproduce
I tried this with the nucleo_wb55rg devboard. To be precise MB1355D-01.
Enable
CONFIG_PM
,CONFIG_PM_DEVICE
andCONFIG_ENTROPY_GENERATOR
in the Bluetooth peripheral sample and wait a bit. I have speed up the process, by replacing the content of the while loop in main withk_sleep(K_MSEC(2));
patch for this
compile and flash with:
Expected behavior
No bus fault.
Impact
Not sure yet, will have to see. Currently annoyance.
Logs and console output
Log output:
Time until bus fault occurs can vary. With 2ms sleep I have seen between 0.036 and 2.500 seconds in the logs.
Backtrace from gdb with zephyr v3.6.0:
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: