[riot-notifications] [RIOT-OS/RIOT] cpu/stm32f1: CPU hangs after wake-up from STOP power mode (#13918)

Juergen Fitschen notifications at github.com
Wed May 6 13:05:19 CEST 2020


> @jue89: Can you check again to rule out human error? Can you temporarily add an `#error "test"` below the `#if defined(CPU_MODEL_STM32L152RE) || defined(CPU_MODEL_STM32F103CB) || defined(CPU_MODEL_STM32F103C8)` to verify that correct code gets indeed compiled?

Sure. Current master:

<details>
<summary>tests/periph_pm hangs</summary>

```
jue at bart ~/P/R/t/periph_pm $ make BOARD=bluepill flash term
2020-05-06 12:58:24,959 #  �main(): This is RIOT! (Version: 2020.07-devel-446-g8ffd34)
2020-05-06 12:58:24,961 # This application allows you to test the CPU power management.
2020-05-06 12:58:24,963 # The available power modes are 0 - 1. Lower-numbered power modes
2020-05-06 12:58:24,964 # save more power, but may require an event/interrupt to wake up
2020-05-06 12:58:24,964 # the CPU. Reset the CPU if needed.
2020-05-06 12:58:24,965 # mode 0 blockers: 1 
2020-05-06 12:58:24,965 # mode 1 blockers: 2 
2020-05-06 12:58:24,965 # Lowest allowed mode: 2
> pm unblock 1
2020-05-06 12:58:29,575 #  pm unblock 1
2020-05-06 12:58:29,576 # Unblocking power mode 1.
> unblock_rtc 1 2
2020-05-06 12:58:35,983 #  unblock_rtc 1 2
2020-05-06 12:58:35,985 # Unblocking power mode 1 for 2 seconds.
> help
help
help
help
help
```

</details>

With this patch applied (checked with `#error` inside the if statement):

```diff
diff --git a/cpu/cortexm_common/include/cpu.h b/cpu/cortexm_common/include/cpu.h
index d79d65495..9dae3e104 100644
--- a/cpu/cortexm_common/include/cpu.h
+++ b/cpu/cortexm_common/include/cpu.h
@@ -170,7 +170,7 @@ static inline void cortexm_sleep(int deep)
     unsigned state = irq_disable();
     __DSB();
     __WFI();
-#if defined(CPU_MODEL_STM32L152RE)
+#if defined(CPU_MODEL_STM32L152RE) || defined(CPU_MODEL_STM32F103CB) || defined(CPU_MODEL_STM32F103C8)
     /* STM32L152RE crashes if branching to irq_restore(state). See #11830. */
     __set_PRIMASK(state);
 #else
```

<details>
<summary>tests/periph_pm hardfaults</summary>

```
jue at bart ~/P/R/t/periph_pm $ make BOARD=bluepill flash term
2020-05-06 13:02:05,700 # main(): This is RIOT! (Version: 2020.07-devel-446-g8ffd34)
2020-05-06 13:02:05,703 # This application allows you to test the CPU power management.
2020-05-06 13:02:05,705 # The available power modes are 0 - 1. Lower-numbered power modes
2020-05-06 13:02:05,707 # save more power, but may require an event/interrupt to wake up
2020-05-06 13:02:05,708 # the CPU. Reset the CPU if needed.
2020-05-06 13:02:05,709 # mode 0 blockers: 1 
2020-05-06 13:02:05,710 # mode 1 blockers: 2 
2020-05-06 13:02:05,710 # Lowest allowed mode: 2
> pm unblock 1
2020-05-06 13:02:11,703 #  pm unblock 1
2020-05-06 13:02:11,704 # Unblocking power mode 1.
> unblock_rtc 1 2
2020-05-06 13:02:15,554 #  unblock_rtc 1 2
2020-05-06 13:02:15,555 # Unblocking power mode 1 for 2 seconds.
> help
help
help
he2020-05-06 13:02:18,478 #  
l2020-05-06 13:02:18,527 # Context before hardfault:
2020-05-06 13:02:18,528 #    r0: 0x00000001
2020-05-06 13:02:18,529 #    r1: 0xd5a0c000
2020-05-06 13:02:18,530 #    r2: 0x03035682
2020-05-06 13:02:18,531 #    r3: 0x00000014
2020-05-06 13:02:18,532 #   r12: 0x00000000
2020-05-06 13:02:18,532 #    lr: 0x00000006
2020-05-06 13:02:18,532 #    pc: 0x00000006
2020-05-06 13:02:18,533 #   psr: 0x20000000
2020-05-06 13:02:18,533 # 
2020-05-06 13:02:18,533 # FSR/FAR:
2020-05-06 13:02:18,534 #  CFSR: 0x00020000
2020-05-06 13:02:18,534 #  HFSR: 0x40000000
2020-05-06 13:02:18,534 #  DFSR: 0x00000008
2020-05-06 13:02:18,534 #  AFSR: 0x00000000
2020-05-06 13:02:18,534 # Misc
2020-05-06 13:02:18,534 # EXC_RET: 0xfffffffd
2020-05-06 13:02:18,535 # Attempting to reconstruct state for debugging...
2020-05-06 13:02:18,535 # In GDB:
2020-05-06 13:02:18,535 #   set $pc=0x6
2020-05-06 13:02:18,535 #   frame 0
2020-05-06 13:02:18,535 #   bt
2020-05-06 13:02:18,535 # 
2020-05-06 13:02:18,536 # ISR stack overflowed by at least 16 bytes.
```

</details>



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/13918#issuecomment-624583631
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200506/fd55e2ef/attachment-0001.htm>


More information about the notifications mailing list