boards: arm: add support for STM32F0DISCOVERY
Support the ST STM32F0DISCOVERY board with STM32F051R8T6 SoC Tested with: - `samples/basic/blinky` - `samples/basic/button` Includes flash config in `stm32f0_disco.rst` for use with mcuboot Signed-off-by: Nathan Tsoi <nathan@vertile.com>
This commit is contained in:
parent
28758fe986
commit
32ef59a4d1
3
boards/arm/stm32f0_disco/CMakeLists.txt
Normal file
3
boards/arm/stm32f0_disco/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
zephyr_library()
|
||||
zephyr_library_sources(pinmux.c)
|
||||
zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers)
|
10
boards/arm/stm32f0_disco/Kconfig.board
Normal file
10
boards/arm/stm32f0_disco/Kconfig.board
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Kconfig - STM32F0DISCOVERY development board with STM32F051R8 MCU configuration
|
||||
#
|
||||
# Copyright (c) 2018 Nathan Tsoi <nathan@vertile.com>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
config BOARD_STM32F0_DISCO
|
||||
bool "STM32F0DISCOVERY Development Board"
|
||||
depends on SOC_STM32F051X8
|
20
boards/arm/stm32f0_disco/Kconfig.defconfig
Normal file
20
boards/arm/stm32f0_disco/Kconfig.defconfig
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Kconfig - STM32F0 development board with STM32F051R8T6 MCU
|
||||
#
|
||||
# Copyright (c) 2018 Nathan Tsoi <nathan@vertile.com>
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
if BOARD_STM32F0_DISCO
|
||||
|
||||
config BOARD
|
||||
default stm32f0_disco
|
||||
|
||||
if UART_CONSOLE
|
||||
|
||||
config UART_STM32_PORT_1
|
||||
default y
|
||||
|
||||
endif # UART_CONSOLE
|
||||
|
||||
endif # BOARD_STM32F0_DISCO
|
1
boards/arm/stm32f0_disco/board.cmake
Normal file
1
boards/arm/stm32f0_disco/board.cmake
Normal file
|
@ -0,0 +1 @@
|
|||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
|
32
boards/arm/stm32f0_disco/board.h
Normal file
32
boards/arm/stm32f0_disco/board.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Nathan Tsoi <nathan@vertile.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef __INC_BOARD_H
|
||||
#define __INC_BOARD_H
|
||||
|
||||
#include <soc.h>
|
||||
|
||||
/* USER push button */
|
||||
#define USER_PB_GPIO_PORT "GPIOA"
|
||||
#define USER_PB_GPIO_PIN 0
|
||||
|
||||
/* LD3 green LED */
|
||||
#define GREEN_LED_GPIO_PORT "GPIOC"
|
||||
#define GREEN_LED_GPIO_PIN 9
|
||||
|
||||
/* LD4 blue LED */
|
||||
#define BLUE_LED_GPIO_PORT "GPIOC"
|
||||
#define BLUE_LED_GPIO_PIN 8
|
||||
|
||||
/* Create aliases to make the basic samples work */
|
||||
#define SW0_GPIO_NAME USER_PB_GPIO_PORT
|
||||
#define SW0_GPIO_PIN USER_PB_GPIO_PIN
|
||||
#define LED0_GPIO_PORT GREEN_LED_GPIO_PORT
|
||||
#define LED0_GPIO_PIN GREEN_LED_GPIO_PIN
|
||||
#define LED1_GPIO_PORT BLUE_LED_GPIO_PORT
|
||||
#define LED1_GPIO_PIN BLUE_LED_GPIO_PIN
|
||||
|
||||
#endif /* __INC_BOARD_H */
|
BIN
boards/arm/stm32f0_disco/doc/img/en.stm32f0discovery.jpg
Normal file
BIN
boards/arm/stm32f0_disco/doc/img/en.stm32f0discovery.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
146
boards/arm/stm32f0_disco/doc/stm32f0_disco.rst
Normal file
146
boards/arm/stm32f0_disco/doc/stm32f0_disco.rst
Normal file
|
@ -0,0 +1,146 @@
|
|||
.. _stm32f0_disco_board:
|
||||
|
||||
ST STM32F0DISCOVERY
|
||||
###################
|
||||
|
||||
Overview
|
||||
********
|
||||
|
||||
The STM32F0 Discovery development board uses an STM32F051R8T6 MCU and
|
||||
integrates the ST-LINK/V2-1 debugger and programmer. It also comes with a
|
||||
comprehensive STM32 software HAL library and various packaged software
|
||||
examples.
|
||||
|
||||
.. image:: img/en.stm32f0discovery.jpg
|
||||
:width: 350px
|
||||
:height: 404px
|
||||
:align: center
|
||||
:alt: STM32F0DISCOVERY
|
||||
|
||||
More information about the board can be found at the `STM32F0DISCOVERY website`_.
|
||||
|
||||
Hardware
|
||||
********
|
||||
|
||||
The STM32 Discovery board features:
|
||||
|
||||
- STM32F051R8T6 microcontroller featuring 64 KB Flash memory, 8 KB RAM in an
|
||||
LQFP64 package
|
||||
- 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
|
||||
- An additional board is provided which can be connected to the extension
|
||||
connector for even easier prototyping and probing.
|
||||
- Comprehensive free software including a variety of examples, part of
|
||||
STM32CubeF0 package or STSW-STM32049 for legacy Standard Libraries usage
|
||||
|
||||
More information about STM32F051R8 can be found in the `STM32F0x8 reference manual`_.
|
||||
|
||||
Supported Features
|
||||
==================
|
||||
|
||||
The Zephyr stm32f0_disco 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 |
|
||||
+-----------+------------+-------------------------------------+
|
||||
| IWDG | on-chip | independent watchdog |
|
||||
+-----------+------------+-------------------------------------+
|
||||
|
||||
Other hardware features are not yet supported in this Zephyr port.
|
||||
|
||||
The default configuration can be found in the defconfig file:
|
||||
``boards/arm/stm32f0_disco/stm32f0_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:
|
||||
----------------------------------
|
||||
|
||||
- UART_1_TX : PA9
|
||||
- UART_1_RX : PA10
|
||||
- UART_2_TX : PA2
|
||||
- UART_2_RX : PA3
|
||||
|
||||
For mode details please refer to `STM32F0DISCOVERY board User Manual`_.
|
||||
|
||||
Programming and Debugging
|
||||
*************************
|
||||
|
||||
Applications for the ``stm32f0_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
|
||||
========
|
||||
|
||||
STM32F0DISCOVERY 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: stm32f0_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: stm32f0_disco
|
||||
:maybe-skip-config:
|
||||
:goals: debug
|
||||
|
||||
References
|
||||
**********
|
||||
|
||||
.. target-notes::
|
||||
|
||||
.. _STM32F0DISCOVERY website:
|
||||
http://www.st.com/en/evaluation-tools/stm32f0discovery.html
|
||||
|
||||
.. _STM32F0x8 reference manual:
|
||||
http://www.st.com/resource/en/reference_manual/dm00031936.pdf
|
||||
|
||||
.. _STM32F0DISCOVERY board User Manual:
|
||||
http://www.st.com/resource/en/user_manual/dm00050135.pdf
|
||||
|
38
boards/arm/stm32f0_disco/pinmux.c
Normal file
38
boards/arm/stm32f0_disco/pinmux.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Nathan Tsoi <nathan@vertile.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <pinmux.h>
|
||||
#include <sys_io.h>
|
||||
#include "pinmux/pinmux.h"
|
||||
|
||||
#include "pinmux/stm32/pinmux_stm32.h"
|
||||
|
||||
/* pin assignments for STM32F0DISCOVERY board */
|
||||
static const struct pin_config pinconf[] = {
|
||||
#ifdef CONFIG_UART_STM32_PORT_1
|
||||
{STM32_PIN_PA9, STM32F0_PINMUX_FUNC_PA9_USART1_TX},
|
||||
{STM32_PIN_PA10, STM32F0_PINMUX_FUNC_PA10_USART1_RX},
|
||||
#endif /* CONFIG_UART_STM32_PORT_1 */
|
||||
#ifdef CONFIG_UART_STM32_PORT_2
|
||||
{STM32_PIN_PA2, STM32F0_PINMUX_FUNC_PA2_USART2_TX},
|
||||
{STM32_PIN_PA3, STM32F0_PINMUX_FUNC_PA3_USART2_RX},
|
||||
#endif /* CONFIG_UART_STM32_PORT_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);
|
71
boards/arm/stm32f0_disco/stm32f0_disco.dts
Normal file
71
boards/arm/stm32f0_disco/stm32f0_disco.dts
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Nathan Tsoi <nathan@vertile.com>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/stm32f051.dtsi>
|
||||
|
||||
/ {
|
||||
model = "STMicroelectronics STM32F0DISCOVERY board";
|
||||
compatible = "st,stm32f058r8-discovery", "st,stm32f051";
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart1;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
current-speed = <115200>;
|
||||
pinctrl-0 = <&usart1_pins_b>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
current-speed = <115200>;
|
||||
pinctrl-0 = <&usart2_pins_a>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&flash0 {
|
||||
partitions {
|
||||
/*
|
||||
* If chosen's zephyr,code-partion is unset, the image will be
|
||||
* linked into the entire flash device. If it points to an
|
||||
* individual partition, the code will be linked to, and
|
||||
* restricted to that partition.
|
||||
*/
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
boot_partition: partition@0 {
|
||||
label = "mcuboot";
|
||||
reg = <0x00000000 0x00002000>;
|
||||
read-only;
|
||||
};
|
||||
|
||||
/*
|
||||
* The flash starting at offset 0x2000 and ending at
|
||||
* offset 0x3999 is reserved for use by the application.
|
||||
*/
|
||||
|
||||
slot0_partition: partition@4000 {
|
||||
label = "image-0";
|
||||
reg = <0x00004000 0x00004000>;
|
||||
};
|
||||
slot1_partition: partition@40000 {
|
||||
label = "image-1";
|
||||
reg = <0x00008000 0x00004000>;
|
||||
};
|
||||
scratch_partition: partition@60000 {
|
||||
label = "image-scratch";
|
||||
reg = <0x0000C000 0x00004000>;
|
||||
};
|
||||
};
|
||||
};
|
8
boards/arm/stm32f0_disco/stm32f0_disco.yaml
Normal file
8
boards/arm/stm32f0_disco/stm32f0_disco.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
identifier: stm32f0_disco
|
||||
name: STM32F0DISCOVERY
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gccarmemb
|
||||
ram: 8
|
48
boards/arm/stm32f0_disco/stm32f0_disco_defconfig
Normal file
48
boards/arm/stm32f0_disco/stm32f0_disco_defconfig
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Zephyr Kernel Configuration
|
||||
CONFIG_ARM=y
|
||||
CONFIG_SOC_SERIES_STM32F0X=y
|
||||
|
||||
# Platform Configuration
|
||||
CONFIG_SOC_STM32F051X8=y
|
||||
CONFIG_BOARD_STM32F0_DISCO=y
|
||||
|
||||
# General Kernel Options
|
||||
CONFIG_CORTEX_M_SYSTICK=y
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=48000000
|
||||
|
||||
# Kernel Options due to Low Memory (8k)
|
||||
CONFIG_MAIN_STACK_SIZE=640
|
||||
CONFIG_IDLE_STACK_SIZE=200
|
||||
CONFIG_ISR_STACK_SIZE=512
|
||||
# Prevent Interrupt Vector Table in RAM
|
||||
CONFIG_IS_BOOTLOADER=y
|
||||
CONFIG_BOOTLOADER_SRAM_SIZE=8
|
||||
|
||||
# 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
|
||||
CONFIG_GPIO_STM32_PORTD=n
|
||||
CONFIG_GPIO_STM32_PORTF=n
|
||||
|
||||
# Clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
# SYSCLK selection
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
# HSE configuration
|
||||
CONFIG_CLOCK_STM32_HSE_CLOCK=8000000
|
||||
# PLL configuration
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
|
||||
# produce 48MHz clock at PLL output
|
||||
CONFIG_CLOCK_STM32_PLL_PREDIV=1
|
||||
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=6
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
12
boards/arm/stm32f0_disco/support/openocd.cfg
Normal file
12
boards/arm/stm32f0_disco/support/openocd.cfg
Normal file
|
@ -0,0 +1,12 @@
|
|||
source [find board/stm32f0discovery.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
|
||||
}
|
Loading…
Reference in a new issue