Skip to content

Commit

Permalink
hw/bsp: Fix Watchdog interval for STM32 BSPs
Browse files Browse the repository at this point in the history
Default value 30s is out of range for all STM32 devices.

This sets WATCHDOG_INTERVAL to maximum correct value that
depends on LSI_VALUE for each MCU.

Additionally static assert is added to hal_watchdog.c
that checks if WATCHDOG_INTERVAL value does not exceed range.
  • Loading branch information
kasjer committed May 25, 2024
1 parent e9faa0b commit d6eb43f
Show file tree
Hide file tree
Showing 34 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions hw/bsp/ada_feather_stm32f405/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
# UART0 is on the large breakout connector, pins TX and RX.
UART_0_PIN_TX: 'MCU_GPIO_PORTB(10)'
UART_0_PIN_RX: 'MCU_GPIO_PORTB(11)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/b-l072z-lrwan1/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 1 # max 32MHz
STM32_FLASH_PREFETCH_ENABLE: 0
WATCHDOG_INTERVAL: 25000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
SPI_1_CUSTOM_CFG: 1
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/b-l475e-iot01a/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 0
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 25000
UART_0_PIN_TX: 'MCU_GPIO_PORTB(6)'
UART_0_PIN_RX: 'MCU_GPIO_PORTB(7)'
I2C_0_PIN_SCL: 'MCU_GPIO_PORTB(8)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/black_vet6/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 25000

SPI_0_MASTER: 1
# On board SPIFLASH configuration for W25Q16VBS
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/bluepill/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f030r8/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ syscfg.vals:
STM32_CLOCK_APB1_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_1'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f072rb/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ syscfg.vals:
STM32_CLOCK_APB1_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_1'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f103rb/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f303k8/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(15)'
UART_0_PIN_RTS: 'MCU_GPIO_PORTA(1)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f303re/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 19000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_0_PIN_RTS: 'MCU_GPIO_PORTA(1)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f401re/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_0_PIN_RTS: 'MCU_GPIO_PORTA(1)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f411re/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f413zh/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTD(8)'
UART_0_PIN_RX: 'MCU_GPIO_PORTD(9)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f439zi/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTD(8)'
UART_0_PIN_RX: 'MCU_GPIO_PORTD(9)'
UART_1_PIN_TX: 'MCU_GPIO_PORTD(5)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f746zg/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ syscfg.vals:
STM32_FLASH_LATENCY: 'FLASH_LATENCY_7'
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_ART_ACCLERATOR_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTD(8)'
UART_0_PIN_RX: 'MCU_GPIO_PORTD(9)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTD(14)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-f767zi/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ syscfg.vals:
STM32_FLASH_LATENCY: 'FLASH_LATENCY_7'
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_ART_ACCLERATOR_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTD(8)'
UART_0_PIN_RX: 'MCU_GPIO_PORTD(9)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTD(14)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-g0b1re/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ syscfg.vals:
STM32_CLOCK_APB4_DIVIDER: 'RCC_HCLK_DIV1'
STM32_CLOCK_PLLRGE: 'RCC_PLLVCIRANGE_0'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
WATCHDOG_INTERVAL: 28000
UART_0: 0
UART_1: 1
UART_0_PIN_TX: 'MCU_GPIO_PORTC(4)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-g491re/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ syscfg.vals:
STM32_CLOCK_APB4_DIVIDER: 'RCC_HCLK_DIV1'
STM32_CLOCK_PLLRGE: 'RCC_PLLVCIRANGE_0'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_4'
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(10)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(2)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-h723zg/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ syscfg.vals:
STM32_CLOCK_PLLRGE: 'RCC_PLL1VCIRANGE_3'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_3'
STM32_ENABLE_ICACHE: 0
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTD(8)'
UART_0_PIN_RX: 'MCU_GPIO_PORTD(9)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTD(14)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-l073rz/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 1 # max 32MHz
STM32_FLASH_PREFETCH_ENABLE: 0
WATCHDOG_INTERVAL: 25000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-l476rg/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 0
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 25000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/nucleo-u575zi-q/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ syscfg.vals:
STM32_CLOCK_APB4_DIVIDER: 'RCC_HCLK_DIV1'
STM32_CLOCK_PLLRGE: 'RCC_PLLVCIRANGE_0'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_4'
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(10)'
UART_1_PIN_TX: 'MCU_GPIO_PORTD(5)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/olimex-p103/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/olimex_stm32-e407_devboard/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTC(6)'
UART_0_PIN_RX: 'MCU_GPIO_PORTC(7)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/p-nucleo-wb55-usbdongle/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ syscfg.vals:
TIMER_0_TIM: 'TIM2'
TIMER_1_TIM: 'TIM16'
TIMER_2_TIM: 'TIM17'
WATCHDOG_INTERVAL: 28000

