board: arm: add support for the nucleo_f031k6 board

The configuration is based on
the f303k6 and the ST reference manual.

I had successfully tested the following sample code:
blinky
blink_led (uses TIM2_CH2 on PB3)
hello_world

Signed-off-by: Sebastian Schwabe <sebastian-schwabe@gmx.de>
This commit is contained in:
Sebastian Schwabe 2021-04-09 00:15:01 +02:00 committed by Maureen Helm
commit 54496f0907
10 changed files with 338 additions and 0 deletions

View file

@ -0,0 +1,8 @@
# STM32 Nucleo-32 development board with STM32F031K6 MCU configuration
# Copyright (c) 2021 Sebastian Schwabe <sebastian.schwabe@mailbox.tu-dresden.de>
# SPDX -License-Identifier: Apache-2.0
config BOARD_NUCLEO_F031K6
bool "NUCLEO-32 F031K6 Development Board"
depends on SOC_STM32F031X6

View file

@ -0,0 +1,11 @@
# STM32 Nucleo-32 development board with STM32F031K6 MCU
# Copyright (c) 2021 Sebastian Schwabe <sebastian.schwabe@mailbox.tu-dresden.de>
# SPDX-License-Identifier: Apache-2.0
if BOARD_NUCLEO_F031K6
config BOARD
default "nucleo_f031k6"
endif # BOARD_NUCLEO_F031K6

View file

