[PATCH 1/3] prepared patch

Robin Müller robin.mueller.m at gmail.com
Mon Jan 4 15:20:06 UTC 2021


Patch can also be found here: https://devel.rtems.org/ticket/4209#comment:3

Kind Regards
Robin

On Mon, 4 Jan 2021 at 16:12, Robin.Mueller <robin.mueller.m at gmail.com>
wrote:

> I added the weak attribute to some configuration structs so users can can
> supply their own configuration
> structs (otherwise I got redeclaration linker errors).
> ---
>  bsps/arm/stm32h7/console/console-usart3.c     | 23 ++++++++++++++++++-
>  bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h |  8 +++++++
>  bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h |  1 +
>  bsps/arm/stm32h7/start/stm32h7-config.c       | 11 ++++++---
>  bsps/arm/stm32h7/start/system_stm32h7xx.c     |  6 +++++
>  spec/build/bsps/arm/stm32h7/bspstm32h7.yml    |  2 ++
>  spec/build/bsps/arm/stm32h7/opth743nucleo.yml | 13 +++++++++++
>  7 files changed, 60 insertions(+), 4 deletions(-)
>  create mode 100644 spec/build/bsps/arm/stm32h7/opth743nucleo.yml
>
> diff --git a/bsps/arm/stm32h7/console/console-usart3.c
> b/bsps/arm/stm32h7/console/console-usart3.c
> index 6e0a10fe46..c84f6eb417 100644
> --- a/bsps/arm/stm32h7/console/console-usart3.c
> +++ b/bsps/arm/stm32h7/console/console-usart3.c
> @@ -25,13 +25,33 @@
>   * POSSIBILITY OF SUCH DAMAGE.
>   */
>
> +#ifdef __rtems__
> +#include <bspopts.h>
> +#endif
> +
>  #ifdef HAVE_CONFIG_H
>  #include "config.h"
>  #endif
>
>  #include <stm32h7/hal.h>
>
> -static const stm32h7_uart_config stm32h7_usart3_config = {
> +#if STM32H743ZI_NUCLEO == 1
> +__attribute__((weak)) static const stm32h7_uart_config
> stm32h7_usart3_config = {
> +  .gpio = {
> +    .regs = GPIOD,
> +    .config = {
> +      .Pin = GPIO_PIN_8 | GPIO_PIN_9,
> +      .Mode = GPIO_MODE_AF_PP,
> +      .Pull = GPIO_NOPULL,
> +      .Speed = GPIO_SPEED_FREQ_LOW,
> +      .Alternate = GPIO_AF7_USART3
> +    }
> +  },
> +  .irq = USART3_IRQn,
> +  .device_index = 2
> +};
> +#else
> +__attribute__((weak)) static const stm32h7_uart_config
> stm32h7_usart3_config = {
>    .gpio = {
>      .regs = GPIOB,
>      .config = {
> @@ -45,6 +65,7 @@ static const stm32h7_uart_config stm32h7_usart3_config =
> {
>    .irq = USART3_IRQn,
>    .device_index = 2
>  };
> +#endif
>
>  stm32h7_uart_context stm32h7_usart3_instance = {
>    .uart = {
> diff --git a/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
> b/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
> index d423e4f782..7dd73075ba 100644
> --- a/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
> +++ b/bsps/arm/stm32h7/include/stm32h7xx_hal_conf.h
> @@ -21,6 +21,9 @@
>  #ifndef __STM32H7xx_HAL_CONF_H
>  #define __STM32H7xx_HAL_CONF_H
>
> +#ifdef __rtems__
> +#include <bspopts.h>
> +#endif /* __rtems__ */
>  #ifdef __cplusplus
>   extern "C" {
>  #endif
> @@ -103,7 +106,12 @@
>    *        (when HSE is used as system clock source, directly or through
> the PLL).
>    */
>  #if !defined  (HSE_VALUE)
> +#if STM32H743ZI_NUCLEO == 1
> +// HSE for the STM32H743ZI Nucleo
> +#define HSE_VALUE    ((uint32_t)8000000)
> +#else
>  #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External
> oscillator in Hz : FPGA case fixed to 60MHZ */
> +#endif
>  #endif /* HSE_VALUE */
>
>  #if !defined  (HSE_STARTUP_TIMEOUT)
> diff --git a/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
> b/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
> index e9fecc4aa0..b171f7dac7 100644
> --- a/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
> +++ b/bsps/arm/stm32h7/include/stm32h7xx_hal_uart.h
> @@ -27,6 +27,7 @@ extern "C" {
>
>  /* Includes
> ------------------------------------------------------------------*/
>  #include "stm32h7xx_hal_def.h"
> +#include "stm32h7xx_hal_dma.h"
>
>  /** @addtogroup STM32H7xx_HAL_Driver
>    * @{
> diff --git a/bsps/arm/stm32h7/start/stm32h7-config.c
> b/bsps/arm/stm32h7/start/stm32h7-config.c
> index 874ad047db..22422f2c38 100644
> --- a/bsps/arm/stm32h7/start/stm32h7-config.c
> +++ b/bsps/arm/stm32h7/start/stm32h7-config.c
> @@ -29,12 +29,17 @@
>  #include "config.h"
>  #endif
>
> +#ifdef __rtems__
> +#include <bspopts.h>
> +#endif
> +
>  #include <stm32h7/hal.h>
>
> +
>  const uint32_t stm32h7_config_pwr_regulator_voltagescaling =
>    PWR_REGULATOR_VOLTAGE_SCALE0;
>
> -const RCC_OscInitTypeDef stm32h7_config_oscillator = {
> +__attribute__((weak)) const RCC_OscInitTypeDef stm32h7_config_oscillator
> = {
>    .OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE
>      | RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_HSI48,
>    .HSEState = RCC_HSE_ON,
> @@ -54,7 +59,7 @@ const RCC_OscInitTypeDef stm32h7_config_oscillator = {
>    .PLL.PLLFRACN = 0
>  };
>
> -const RCC_ClkInitTypeDef stm32h7_config_clocks = {
> +__attribute__((weak)) const RCC_ClkInitTypeDef stm32h7_config_clocks = {
>    .ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
>      | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2
>      | RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1,
> @@ -69,7 +74,7 @@ const RCC_ClkInitTypeDef stm32h7_config_clocks = {
>
>  const uint32_t stm32h7_config_flash_latency = FLASH_LATENCY_4;
>
> -const RCC_PeriphCLKInitTypeDef stm32h7_config_peripheral_clocks = {
> +__attribute__((weak)) const RCC_PeriphCLKInitTypeDef
> stm32h7_config_peripheral_clocks = {
>    .PeriphClockSelection = RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_USART3
>      | RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1
>      | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_FMC | RCC_PERIPHCLK_RNG,
> diff --git a/bsps/arm/stm32h7/start/system_stm32h7xx.c
> b/bsps/arm/stm32h7/start/system_stm32h7xx.c
> index 092d853720..65c5a65ef0 100644
> --- a/bsps/arm/stm32h7/start/system_stm32h7xx.c
> +++ b/bsps/arm/stm32h7/start/system_stm32h7xx.c
> @@ -48,10 +48,16 @@
>  #include "stm32h7xx.h"
>  #include <math.h>
>  #ifdef __rtems__
> +#include <bspopts.h>
>  #include <bsp/linker-symbols.h>
>  #endif /* __rtems__ */
> +
>  #if !defined  (HSE_VALUE)
> +#if STM32H743ZI_NUCLEO
> +#define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External
> oscillator in Hz */
> +#else
>  #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External
> oscillator in Hz */
> +#endif
>  #endif /* HSE_VALUE */
>
>  #if !defined  (CSI_VALUE)
> diff --git a/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
> b/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
> index 835247316c..cd3446d1d4 100644
> --- a/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
> +++ b/spec/build/bsps/arm/stm32h7/bspstm32h7.yml
> @@ -244,6 +244,8 @@ links:
>    uid: ../../optconsolebaud
>  - role: build-dependency
>    uid: ../../optconsoleirq
> +- role: build-dependency
> +  uid: opth743nucleo
>  - role: build-dependency
>    uid: ../grp
>  - role: build-dependency
> diff --git a/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> new file mode 100644
> index 0000000000..3e68455893
> --- /dev/null
> +++ b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> @@ -0,0 +1,13 @@
> +actions:
> +- get-boolean: null
> +- define-condition: null
> +build-type: option
> +default: false
> +default-by-variant: []
> +enabled-by: true
> +format: '{}'
> +links: []
> +name: STM32H743ZI_NUCLEO
> +description: |
> +  Nucleo board. Use 8 MHz HSE external clock.
> +type: build
> --
> 2.25.1
>
>
> From 4e2645f7586508b0f68e2fb19f888e92d4ac5530 Mon Sep 17 00:00:00 2001
> From: "Robin.Mueller" <robin.mueller.m at gmail.com>
> Date: Mon, 4 Jan 2021 16:00:46 +0100
> Subject: [PATCH 2/3] functions made public
>
> ---
>  bsps/arm/stm32h7/console/console-usart3.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bsps/arm/stm32h7/console/console-usart3.c
> b/bsps/arm/stm32h7/console/console-usart3.c
> index c84f6eb417..555669436e 100644
> --- a/bsps/arm/stm32h7/console/console-usart3.c
> +++ b/bsps/arm/stm32h7/console/console-usart3.c
> @@ -36,7 +36,7 @@
>  #include <stm32h7/hal.h>
>
>  #if STM32H743ZI_NUCLEO == 1
> -__attribute__((weak)) static const stm32h7_uart_config
> stm32h7_usart3_config = {
> +__attribute__((weak)) const stm32h7_uart_config stm32h7_usart3_config = {
>    .gpio = {
>      .regs = GPIOD,
>      .config = {
> @@ -51,7 +51,7 @@ __attribute__((weak)) static const stm32h7_uart_config
> stm32h7_usart3_config = {
>    .device_index = 2
>  };
>  #else
> -__attribute__((weak)) static const stm32h7_uart_config
> stm32h7_usart3_config = {
> +__attribute__((weak)) const stm32h7_uart_config stm32h7_usart3_config = {
>    .gpio = {
>      .regs = GPIOB,
>      .config = {
> --
> 2.25.1
>
>
> From 0cb2f4f4deb0015f96866bc00869095b2e637437 Mon Sep 17 00:00:00 2001
> From: "Robin.Mueller" <robin.mueller.m at gmail.com>
> Date: Mon, 4 Jan 2021 16:04:03 +0100
> Subject: [PATCH 3/3] better help output
>
> ---
>  spec/build/bsps/arm/stm32h7/opth743nucleo.yml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> index 3e68455893..2c4176bf00 100644
> --- a/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> +++ b/spec/build/bsps/arm/stm32h7/opth743nucleo.yml
> @@ -9,5 +9,5 @@ format: '{}'
>  links: []
>  name: STM32H743ZI_NUCLEO
>  description: |
> -  Nucleo board. Use 8 MHz HSE external clock.
> +  Nucleo board. Use 8 MHz HSE external clock and different pins for the
> UART console.
>  type: build
> --
> 2.25.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210104/a6d9bb7f/attachment-0001.html>


More information about the devel mailing list