boards: stm32: add nucleo board stm32g474re

This patch adds the nucleo_g474re board
         based on the stm32g474 from STMicroelectronics.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2019-11-04 09:30:05 +01:00 committed by Kumar Gala
parent 4ef62a2db7
commit dbc1d6370f
11 changed files with 615 additions and 0 deletions

View File

@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_PINMUX)
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
endif()

View File

@ -0,0 +1,8 @@
# STM32G474RE Nucleo board configuration
# Copyright (c) 2019 STMicroelectronics.
# SPDX-License-Identifier: Apache-2.0
config BOARD_NUCLEO_G474RE
bool "Nucleo G474RE Development Board"
depends on SOC_STM32G474XX

View File

@ -0,0 +1,42 @@
# STM32G474RE Nucleo board configuration
# Copyright (c) 2019 STMicroelectronics.
# SPDX-License-Identifier: Apache-2.0
if BOARD_NUCLEO_G474RE
config BOARD
default "nucleo_g474re"
if UART_CONSOLE
config LPUART_1
default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
endif # I2C
if PWM
config PWM_STM32_2
default y
endif # PWM
if SPI
config SPI_1
default y
config SPI_STM32_INTERRUPT
default y
endif # SPI
endif # BOARD_NUCLEO_G431RB

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2019 STMicroelectronics.
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
arduino_header: connector {
compatible = "arduino-header-r3";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map = <0 0 &gpioa 0 0>, /* A0 */
<1 0 &gpioa 1 0>, /* A1 */
<2 0 &gpioa 4 0>, /* A2 */
<3 0 &gpiob 0 0>, /* A3 */
<4 0 &gpioc 1 0>, /* A4 */
<5 0 &gpioc 0 0>, /* A5 */
<6 0 &gpioc 5 0>, /* D0 */
<7 0 &gpioc 4 0>, /* D1 */
<8 0 &gpioa 10 0>, /* D2 */
<9 0 &gpiob 3 0>, /* D3 */
<10 0 &gpiob 5 0>, /* D4 */
<11 0 &gpiob 4 0>, /* D5 */
<12 0 &gpiob 10 0>, /* D6 */
<13 0 &gpioa 8 0>, /* D7 */
<14 0 &gpioa 9 0>, /* D8 */
<15 0 &gpioc 7 0>, /* D9 */
<16 0 &gpiob 6 0>, /* D10 */
<17 0 &gpioa 7 0>, /* D11 */
<18 0 &gpioa 6 0>, /* D12 */
<19 0 &gpioa 5 0>, /* D13 */
<20 0 &gpiob 9 0>, /* D14 */
<21 0 &gpiob 8 0>; /* D15 */
};
};
arduino_i2c: &i2c1 {};
arduino_spi: &spi1 {};
arduino_serial: &usart1 {};

View File

