Skip to content

Commit

Permalink
stm32h7: Reset USART clock selection (#23498) (#23516)
Browse files Browse the repository at this point in the history
This resets the USARTs' clock source selection to the default, in case
it has been changed by the bootloader.

This is required if booting from the ArduPilot bootloader which happens
to reset the clock selection to PLL.

Without this fix, UARTs (including the console) is garbled, so
presumably at an invalid baudrate.
  • Loading branch information
julianoes authored Aug 8, 2024
1 parent 631f36b commit fe26cde
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions boards/cubepilot/cubeorange/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@

#define STM32_RCC_D3CCIPR_ADCSRC RCC_D3CCIPR_ADCSEL_PLL2 /* ADC 1 2 3 clock source */

/* UART clock selection */
/* reset to default to overwrite any changes done by any bootloader */

#define STM32_RCC_D2CCIP2R_USART234578_SEL RCC_D2CCIP2R_USART234578SEL_RCC
#define STM32_RCC_D2CCIP2R_USART16_SEL RCC_D2CCIP2R_USART16SEL_RCC

/* FLASH wait states */
#define BOARD_FLASH_WAITSTATES 2

Expand Down
6 changes: 6 additions & 0 deletions boards/cubepilot/cubeorangeplus/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@

#define STM32_RCC_D3CCIPR_ADCSRC RCC_D3CCIPR_ADCSEL_PLL2 /* ADC 1 2 3 clock source */

/* UART clock selection */
/* reset to default to overwrite any changes done by any bootloader */

#define STM32_RCC_D2CCIP2R_USART234578_SEL RCC_D2CCIP2R_USART234578SEL_RCC
#define STM32_RCC_D2CCIP2R_USART16_SEL RCC_D2CCIP2R_USART16SEL_RCC

/* FLASH wait states */
#define BOARD_FLASH_WAITSTATES 2

Expand Down
6 changes: 6 additions & 0 deletions boards/px4/fmu-v6c/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@

#define STM32_RCC_D2CCIP2R_USBSRC RCC_D2CCIP2R_USBSEL_PLL3

/* UART clock selection */
/* reset to default to overwrite any changes done by any bootloader */

#define STM32_RCC_D2CCIP2R_USART234578_SEL RCC_D2CCIP2R_USART234578SEL_RCC
#define STM32_RCC_D2CCIP2R_USART16_SEL RCC_D2CCIP2R_USART16SEL_RCC

/* ADC 1 2 3 clock source */

#define STM32_RCC_D3CCIPR_ADCSRC RCC_D3CCIPR_ADCSEL_PLL2
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/fmu-v6x/nuttx-config/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@

#define STM32_RCC_D3CCIPR_ADCSRC RCC_D3CCIPR_ADCSEL_PLL2

/* UART clock selection */
/* reset to default to overwrite any changes done by any bootloader */

#define STM32_RCC_D2CCIP2R_USART234578_SEL RCC_D2CCIP2R_USART234578SEL_RCC
#define STM32_RCC_D2CCIP2R_USART16_SEL RCC_D2CCIP2R_USART16SEL_RCC

/* FDCAN 1 2 clock source */

#define STM32_RCC_D2CCIP1R_FDCANSEL RCC_D2CCIP1R_FDCANSEL_HSE /* FDCAN 1 2 clock source */
Expand Down

0 comments on commit fe26cde

Please sign in to comment.