@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(jlink "--device=STM32F031K6" "--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: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 KiB

View file

@ -0,0 +1,159 @@
.. _nucleo_f031k6_board:
ST Nucleo F031K6
################
Overview
********
The STM32 Nucleo-32 development board with STM32F031K6 MCU, supports Arduino nano connectivity.
The STM32 Nucleo board provides an affordable, and flexible way for users to try out new concepts,
and build prototypes with the STM32 microcontroller, choosing from the various
combinations of performance, power consumption and features.
The STM32 Nucleo board integrates the ST-LINK/V2-1 debugger and programmer.
The STM32 Nucleo board comes with the STM32 comprehensive software HAL library together
with various packaged software examples.
.. image:: img/nucleo_f031k6.jpg
:width: 250px
:height: 250px
:align: center
:alt: Nucleo F031k6
More information about the board can be found at the `Nucleo F031K6 website`_.
Hardware
********
Nucleo F031K6 provides the following hardware components:
- STM32 microcontroller in LQFP32 package
- On-board ST-LINK/V2-1 debugger/programmer with SWD connector:
- Flexible board power supply:
- USB VBUS or external source (3.3V, 5V, 7 - 12V)
- Three LEDs:
- USB communication (LD1), user LED (LD2), power LED (LD3)
- reset push button
More information about STM32F031K6 can be found here:
- `STM32F031 reference manual`_
- `STM32F031 data sheet`_
Supported Features
==================
The Zephyr nucleo_f031k6 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 |
+-----------+------------+-------------------------------------+
| CLOCK | on-chip | reset and clock control |
+-----------+------------+-------------------------------------+
| FLASH | on-chip | flash memory |
+-----------+------------+-------------------------------------+
| I2C | on-chip | i2c controller |
+-----------+------------+-------------------------------------+
| SPI | on-chip | spi controller |
+-----------+------------+-------------------------------------+
Other hardware features are not yet supported in this Zephyr port.
The default configuration can be found in the defconfig file:
``boards/arm/nucleo_f031k6/nucleo_f031k6_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.
Board connectors:
-----------------
.. image:: img/nucleo_f031k6_connectors.png
:width: 960px
:align: center
:height: 720px
:alt: Nucleo F031K6 connectors
Default Zephyr Peripheral Mapping:
----------------------------------
- UART_1 TX/RX : PA2/PA15 (ST-Link Virtual COM Port)
- I2C1 SCL/SDA : PB6/PB7 (Arduino I2C)
- SPI1 NSS/SCK/MISO/MOSI : PA4/PA5/PA6/PA7 (Arduino SPI)
- LD2 : PB3
For mode details please refer to `STM32 Nucleo-32 board User Manual`_.
Programming and Debugging
*************************
Applications for the ``nucleo_f031k6`` 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 F031K6 board includes an ST-LINK/V2-1 embedded debug tool interface.
This interface is supported by the openocd version included in the Zephyr SDK.
Flashing an application to Nucleo F030R8
----------------------------------------
Here is an example for the :ref:`blinky-sample` application.
.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: nucleo_f031k6
: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: nucleo_f031k6
:maybe-skip-config:
:goals: debug
References
**********
.. target-notes::
.. _Nucleo F031K6 website:
https://www.st.com/en/evaluation-tools/nucleo-f031k6.html
.. _STM32F031 reference manual:
https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
.. _STM32F031 data sheet:
https://www.st.com/resource/en/datasheet/stm32f031k6.pdf
.. _STM32 Nucleo-32 board User Manual:
https://www.st.com/resource/en/user_manual/dm00231744-stm32-nucleo32-boards-mb1180-stmicroelectronics.pdf

View file

@ -0,0 +1,82 @@
/*
* Copyright (c) 2021 Sebastian Schwabe <sebastian.schwabe@mailbox.tu-dresden.de>
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <st/f0/stm32f031X6.dtsi>
#include <st/f0/stm32f031k6tx-pinctrl.dtsi>
/ {
model = "STMicroelectronics STM32F031K6-NUCLEO board";
compatible = "st,stm32f031k6-nucleo";
chosen {
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};
leds {
compatible = "gpio-leds";
green_led_3: led_3 {
gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>;
label = "User LD3";
};
};
pwmleds {
compatible = "pwm-leds";
green_pwm_led: green_pwm_led {
pwms = <&pwm2 2 0 PWM_POLARITY_NORMAL>;
};
};
aliases {
led0 = &green_led_3;
pwm-led0 = &green_pwm_led;
};
};
/* Due to limited available memory, don't enable gpiod and gpiof */
/* (Test cases fail due to 'SRAM' region overflow) */
&gpiod {status = "disabled";};
&gpiof {status = "disabled";};
&timers2 {
status = "okay";
pwm2: pwm {
status = "okay";
pinctrl-0 = <&tim2_ch2_pb3>;
};
};
&usart1 {
pinctrl-0 = <&usart1_tx_pa2 &usart1_rx_pa15>;
current-speed = <115200>;
status = "okay";
};
&i2c1 {
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>;
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
};
&spi1 {
pinctrl-0 = <&spi1_nss_pa4 &spi1_sck_pa5
&spi1_miso_pa6 &spi1_mosi_pa7>;
status = "okay";
};
&adc1 {
pinctrl-0 = <&adc_in0_pa0>;
status = "okay";
};
&rtc {
status = "okay";
};

View file

@ -0,0 +1,18 @@
identifier: nucleo_f031k6
name: ST Nucleo F031K6
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 4
flash: 32
supported:
- i2c
- spi
- gpio
testing:
ignore_tags:
- net
- bluetooth

View file

@ -0,0 +1,42 @@
# SPDX-License-Identifier: Apache-2.0
# Platform Configuration
CONFIG_SOC_SERIES_STM32F0X=y
CONFIG_SOC_STM32F031X6=y
# General Kernel Options
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000
# Kernel Options due to Low Memory (4k)
CONFIG_MAIN_STACK_SIZE=512
CONFIG_IDLE_STACK_SIZE=150
CONFIG_ISR_STACK_SIZE=256
CONFIG_LOG_BUFFER_SIZE=256
# Prevent Interrupt Vector Table in RAM
CONFIG_IS_BOOTLOADER=y
CONFIG_BOOTLOADER_SRAM_SIZE=4
# Serial Drivers
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Pinmux Driver
CONFIG_PINMUX=y
# GPIO Controller
CONFIG_GPIO=y
# Clock configuration
CONFIG_CLOCK_CONTROL=y
# SYSCLK selection
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSI as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
# produce 48MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_PREDIV=4
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=12
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=1

View file

@ -0,0 +1,12 @@
source [find board/st_nucleo_f0.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
}