@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(pyocd "--target=stm32g474retx")
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -0,0 +1,243 @@
.. _nucleo_g474re_board:
ST Nucleo G474RE
################
Overview
********
The Nucleo G474RE board features an ARM Cortex-M4 based STM32G474RE MCU
with a wide range of connectivity support and configurations. Here are
some highlights of the Nucleo G474RE board:
- STM32 microcontroller in LQFP64 package
- Arduino Uno V3 connectivity
- On-board ST-LINK/V3E debugger/programmer with SWD connector
- Flexible board power supply:
- USB VBUS or external source(3.3V, 5V, 7 - 12V)
- Power management access point
- Three LEDs: USB communication (LD1), power LED (LD3), user LED (LD2)
- Two push-buttons: RESET and USER
.. image:: img/nucleo_g474re.jpg
:width: 426px
:align: center
:height: 256px
:alt: Nucleo G474RE
More information about the board can be found at the `Nucleo G474RE website`_.
Hardware
********
The STM32G474RE SoC provides the following hardware IPs:
- Ultra-low-power with FlexPowerControl (down to 28 nA Standby mode and 84
|micro| A/MHz run mode)
- Core: ARM |reg| 32-bit Cortex |reg| -M4 CPU with FPU, frequency up to 170 MHz
- Clock Sources:
- 4 to 48 MHz crystal oscillator (HSE)
- 32 kHz crystal oscillator for RTC (LSE)
- Internal 16 MHz factory-trimmed RC ( |plusminus| 1%)
- Internal low-power 32 kHz RC ( |plusminus| 5%)
- 2 PLLs for system clock, USB, audio, ADC
- RTC with HW calendar, alarms and calibration
- 14x timers:
- 1x 32-bit timer and 2x 16-bit timers with up to four IC/OC/PWM or pulse counter and quadrature (incremental) encoder input
- 2x 16-bit 8-channel advanced motor control timers, with up to 8x PWM channels, dead time generation and emergency stop
- 1x 16-bit timer with 2x IC/OCs, one OCN/PWM, dead time generation and emergency stop
- 2x 16-bit timers with IC/OC/OCN/PWM, dead time generation and emergency stop
- 2x watchdog timers (independent, window)
- 2x 16-bit basic timers
- SysTick timer
- 1x low-power timer
- Up to 86 fast I/Os, most 5 V-tolerant
- Memories
- Up to 128 KB single bank Flash, proprietary code readout protection
- Up to 22 KB of SRAM including 16 KB with hardware parity check
- Rich analog peripherals (independent supply)
- 2x 12-bit ADC 5 MSPS, up to 16-bit with hardware oversampling, 200
|micro| A/MSPS
- 4x 12-bit DAC, low-power sample and hold
- 3x operational amplifiers with built-in PGA
- 4x ultra-fast rail-to-rail analog comparators
- 16x communication interfaces
- 1 x FDCAN controller supporting flexible data rate
- 3x I2C FM+(1 Mbit/s), SMBus/PMBus
- 4x USARTs (ISO 7816, LIN, IrDA, modem)
- 1x LPUART
- 3x SPIs (2x with multiplexed half duplex I2S interface)
- 1x SAI (serial audio interface)
- USB 2.0 full-speed interface with LPM and BCD support
- IRTIM (Infrared interface)
- USB Type-C™ /USB power delivery controller (UCPD)
- 12-channel DMA controller
- True random number generator (RNG)
- CRC calculation unit, 96-bit unique ID
- Development support: serial wire debug (SWD), JTAG, Embedded Trace Macrocell*
More information about STM32G474RE can be found here:
- `STM32G474RE on www.st.com`_
- `STM32G4 reference manual`_
Supported Features
==================
The Zephyr nucleo_g474re board configuration supports the following hardware features:
+-----------+------------+-------------------------------------+
| Interface | Controller | Driver/Component |
+===========+============+=====================================+
| NVIC | on-chip | nested vector interrupt controller |
+-----------+------------+-------------------------------------+
| UART | on-chip | serial port-polling; |
| | | serial port-interrupt |
+-----------+------------+-------------------------------------+
| PINMUX | on-chip | pinmux |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| I2C | on-chip | i2c |
+-----------+------------+-------------------------------------+
| PWM | on-chip | pwm |
+-----------+------------+-------------------------------------+
Other hardware features are not yet supported on this Zephyr port.
The default configuration can be found in the defconfig file:
``boards/arm/nucleo_g474re/nucleo_g474re_defconfig``
Connections and IOs
===================
Nucleo G474RE Board has 6 GPIO controllers. These controllers are responsible for pin muxing,
input/output, pull-up, etc.
For mode details please refer to `STM32G4 Nucleo-64 board User Manual`_.
Default Zephyr Peripheral Mapping:
----------------------------------
.. rst-class:: rst-columns
- UART_1_TX : PC4
- UART_1_RX : PC5
- UART_2_TX : PA2
- UART_2_RX : PA15
- I2C_1_SCL : PB8
- I2C_1_SDA : PB9
- SPI_1_NSS : PB6
- SPI_1_SCK : PB3
- SPI_1_MISO : PA6
- SPI_1_MOSI : PA7
- SPI_2_NSS : PB12
- SPI_2_SCK : PB13
- SPI_2_MISO : PB14
- SPI_2_MOSI : PB15
- SPI_3_NSS : PA15
- SPI_3_SCK : PC10
- SPI_3_MISO : PC11
- SPI_3_MOSI : PC12
- PWM_3_CH1 : PB4
- USER_PB : PC13
- LD2 : PA5
- USB DM : PA11
- USB DP : PA12
System Clock
------------
Nucleo G474RE System Clock could be driven by internal or external oscillator,
as well as main PLL clock. By default System clock is driven by PLL clock at 150MHz,
driven by 16MHz high speed internal oscillator. The clock can be boosted to 170MHz if boost mode
is selected.
Serial Port
-----------
Nucleo G474RE board has 3 U(S)ARTs. The Zephyr console output is assigned to UART2.
Default settings are 115200 8N1.
Programming and Debugging
*************************
Applications for the ``nucleo_g474re`` board configuration can be built and
flashed in the usual way (see :ref:`build_an_application` and
:ref:`application_run` for more details).
Flashing
========
Nucleo G474RE board includes an ST-LINK/V3E embedded debug tool
interface. This interface is not yet supported by the openocd version.
Instead, support can be enabled on pyocd by adding "pack" support with
the following pyocd command:
.. code-block:: console
$ pyocd pack --install stm32g474re
Flashing an application to Nucleo G474RE
----------------------------------------
Connect the Nucleo G474RE to your host computer using the USB port,
then run a serial host program to connect with your Nucleo board.
.. code-block:: console
$ minicom -D /dev/ttyACM0
Now build and flash an application. Here is an example for
:ref:`hello_world`.
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: nucleo_g474re
:goals: build flash
You should see the following message on the console:
.. code-block:: console
$ Hello World! arm
Debugging
=========
You can debug an application in the usual way. Here is an example for the
:ref:`hello_world` application.
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: nucleo_g474re
:maybe-skip-config:
:goals: debug
.. _Nucleo G474RE website:
http://www.st.com/en/evaluation-tools/nucleo-g474re.html
.. _STM32G4 Nucleo-64 board User Manual:
https://www.st.com/resource/en/user_manual/dm00556337.pdf
.. _STM32G474RE on www.st.com:
http://www.st.com/en/microcontrollers/stm32g474re.html
.. _STM32G4 reference manual:
https://www.st.com/resource/en/reference_manual/dm00355726.pdf

