boards: add stm32l1 discovery

Tested apps: hello_world, blinky
Tested peripherals: UART, SPI

Signed-off-by: Karl Palsson <karlp@etactica.com>
This commit is contained in:
Karl Palsson 2019-10-01 23:12:31 +00:00 committed by Maureen Helm
commit 79b15e374d
12 changed files with 448 additions and 0 deletions

View file

@ -85,6 +85,7 @@
/boards/arm/olimexino_stm32/ @ydamigos
/boards/arm/sensortile_box/ @avisconti
/boards/arm/steval_fcu001v1/ @Navin-Sankar
/boards/arm/stm32l1_disco/ @karlp
/boards/arm/stm32*_disco/ @erwango
/boards/arm/stm32f3_disco/ @ydamigos
/boards/arm/stm32*_eval/ @erwango

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,10 @@
# Kconfig - board configuration
#
# Copyright (c) 2019 eTactica ehf
#
# SPDX-License-Identifier: Apache-2.0
#
config BOARD_STM32L1_DISCO
bool "STM32L1DISCOVERY Development Board"
depends on SOC_STM32L151XB

View file

@ -0,0 +1,41 @@
# Kconfig - board configuration
#
# Copyright (c) 2019 eTactica ehf
#
# SPDX-License-Identifier: Apache-2.0
#
if BOARD_STM32L1_DISCO
config BOARD
default "stm32l1_disco"
if UART_CONSOLE
config UART_1
default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
config I2C_2
default y
endif # I2C
if SPI
config SPI_1
default y
config SPI_2
default y
endif # SPI
endif # BOARD_STM32L1_DISCO

View file

@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(jlink "--device=STM32L151RB" "--speed=4000")
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

View file

