Skip to content

Commit

Permalink
Merge pull request #20149 from maribu/cpu/stm32/buf-wfi
Browse files Browse the repository at this point in the history
cpu/cortexm_common: work around bug on WFI for STM32
  • Loading branch information
maribu authored Dec 9, 2023
2 parents 46571b6 + 1c281d2 commit 43e62e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cpu/cortexm_common/include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ static inline void cortexm_sleep(int deep)
unsigned state = irq_disable();
__DSB();
__WFI();
/* Some CPUs require an ISB after WFI to work around silicon bugs */
#if CORTEXM_ISB_REQUIRED_AFTER_WFI
__ISB();
#endif
irq_restore(state);
}

Expand Down
10 changes: 10 additions & 0 deletions cpu/stm32/include/cpu_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
extern "C" {
#endif

/**
* @brief Enable workaround for bug in WFI by issuing an ISB
*
* This works around a bug on STM32 systems, see [1] for details, or [2] for
* an archive.org backup.
* [1]: https://cliffle.com/blog/stm32-wfi-bug
* [2]: https://web.archive.org/web/20231205101603/https://cliffle.com/blog/stm32-wfi-bug/
*/
#define CORTEXM_ISB_REQUIRED_AFTER_WFI 1

/**
* @brief ARM Cortex-M specific CPU configuration
* @{
Expand Down

0 comments on commit 43e62e6

Please sign in to comment.