View File

@ -0,0 +1,112 @@
/*
* Copyright (c) 2019 STMicroelectronics.
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <st/g4/stm32g474Xe.dtsi>
#include "arduino_r3_connector.dtsi"
/ {
model = "STMicroelectronics STM32G474RE-NUCLEO board";
compatible = "st,stm32g474re-nucleo", "st,stm32g474";
chosen {
zephyr,console = &lpuart1;
zephyr,shell-uart = &lpuart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};
leds {
compatible = "gpio-leds";
green_led: led_0 {
gpios = <&gpioa 5 GPIO_INT_ACTIVE_HIGH>;
label = "User LD2";
};
};
pwmleds {
compatible = "pwm-leds";
green_pwm_led: green_pwm_led {
pwms = <&{/soc/timers@40000000/pwm} 1 4>;
};
};
gpio_keys {
compatible = "gpio-keys";
user_button: button {
label = "User";
gpios = <&gpioc 13 GPIO_INT_ACTIVE_LOW>;
};
};
aliases {
led0 = &green_led;
pwm-led0 = &green_pwm_led;
sw0 = &user_button;
};
};
&usart1 {
current-speed = <115200>;
status = "okay";
};
&usart2 {
current-speed = <115200>;
status = "okay";
};
&lpuart1 {
current-speed = <115200>;
status = "okay";
};
&i2c1 {
status = "okay";
};
&spi1 {
status = "okay";
};
&timers2 {
status = "okay";
pwm {
status = "okay";
};
};
&usb {
status = "okay";
};
&rtc {
status = "okay";
};
&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* Set 2Kb of storage at the end of the 128Kb of flash */
storage_partition: partition@1f800 {
label = "storage";
reg = <0x0001f800 0x00000800>;
};
};
};
&iwdg {
status = "okay";
};

View File

@ -0,0 +1,21 @@
identifier: nucleo_g474re
name: NUCLEO-G474RE
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 32
flash: 128
supported:
- arduino_gpio
- arduino_i2c
- arduino_spi
- nvs
- pwm
- i2c
- gpio
- usb device
- counter
- spi

View File

