Skip to content

Commit ec53c8a

Browse files
arthurpiAnas Nashif
authored andcommitted
boards: arm: Add support for STM32L476G Discovery board
Add configuration, pinmux, dts and documentation for the STM32L476G Discovery board based on the STM32L476VG SoC. Signed-off-by: Arthur SFEZ <[email protected]>
1 parent c1d9cb7 commit ec53c8a

14 files changed

+441
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
zephyr_library()
2+
zephyr_library_sources(pinmux.c)
3+
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Kconfig - STM32L476G Discovery board configuration
2+
#
3+
# Copyright (c) 2017 Arthur Sfez
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
config BOARD_STM32L476G_DISCO
9+
bool "STM32L476G Discovery Development Board"
10+
depends on SOC_STM32L476XG
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Kconfig - STM32L476G DISCOVERY board configuration
2+
#
3+
# Copyright (c) 2017 Arthur Sfez
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if BOARD_STM32L476G_DISCO
9+
10+
config BOARD
11+
default stm32l476g_disco
12+
13+
endif # BOARD_STM32L476G_DISCO
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include($ENV{ZEPHYR_BASE}/boards/common/openocd.board.cmake)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2017 Arthur Sfez
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef __INC_BOARD_H
8+
#define __INC_BOARD_H
9+
10+
#include <soc.h>
11+
12+
/* LD4 red LED */
13+
#define LD4_GPIO_PORT "GPIOB"
14+
#define LD4_GPIO_PIN 2
15+
16+
/* LD5 green LED */
17+
#define LD5_GPIO_PORT "GPIOE"
18+
#define LD5_GPIO_PIN 8
19+
20+
/* Create aliases to make the basic samples work */
21+
#define LED0_GPIO_PORT LD4_GPIO_PORT
22+
#define LED0_GPIO_PIN LD4_GPIO_PIN
23+
#define LED1_GPIO_PORT LD5_GPIO_PORT
24+
#define LED1_GPIO_PIN LD5_GPIO_PIN
25+
26+
#endif /* __INC_BOARD_H */
239 KB
Loading
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
.. _stm32l476g_disco_board:
2+
3+
ST STM32L476G Discovery
4+
########################
5+
6+
Overview
7+
********
8+
9+
The STM32L476G Discovery board features an ARM Cortex-M4 based STM32L476VG MCU
10+
with a wide range of connectivity support and configurations. Here are
11+
some highlights of the STM32L476G Discovery board:
12+
13+
14+
- STM32L476VGT6 microcontroller featuring 1 Mbyte of Flash memory, 128 Kbytes of RAM in LQFP100 package
15+
- On-board ST-LINK/V2-1 supporting USB re-enumeration capability
16+
- Three different interfaces supported on USB:
17+
18+
- Virtual com port
19+
- Mass storage
20+
- Debug port
21+
22+
- LCD 24 segments, 4 commons in DIP 28 package
23+
- Seven LEDs:
24+
25+
- LD1 (red/green) for USB communication
26+
- LD2 (red) for 3.3 V power on
27+
- LD3 Over current (red)
28+
- LD4 (red), LD5 (green) two user LEDs
29+
- LD6 (green), LD7 (red) USB OTG FS LEDs
30+
31+
- Pushbutton (reset)
32+
- Four directions Joystick with selection
33+
- USB OTG FS with micro-AB connector
34+
- SAI Audio DAC, Stereo with output jack
35+
- Digital microphone, accelerometer, magnetometer and gyroscope MEMS
36+
- 128-Mbit Quad-SPI Flash memory
37+
- MCU current ammeter with 4 ranges and auto-calibration
38+
- Connector for external board or RF-EEPROM
39+
- Four power supply options:
40+
- ST-LINK/V2-1
41+
- USB FS connector
42+
- External 5 V
43+
- CR2032 battery (not provided)
44+
45+
.. image:: img/en.stm32l476g-disco.jpg
46+
:width: 450px
47+
:align: center
48+
:height: 394px
49+
:alt: STM32L476G Discovery
50+
51+
More information about the board can be found at the `STM32L476G Discovery website`_.
52+
53+
Hardware
54+
********
55+
56+
The STM32L476VG SoC provides the following hardware features:
57+
58+
- Ultra-low-power with FlexPowerControl (down to 130 nA Standby mode and 100 uA/MHz run mode)
59+
- Core: ARM |reg| 32-bit Cortex |reg|-M4 CPU with FPU, frequency up to 80 MHz, 100DMIPS/1.25DMIPS/MHz (Dhrystone 2.1)
60+
- Clock Sources:
61+
- 4 to 48 MHz crystal oscillator
62+
- 32 kHz crystal oscillator for RTC (LSE)
63+
- Internal 16 MHz factory-trimmed RC ( |plusminus| 1%)
64+
- Internal low-power 32 kHz RC ( |plusminus| 5%)
65+
- Internal multispeed 100 kHz to 48 MHz oscillator, auto-trimmed by
66+
LSE (better than |plusminus| 0.25 % accuracy)
67+
- 3 PLLs for system clock, USB, audio, ADC
68+
- RTC with HW calendar, alarms and calibration
69+
- LCD 8 x 40 or 4 x 44 with step-up converter
70+
- Up to 24 capacitive sensing channels: support touchkey, linear and rotary touch sensors
71+
- 16x timers:
72+
- 2x 16-bit advanced motor-control
73+
- 2x 32-bit and 5x 16-bit general purpose
74+
- 2x 16-bit basic
75+
- 2x low-power 16-bit timers (available in Stop mode)
76+
- 2x watchdogs
77+
- SysTick timer
78+
- Up to 114 fast I/Os, most 5 V-tolerant, up to 14 I/Os with independent supply down to 1.08 V
79+
- Memories
80+
- Up to 1 MB Flash, 2 banks read-while-write, proprietary code readout protection
81+
- Up to 128 KB of SRAM including 32 KB with hardware parity check
82+
- External memory interface for static memories supporting SRAM, PSRAM, NOR and NAND memories
83+
- Quad SPI memory interface
84+
- 4x digital filters for sigma delta modulator
85+
- Rich analog peripherals (independent supply)
86+
- 3x 12-bit ADC 5 MSPS, up to 16-bit with hardware oversampling, 200 uA/MSPS
87+
- 2x 12-bit DAC, low-power sample and hold
88+
- 2x operational amplifiers with built-in PGA
89+
- 2x ultra-low-power comparators
90+
- 18x communication interfaces
91+
- USB OTG 2.0 full-speed, LPM and BCD
92+
- 2x SAIs (serial audio interface)
93+
- 3x I2C FM+(1 Mbit/s), SMBus/PMBus
94+
- 6x USARTs (ISO 7816, LIN, IrDA, modem)
95+
- 3x SPIs (4x SPIs with the Quad SPI)
96+
- CAN (2.0B Active) and SDMMC interface
97+
- SWPMI single wire protocol master I/F
98+
- 14-channel DMA controller
99+
- True random number generator
100+
- CRC calculation unit, 96-bit unique ID
101+
- Development support: serial wire debug (SWD), JTAG, Embedded Trace Macrocell |trade|
102+
103+
104+
More information about STM32L476VG can be found here:
105+
- `STM32L476VG on www.st.com`_
106+
- `STM32L476 reference manual`_
107+
108+
109+
Supported Features
110+
==================
111+
112+
The Zephyr stm32l476g_disco board configuration supports the following hardware features:
113+
114+
+-----------+------------+-------------------------------------+
115+
| Interface | Controller | Driver/Component |
116+
+===========+============+=====================================+
117+
| NVIC | on-chip | nested vector interrupt controller |
118+
+-----------+------------+-------------------------------------+
119+
| UART | on-chip | serial port-polling; |
120+
| | | serial port-interrupt |
121+
+-----------+------------+-------------------------------------+
122+
| PINMUX | on-chip | pinmux |
123+
+-----------+------------+-------------------------------------+
124+
| GPIO | on-chip | gpio |
125+
+-----------+------------+-------------------------------------+
126+
127+
Other hardware features are not yet supported on this Zephyr port.
128+
129+
The default configuration can be found in the defconfig file:
130+
131+
``boards/arm/stm32l476g_disco/stm32l476g_disco_defconfig``
132+
133+
134+
Connections and IOs
135+
===================
136+
137+
STM32L476G Discovery Board has 8 GPIO controllers. These controllers are responsible for pin muxing,
138+
input/output, pull-up, etc.
139+
140+
For mode details please refer to `STM32L476G Discovery board User Manual`_.
141+
142+
Default Zephyr Peripheral Mapping:
143+
----------------------------------
144+
145+
- UART_2_TX : PD5
146+
- UART_2_RX : PD6
147+
- LD4 : PB2
148+
- LD5 : PE8
149+
150+
System Clock
151+
------------
152+
153+
STM32L476G Discovery System Clock could be driven by an internal or external oscillator,
154+
as well as the main PLL clock. By default the System clock is driven by the PLL clock at 80MHz,
155+
driven by 16MHz high speed internal oscillator.
156+
157+
Serial Port
158+
-----------
159+
160+
STM32L476G Discovery board has 6 U(S)ARTs. The Zephyr console output is assigned to UART2.
161+
Default settings are 115200 8N1.
162+
163+
164+
Programming and Debugging
165+
*************************
166+
167+
Flashing
168+
========
169+
170+
STM32L476G Discovery board includes an ST-LINK/V2-1 embedded debug tool interface.
171+
This interface is supported by the openocd version included in Zephyr SDK.
172+
173+
Flashing an application to STM32L476G Discovery
174+
-----------------------------------------------
175+
176+
Connect the STM32L476G Discovery to your host computer using the USB
177+
port, then run a serial host program to connect with your Discovery
178+
board. For example:
179+
180+
.. code-block:: console
181+
182+
$ minicom -D /dev/ttyACM0
183+
184+
Then, build and flash in the usual way. Here is an example for the
185+
:ref:`hello_world` application.
186+
187+
.. zephyr-app-commands::
188+
:zephyr-app: samples/hello_world
189+
:board: stm32l476g_disco
190+
:goals: build flash
191+
192+
You should see the following message on the console:
193+
194+
.. code-block:: console
195+
196+
Hello World! arm
197+
198+
Debugging
199+
=========
200+
201+
You can debug an application in the usual way. Here is an example for the
202+
:ref:`hello_world` application.
203+
204+
.. zephyr-app-commands::
205+
:zephyr-app: samples/hello_world
206+
:board: stm32l476g_disco
207+
:maybe-skip-config:
208+
:goals: debug
209+
210+
.. _STM32L476G Discovery website:
211+
http://www.st.com/en/evaluation-tools/32l476gdiscovery.html
212+
213+
.. _STM32L476G Discovery board User Manual:
214+
http://www.st.com/resource/en/user_manual/dm00172179.pdf
215+
216+
.. _STM32L476VG on www.st.com:
217+
http://www.st.com/en/microcontrollers/stm32l476vg.html
218+
219+
.. _STM32L476 reference manual:
220+
http://www.st.com/resource/en/reference_manual/DM00083560.pdf
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* This file is a temporary workaround for mapping of the generated information
2+
* to the current driver definitions. This will be removed when the drivers
3+
* are modified to handle the generated information, or the mapping of
4+
* generated data matches the driver definitions.
5+
*/
6+
7+
#define CONFIG_NUM_IRQ_PRIO_BITS ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS
8+
9+
#define CONFIG_UART_STM32_PORT_1_BASE_ADDRESS ST_STM32_USART_40013800_BASE_ADDRESS
10+
#define CONFIG_UART_STM32_PORT_1_BAUD_RATE ST_STM32_USART_40013800_CURRENT_SPEED
11+
#define CONFIG_UART_STM32_PORT_1_IRQ_PRI ST_STM32_USART_40013800_IRQ_0_PRIORITY
12+
#define CONFIG_UART_STM32_PORT_1_NAME ST_STM32_USART_40013800_LABEL
13+
#define PORT_1_IRQ ST_STM32_USART_40013800_IRQ_0
14+
15+
#define CONFIG_UART_STM32_PORT_2_BASE_ADDRESS ST_STM32_USART_40004400_BASE_ADDRESS
16+
#define CONFIG_UART_STM32_PORT_2_BAUD_RATE ST_STM32_USART_40004400_CURRENT_SPEED
17+
#define CONFIG_UART_STM32_PORT_2_IRQ_PRI ST_STM32_USART_40004400_IRQ_0_PRIORITY
18+
#define CONFIG_UART_STM32_PORT_2_NAME ST_STM32_USART_40004400_LABEL
19+
#define PORT_2_IRQ ST_STM32_USART_40004400_IRQ_0
20+
21+
#define CONFIG_UART_STM32_PORT_3_BASE_ADDRESS ST_STM32_USART_40004800_BASE_ADDRESS
22+
#define CONFIG_UART_STM32_PORT_3_BAUD_RATE ST_STM32_USART_40004800_CURRENT_SPEED
23+
#define CONFIG_UART_STM32_PORT_3_IRQ_PRI ST_STM32_USART_40004800_IRQ_0_PRIORITY
24+
#define CONFIG_UART_STM32_PORT_3_NAME ST_STM32_USART_40004800_LABEL
25+
#define PORT_3_IRQ ST_STM32_USART_40004800_IRQ_0
26+
27+
#define CONFIG_UART_STM32_PORT_4_BASE_ADDRESS ST_STM32_UART_40004C00_BASE_ADDRESS
28+
#define CONFIG_UART_STM32_PORT_4_BAUD_RATE ST_STM32_UART_40004C00_CURRENT_SPEED
29+
#define CONFIG_UART_STM32_PORT_4_IRQ_PRI ST_STM32_UART_40004C00_IRQ_0_PRIORITY
30+
#define CONFIG_UART_STM32_PORT_4_NAME ST_STM32_UART_40004C00_LABEL
31+
#define PORT_4_IRQ ST_STM32_UART_40004C00_IRQ_0
32+
33+
#define CONFIG_UART_STM32_PORT_5_BASE_ADDRESS ST_STM32_UART_40005000_BASE_ADDRESS
34+
#define CONFIG_UART_STM32_PORT_5_BAUD_RATE ST_STM32_UART_40005000_CURRENT_SPEED
35+
#define CONFIG_UART_STM32_PORT_5_IRQ_PRI ST_STM32_UART_40005000_IRQ_0_PRIORITY
36+
#define CONFIG_UART_STM32_PORT_5_NAME ST_STM32_UART_40005000_LABEL
37+
#define PORT_5_IRQ ST_STM32_UART_40005000_IRQ_0
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <kernel.h>
2+
#include <device.h>
3+
#include <init.h>
4+
#include <pinmux.h>
5+
#include <sys_io.h>
6+
7+
#include <pinmux/stm32/pinmux_stm32.h>
8+
9+
/* pin assignments for STM32L476G DISCOVERY board */
10+
static const struct pin_config pinconf[] = {
11+
#ifdef CONFIG_UART_STM32_PORT_2
12+
{STM32_PIN_PD5, STM32L4X_PINMUX_FUNC_PD5_USART2_TX},
13+
{STM32_PIN_PD6, STM32L4X_PINMUX_FUNC_PD6_USART2_RX},
14+
#endif /* CONFIG_UART_STM32_PORT_2 */
15+
};
16+
17+
static int pinmux_stm32_init(struct device *port)
18+
{
19+
ARG_UNUSED(port);
20+
21+
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
22+
23+
return 0;
24+
}
25+
26+
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
27+
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2017 Arthur Sfez
3+
*
4+
* Based on stm32l496g_disco:
5+
*
6+
* Copyright (c) 2017 Linaro Limited
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*/
10+
11+
/dts-v1/;
12+
#include <st/stm32l476.dtsi>
13+
14+
/ {
15+
model = "STMicroelectronics STM32L476G-DISCO board";
16+
compatible = "st,stm32l476g-disco", "st,stm32l476";
17+
18+
chosen {
19+
zephyr,console = &usart2;
20+
zephyr,sram = &sram0;
21+
zephyr,flash = &flash0;
22+
};
23+
};
24+
25+
&usart2 {
26+
current-speed = <115200>;
27+
pinctrl-0 = <&usart2_pins_d>;
28+
pinctrl-names = "default";
29+
status = "ok";
30+
};

0 commit comments

Comments
 (0)