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 f2e1155  stm32: Disable WFI when OS_SYSVIEW is defined
f2e1155 is described below

commit f2e11556d50e65497b4f88768bbb0fce686a4efc
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Thu Sep 3 11:34:20 2020 +0200

    stm32: Disable WFI when OS_SYSVIEW is defined
    
    Reading RAM or FLASH from Debugger on STM32 MCUs in SLEEP (WFI)
    returns wrong values.
    If makes it almost impossible to use with SystemView when application
    runs at high clock speed and spend a lot of time in SLEEP mode.
    SystemView is often not able to correctly read header for RTT
    virtually preventing tool to detect instrumentation.
    
    This change replaces WFI with busy loop waiting for interrupts when
    OS_SYSVIEW is defined.
---
 hw/mcu/stm/stm32_common/src/hal_os_tick.c     | 10 ++++++++++
 hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c | 10 ++++++++++
 2 files changed, 20 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 375978d..9d42763 100644
--- a/hw/mcu/stm/stm32_common/src/hal_os_tick.c
+++ b/hw/mcu/stm/stm32_common/src/hal_os_tick.c
@@ -26,6 +26,15 @@
  */
 
 /*
+ * ST's MCUs seems to have problem with accessing AHB interface from SWD 
during SLEEP.
+ * This makes it almost impossible to use with SEGGER SystemView, therefore 
when OS_SYSVIEW
+ * is defined __WFI will become a loop waiting for pending interrupts.
+ */
+#if MYNEWT_VAL(OS_SYSVIEW)
+#undef __WFI
+#define __WFI() do { } while ((SCB->ICSR & (SCB_ICSR_ISRPENDING_Msk | 
SCB_ICSR_PENDSTSET_Msk)) == 0)
+#else
+/*
  * Errata for STM32F405, STM32F407, STM32F415, STM32F417.
  * When WFI instruction is placed at address like 0x080xxxx4
  * (also seen for addresses ending with xxx2). System may
@@ -43,6 +52,7 @@ __WFI(void)
                     "bx lr");
 }
 #endif
+#endif
 
 #if MYNEWT_VAL(STM32_CLOCK_LSE) == 0 || (((32768 / OS_TICKS_PER_SEC) * 
OS_TICKS_PER_SEC) != 32768) || !defined(STM32F1)
 
diff --git a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c 
b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c
index 4d678d5..4feb4b0 100644
--- a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c
+++ b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c
@@ -27,6 +27,16 @@
 /* RTC tick only if LSE is enabled and OS_TICKS_PER_SEC can work with 32768 
oscillator */
 #if MYNEWT_VAL(STM32_CLOCK_LSE) && (((32768 / OS_TICKS_PER_SEC) * 
OS_TICKS_PER_SEC) == 32768)
 
+/*
+ * ST's MCUs seems to have problem with accessing AHB interface from SWD 
during SLEEP.
+ * This makes it almost impossible to use with SEGGER SystemView, therefore 
when OS_SYSVIEW
+ * is defined __WFI will become a loop waiting for pending interrupts.
+ */
+#if MYNEWT_VAL(OS_SYSVIEW)
+#undef __WFI
+#define __WFI() do { } while ((SCB->ICSR & (SCB_ICSR_ISRPENDING_Msk | 
SCB_ICSR_PENDSTSET_Msk)) == 0)
+#endif
+
 struct hal_os_tick {
     uint32_t rtc_cnt;
 };

Reply via email to