@ -0,0 +1,58 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_ARM=y
CONFIG_SOC_SERIES_STM32G4X=y
CONFIG_SOC_STM32G474XX=y
# 170MHz system clock only in 'boost power' mode. RM0440, section
# 5.1.5 states that the R1MODE bit must be cleared before system can
# be 170MHz. This requires an update to the stm32 clock control
# driver, so default to 150MHz until then.
# CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=170000000
# 150MHz system clock in 'normal power' mode
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
# enable uart driver
CONFIG_SERIAL=y
# enable pinmux
CONFIG_PINMUX=y
# enable GPIO
CONFIG_GPIO=y
# clock configuration
CONFIG_CLOCK_CONTROL=y
# Use PLLCLK for SYSCLK
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# Use HSI (16MHz) to feed into PLL
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=4
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
# Produce 150MHz clock at PLLCLK output
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=75
# Comment out above and uncomment below for 170MHz. Note that you
# must have configured the mcu for boost power mode.
# CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=85
# Produce Max (150MHz or 170MHz) HCLK
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
# Produce Max (150MHz or 170MHz) APB1 clocks and APB2 clocks
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
# Console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Enable MPU
CONFIG_ARM_MPU=y

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 2019 STMicroelectronics.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <drivers/pinmux.h>
#include <sys/sys_io.h>
#include <pinmux/stm32/pinmux_stm32.h>
/* pin assignments for NUCLEO-G474RE board */
static const struct pin_config pinconf[] = {
#ifdef CONFIG_UART_1
{STM32_PIN_PC4, STM32G4X_PINMUX_FUNC_PC4_USART1_TX},
{STM32_PIN_PC5, STM32G4X_PINMUX_FUNC_PC5_USART1_RX},
#endif /* CONFIG_UART_1 */
#ifdef CONFIG_LPUART_1
{STM32_PIN_PA2, STM32G4X_PINMUX_FUNC_PA2_LPUART1_TX},
{STM32_PIN_PA3, STM32G4X_PINMUX_FUNC_PA3_LPUART1_RX},
#endif /* CONFIG_LPUART_1 */
#ifdef CONFIG_UART_2
{STM32_PIN_PA2, STM32G4X_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_USART2_RX},
#endif /* CONFIG_UART_2 */
#ifdef CONFIG_I2C_1
{STM32_PIN_PB8, STM32G4X_PINMUX_FUNC_PB8_I2C1_SCL},
{STM32_PIN_PB9, STM32G4X_PINMUX_FUNC_PB9_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_PWM_STM32_2
{STM32_PIN_PA5, STM32G4X_PINMUX_FUNC_PA5_PWM2_CH1},
#endif /* CONFIG_PWM_STM32_2 */
#ifdef CONFIG_SPI_1
/* SPI1 on the Arduino connectors pins A2, D3, D11, D12 */
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PA4, STM32G4X_PINMUX_FUNC_PA4_SPI1_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
/* SPI1_SCK should output on PA5, but is used for LD2 */
{STM32_PIN_PB3, STM32G4X_PINMUX_FUNC_PB3_SPI1_SCK},
{STM32_PIN_PA6, STM32G4X_PINMUX_FUNC_PA6_SPI1_MISO},
{STM32_PIN_PA7, STM32G4X_PINMUX_FUNC_PA7_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_SPI_2
/* SPI2 on the ST Morpho Connector CN10 pins 16, 30, 28, 26*/
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PB12, STM32G4X_PINMUX_FUNC_PB12_SPI2_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
{STM32_PIN_PB13, STM32G4X_PINMUX_FUNC_PB13_SPI2_SCK},
{STM32_PIN_PB14, STM32G4X_PINMUX_FUNC_PB14_SPI2_MISO},
{STM32_PIN_PB15, STM32G4X_PINMUX_FUNC_PB15_SPI2_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_SPI_3
/* SPI3 on the ST Morpho Connector CN7 pins 17, 1, 2, 3*/
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_SPI3_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
{STM32_PIN_PC10, STM32G4X_PINMUX_FUNC_PC10_SPI3_SCK},
{STM32_PIN_PC11, STM32G4X_PINMUX_FUNC_PC11_SPI3_MISO},
{STM32_PIN_PC12, STM32G4X_PINMUX_FUNC_PC12_SPI3_MOSI},
#endif /* CONFIG_SPI_3 */
#ifdef CONFIG_USB_DC_STM32
{STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_USB_DM},
{STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_USB_DP},
#endif /* CONFIG_USB_DC_STM32 */
};
static int pinmux_stm32_init(struct device *port)
{
ARG_UNUSED(port);
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
return 0;
}
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);