You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2019/10/20 10:08:35 UTC

[mynewt-core] branch master updated: muc/stm32: Add workaround for STM32F4x5/7 WFI error

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 3520b9a  muc/stm32: Add workaround for STM32F4x5/7 WFI error
3520b9a is described below

commit 3520b9a2981cda0787f9ed25839127ae98eeb952
Author: Jerzy Kasenberg <ka...@users.noreply.github.com>
AuthorDate: Sat Oct 19 16:27:35 2019 +0200

    muc/stm32: Add workaround for STM32F4x5/7 WFI error
    
    MCUs from STM32F405, STM32F407, STM32F415, STM32F417 family
    have documented error behaviour when exiting from sleep mode
    when WFI instruction placed at address ending with xx4 was executed.
    
    See en.DM00037591.pdf section 2.1.3 for details and conditions.
    
    It is more cumbersome to make sure WFI is at safe location so
    simplest workaround proposed by ST is implemented:
    - Add 3 NOP instructions after WFI.
---
 hw/mcu/stm/stm32_common/src/hal_os_tick.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hw/mcu/stm/stm32_common/src/hal_os_tick.c b/hw/mcu/stm/stm32_common/src/hal_os_tick.c
index 78e3a82..7496667 100644
--- a/hw/mcu/stm/stm32_common/src/hal_os_tick.c
+++ b/hw/mcu/stm/stm32_common/src/hal_os_tick.c
@@ -30,6 +30,19 @@ os_tick_idle(os_time_t ticks)
     OS_ASSERT_CRITICAL();
     __DSB();
     __WFI();
+/*
+ * Errata for STM32F405, STM32F407, STM32F415, STM32F417.
+ * When WFI instruction is placed at address ending with xxx4
+ * (also seen for addresses ending with xxx2). System may
+ * crash.
+ * Simplest workaround is to add 3 NOP instructions after WFI.
+ */
+#if defined(STM32F405xx) || defined(STM32F407xx) || \
+    defined(STM32F415xx) || defined(STM32F417xx)
+    __NOP();
+    __NOP();
+    __NOP();
+#endif
 }
 
 void