Skip to content

Commit

Permalink
hw/mcu/stm32: Fix WFI in RAM for -O3
Browse files Browse the repository at this point in the history
Even though function stm32_wfi_from_ram() has attribute
to be placed in ram in -03 it can be inlined that can
effectively run WFI from flash.

Now additional attribute is added to make sure that
it is not inlined.

bx lr is also removed allowing compiler to make normal
exit from function (which in most cases will be bx lr)

Signed-off-by: Jerzy Kasenberg <jerzy@apache.org>
  • Loading branch information
kasjer committed Aug 17, 2024
1 parent 251f82e commit 0602777
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hw/mcu/stm/stm32_common/src/hal_os_tick.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
#endif

#if MYNEWT_VAL(STM32_WFI_FROM_RAM)
__attribute__((section(".text_ram"))) void
__attribute__((section(".text_ram"),noinline)) void
stm32_wfi_from_ram(void)
{
__ASM volatile ("wfi\n"
"bx lr");
__ASM volatile ("wfi");
}
#endif

Expand Down

0 comments on commit 0602777

Please sign in to comment.