# Flasher parameters
MYNEWT_DOWNLOADER: stflash
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/p-nucleo-wb55/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ syscfg.vals:
TIMER_0_TIM: 'TIM2'
TIMER_1_TIM: 'TIM16'
TIMER_2_TIM: 'TIM17'
WATCHDOG_INTERVAL: 28000

# Flasher parameters
MYNEWT_DOWNLOADER: stflash
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/stm32f3discovery/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_2'
STM32_FLASH_PREFETCH_ENABLE: 1
WATCHDOG_INTERVAL: 22000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(10)'
SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/stm32f411discovery/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(2)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(3)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(9)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/stm32f429discovery/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(10)'
TIMER_0_TIM: 'TIM9'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/stm32f4discovery/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ syscfg.vals:
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_INSTRUCTION_CACHE_ENABLE: 1
STM32_DATA_CACHE_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTC(6)'
UART_0_PIN_RX: 'MCU_GPIO_PORTC(7)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(2)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/stm32f7discovery/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ syscfg.vals:
STM32_FLASH_LATENCY: 'FLASH_LATENCY_7'
STM32_FLASH_PREFETCH_ENABLE: 1
STM32_ART_ACCLERATOR_ENABLE: 1
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
UART_0_PIN_RX: 'MCU_GPIO_PORTB(7)'
TIMER_0_TIM: 'TIM1'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/stm32l152discovery/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ syscfg.vals:
STM32_CLOCK_APB2_DIVIDER: 'RCC_HCLK_DIV1'
STM32_FLASH_LATENCY: 1 # max 32MHz
STM32_FLASH_PREFETCH_ENABLE: 0
WATCHDOG_INTERVAL: 25000
UART_0_PIN_TX: 'MCU_GPIO_PORTB(10)'
UART_0_PIN_RX: 'MCU_GPIO_PORTB(11)'
SPI_1_PIN_SS: 'MCU_GPIO_PORTB(12)'
Expand Down
1 change: 1 addition & 0 deletions hw/bsp/weact_g431cb/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ syscfg.vals:
STM32_CLOCK_APB4_DIVIDER: 'RCC_HCLK_DIV1'
STM32_CLOCK_PLLRGE: 'RCC_PLLVCIRANGE_0'
STM32_FLASH_LATENCY: 'FLASH_LATENCY_4'
WATCHDOG_INTERVAL: 28000
UART_0_PIN_TX: 'MCU_GPIO_PORTA(9)'
UART_0_PIN_RX: 'MCU_GPIO_PORTA(10)'
UART_1_PIN_TX: 'MCU_GPIO_PORTA(2)'
Expand Down
5 changes: 5 additions & 0 deletions hw/mcu/stm/stm32_common/src/hal_watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

IWDG_HandleTypeDef g_wdt_cfg;

#if MYNEWT_VAL(WATCHDOG_INTERVAL) > 0
_Static_assert(4095 * 2560 / 11 / (LSI_VALUE / 1000) >= MYNEWT_VAL(WATCHDOG_INTERVAL),
"Watchdog interval out of range, decrease value WATCHDOG_INTERVAL in syscfg.yml");
#endif

int
hal_watchdog_init(uint32_t expire_msecs)
{
Expand Down

0 comments on commit d6eb43f

Please sign in to comment.