@ -0,0 +1,181 @@
.. _stm32l1_disco_board:
ST STM32LDISCOVERY and 32L152CDISCOVERY
#######################################
Overview
********
The two generations of the STM32L1 Discovery development boards come with
an integrated ST-LINK/V2 debugger and programmer. The boards have a
24-segment LCD and a touch slider, along with two user LEDs and a user button.
Support circuitry for measuring power consumption is also available.
It also comes with a comprehensive STM32 software HAL library and various
packaged software examples.
There
are two variants of the board:
- STM32LDISCOVERY targets STM32L152RBT6, with 128K flash, 16K RAM
- 32L152CDISCOVERY targets STM32L152RCT6, with 256K flash, 32K RAM
The STM32LDISCOVERY is no longer sold, but was widely available. The current
configuration assumes only 128K flash and 16K RAM, so it builds and runs
on both variants out of the box.
.. image:: img/stm32l1_disco.jpg
:width: 564px
:height: 600px
:align: center
:alt: STM32LDISCOVERY
More information about the board can be found at the `STM32LDISCOVERY website`_.
Hardware
********
The STM32 Discovery board features:
- On-board ST-LINK/V2 with selection mode switch to use the kit as a standalone
ST-LINK/V2 (with SWD connector for programming and debugging)
- Board power supply: through USB bus or from an external 5 V supply voltage
- External application power supply: 3 V and 5 V
- Four LEDs:
- LD1 (red) for 3.3 V power on
- LD2 (red/green) for USB communication
- LD3 (green) for PC9 output
- LD4 (blue) for PC8 output
- Two push buttons (user and reset)
- Extension header for all LQFP64 I/Os for quick connection to prototyping board
and easy probing
More information about STM32L151x can be found in the `STM32L1x reference manual`_.
Supported Features
==================
The Zephyr stm32l1_disco board configuration supports the following hardware features:
.. list-table:: Supported hardware
:header-rows: 1
* - 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
* - CLOCK
- on-chip
- reset and clock control
* - FLASH
- on-chip
- flash memory
* - WATCHDOG
- on-chip
- window watchdog
* - I2C
- on-chip
- i2c
* - SPI
- on-chip
- spi
Other hardware features are not yet supported in this Zephyr port.
The default configuration can be found in the defconfig file:
``boards/arm/stm32l1_disco/stm32l1_disco_defconfig``
Connections and IOs
===================
Each of the GPIO pins can be configured by software as output (push-pull or open-drain), as
input (with or without pull-up or pull-down), or as peripheral alternate function. Most of the
GPIO pins are shared with digital or analog alternate functions. All GPIOs are high current
capable except for analog inputs.
Default Zephyr Peripheral Mapping:
----------------------------------
.. rst-class:: rst-columns
- UART_1_TX : PA9
- UART_1_RX : PA10
- UART_2_TX : PA2
- UART_2_RX : PA3
- I2C1_SCL : PB6
- I2C1_SDA : PB7
- I2C2_SCL : PB10
- I2C2_SDA : PB11
- SPI1_NSS : PA4
- SPI1_SCK : PA5
- SPI1_MISO : PA6
- SPI1_MOSI : PA7
- SPI2_NSS : PB12
- SPI2_SCK : PB13
- SPI2_MISO : PB14
- SPI2_MOSI : PB15
For mode details please refer to `STM32L1DISCOVERY board User Manual`_.
Programming and Debugging
*************************
Applications for the ``stm32l1_disco`` board configuration can be built and
flashed in the usual way (see :ref:`build_an_application` and
:ref:`application_run` for more details).
Flashing
========
STM32L1DISCOVERY board includes an ST-LINK/V2 embedded debug tool interface.
This interface is supported by the openocd version included in the Zephyr SDK.
Flashing an application
-----------------------
Here is an example for the :ref:`blinky-sample` application.
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: stm32l1_disco
:goals: build flash
You will see the LED blinking every second.
Debugging
=========
You can debug an application in the usual way. Here is an example for the
:ref:`blinky-sample` application.
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: stm32l1_disco
:maybe-skip-config:
:goals: debug
References
**********
.. target-notes::
.. _STM32LDISCOVERY website:
https://www.st.com/en/evaluation-tools/32l152cdiscovery.html
.. _STM32L1x reference manual:
https://www.st.com/resource/en/reference_manual/cd00240193.pdf
.. _STM32L1DISCOVERY board User Manual:
https://www.st.com/resource/en/user_manual/dm00027954.pdf

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2019 eTactica ehf
*
* 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>
static const struct pin_config pinconf[] = {
#ifdef CONFIG_UART_1
{STM32_PIN_PA9, STM32L1X_PINMUX_FUNC_PA9_USART1_TX},
{STM32_PIN_PA10, STM32L1X_PINMUX_FUNC_PA10_USART1_RX},
#endif /* CONFIG_UART_1 */
#ifdef CONFIG_UART_2
{STM32_PIN_PA2, STM32L1X_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32L1X_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
#ifdef CONFIG_UART_3
{STM32_PIN_PB10, STM32L1X_PINMUX_FUNC_PB10_USART3_TX},
{STM32_PIN_PB11, STM32L1X_PINMUX_FUNC_PB11_USART3_RX},
#endif /* CONFIG_UART_3 */
#ifdef CONFIG_I2C_1
{STM32_PIN_PB6, STM32L1X_PINMUX_FUNC_PB6_I2C1_SCL},
{STM32_PIN_PB7, STM32L1X_PINMUX_FUNC_PB7_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_I2C_2
{STM32_PIN_PB10, STM32L1X_PINMUX_FUNC_PB10_I2C2_SCL},
{STM32_PIN_PB11, STM32L1X_PINMUX_FUNC_PB11_I2C2_SDA},
#endif /* CONFIG_I2C_2 */
#ifdef CONFIG_SPI_1
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PA4, STM32L1X_PINMUX_FUNC_PA4_SPI1_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
{STM32_PIN_PA5, STM32L1X_PINMUX_FUNC_PA5_SPI1_SCK},
{STM32_PIN_PA6, STM32L1X_PINMUX_FUNC_PA6_SPI1_MISO},
{STM32_PIN_PA7, STM32L1X_PINMUX_FUNC_PA7_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_SPI_2
#ifdef CONFIG_SPI_STM32_USE_HW_SS
{STM32_PIN_PB12, STM32L1X_PINMUX_FUNC_PB12_SPI2_NSS},
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
{STM32_PIN_PB13, STM32L1X_PINMUX_FUNC_PB13_SPI2_SCK},
{STM32_PIN_PB14, STM32L1X_PINMUX_FUNC_PB14_SPI2_MISO},
{STM32_PIN_PB15, STM32L1X_PINMUX_FUNC_PB15_SPI2_MOSI},
#endif /* CONFIG_SPI_2 */
};
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);

View file

@ -0,0 +1,79 @@
/*
* Copyright (c) 2019 eTactica ehf
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <st/l1/stm32l151Xb.dtsi>
/ {
model = "STMicroelectronics STM32L1DISCOVERY board";
compatible = "st,stm32l1discovery", "st,stm32l151";
chosen {
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};
leds {
compatible = "gpio-leds";
green_led: ld3 {
gpios = <&gpiob 7 GPIO_INT_ACTIVE_HIGH>;
label = "User LD3";
};
blue_led: ld4 {
gpios = <&gpiob 6 GPIO_INT_ACTIVE_HIGH>;
label = "User LD4";
};
};
gpio_keys {
compatible = "gpio-keys";
user_button: button {
label = "User";
gpios = <&gpioa 0 GPIO_INT_ACTIVE_LOW>;
};
};
aliases {
led0 = &green_led;
led1 = &blue_led;
sw0 = &user_button;
};
};
&usart1 {
current-speed = <115200>;
status = "okay";
};
&usart2 {
current-speed = <115200>;
status = "okay";
};
&usart3 {
current-speed = <115200>;
status = "okay";
};
&i2c1 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
};
&i2c2 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
};
&spi1 {
status = "okay";
};
&spi2 {
status = "okay";
};

View file

@ -0,0 +1,14 @@
identifier: stm32l1_disco
name: STM32L1DISCOVERY
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 16
flash: 128
supported:
- gpio
- i2c
- spi

View file

@ -0,0 +1,33 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_ARM=y
CONFIG_BOARD_STM32L1_DISCO=y
CONFIG_SOC_SERIES_STM32L1X=y
CONFIG_SOC_STM32L151XB=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000
# enable uart driver
CONFIG_SERIAL=y
# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# enable pinmux
CONFIG_PINMUX=y
# enable GPIO
CONFIG_GPIO=y
# clock configuration
CONFIG_CLOCK_CONTROL=y
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# out of the box, MCO from stlink is not enabled, unlike later discos
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
# produce 32MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_DIVISOR=4
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=8
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
CONFIG_CLOCK_STM32_APB2_PRESCALER=1

View file

@ -0,0 +1,12 @@
source [find board/stm32ldiscovery.cfg]
$_TARGETNAME configure -event gdb-attach {
echo "Debugger attaching: halting execution"
reset halt
gdb_breakpoint_override hard
}
$_TARGETNAME configure -event gdb-detach {
echo "Debugger detaching: resuming execution"
resume
}