Skip to content
Permalink
Browse files

arm: Add support for MINI-M4 for STM32 Board

Add configuration, dts and documentation for the MINI-M4 for
STM32 board based on the STM32F415RG SoC.
See https://www.mikroe.com/mini-stm32f4 for more details.

Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
  • Loading branch information...
KwonTae-young authored and galak committed Jan 20, 2019
1 parent a7199b7 commit 689d71b2915f8e5fa21aeb6fc42da5020fb5a083
@@ -0,0 +1,7 @@
# Copyright (c) 2019, Kwon Tae-young <tykwon@m2i.co.kr>
#
# SPDX-License-Identifier: Apache-2.0
#
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
@@ -0,0 +1,10 @@
# Kconfig - Mikroe MINI-M4 for STM32 board configuration
#
# Copyright (c) 2019, Kwon Tae-young <tykwon@m2i.co.kr>
#
# SPDX-License-Identifier: Apache-2.0
#
config BOARD_MIKROE_MINI_M4_FOR_STM32
bool "Mikroe MINI-M4 for STM32 Board"
depends on SOC_STM32F415RG

@@ -0,0 +1,54 @@
# Kconfig - Mikroe MINI-M4 for STM32 board configuration
#
# Copyright (c) 2019, Kwon Tae-young <tykwon@m2i.co.kr>
#
# SPDX-License-Identifier: Apache-2.0
#

if BOARD_MIKROE_MINI_M4_FOR_STM32

config BOARD
default "mikroe_mini_m4_for_stm32"

if UART_CONSOLE

config UART_2
default y

endif # UART_CONSOLE

if I2C

config I2C_2
default y

config I2C_STM32_INTERRUPT
default y

endif # I2C

if SPI

config SPI_1
default y

config SPI_STM32_INTERRUPT
default y

endif # SPI

if PWM

config PWM_STM32_3
default y

endif # PWM

if USB

config USB_DC_STM32
default y

endif # USB

endif # BOARD_MIKROE_MINI_M4_FOR_STM32
@@ -0,0 +1,5 @@
# Copyright (c) 2019, Kwon Tae-young <tykwon@m2i.co.kr>
#
# SPDX-License-Identifier: Apache-2.0
#
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,151 @@
.. _mikroe_mini_m4_for_stm32:

Mikroe MINI-M4 for STM32
#########################

Overview
********

MINI-M4 for STM32 is a small ARM® Cortex™-M4 development board containing
an `STM32F415RG`_ microcontroller. It is pin compatible with PIC16F887 and
PIC18(L)F45K20 microcontrollers and it perfectly fits into a standard DIP40
socket. The board is equipped with a 16MHz SMD crystal oscillator, and
a 32.768KHz crystal which can be used for the internal RTCC module.
It has a reset button and three signal LEDs.
It operates on a 3.3V power supply. An on-board voltage regulator allows
the board to be powered directly from a USB cable.

.. image:: img/mikroe_mini_m4_for_stm32.jpg
:width: 720px
:align: center
:alt: MINI-M4 for STM32

Pin Mapping
===========

This port is a starting point for your own customizations and not a complete
port for a specific board. Most of the GPIOs on the STM32 SoC have been exposed
in the external header with silk screen labels that match the SoC's pin names.

For more information on Pin Mapping, please refer to `MINI-M4 for STM32 User Manual`_.

STLinkV2 connection:
====================

The board can be flashed by using STLinkV2 with the following connections.

+------------------+---------------------+
| MINI-M4(Pin no.) | ST-Link/V2(Pin no.) |
+==================+=====================+
| PA14(36) | TCK_SWCLK(9) |
+------------------+---------------------+
| PA13(35) | TMS_SWDIO(7) |
+------------------+---------------------+
| PA15(30) | TDI(5) |
+------------------+---------------------+
| PB3(29) | TDO_SWO(13) |
+------------------+---------------------+
| GND(31) | GND(8) |
+------------------+---------------------+
| MCLR(1) | NRST(15) |
+------------------+---------------------+

.. image:: img/st-linkv2.jpg
:width: 720px
:align: center
:alt: ST-Link/V2

Supported Features
==================

The MINI-M4 for STM32 board configuration supports the following hardware
features:

+-----------+------------+----------------------+
| Interface | Controller | Driver/Component |
+===========+============+======================+
| NVIC | on-chip | nested vectored |
| | | interrupt controller |
+-----------+------------+----------------------+
| PINMUX | on-chip | pinmux |
+-----------+------------+----------------------+
| UART | on-chip | serial port |
+-----------+------------+----------------------+
| GPIO | on-chip | gpio |
+-----------+------------+----------------------+
| I2C | on-chip | i2c |
+-----------+------------+----------------------+
| SPI | on-chip | spi |
+-----------+------------+----------------------+
| PWM | on-chip | PWM |
+-----------+------------+----------------------+
| USB | on-chip | USB |
+-----------+------------+----------------------+


Other hardware features are not supported by the Zephyr kernel.

The default configuration can be found in the defconfig file:

``boards/arm/mikroe_mini_m4_for_stm32/mikroe_mini_m4_for_stm32_defconfig``

Serial Port
===========

The Zephyr console output is assigned to USART2. Default settings are 115200 8N1.

Programming and Debugging
*************************

Applications for the ``mikroe_mini_m4_for_stm32`` board configuration can
be built and flashed in the usual way (see :ref:`build_an_application` and
:ref:`application_run` for more details).

Flashing
========

The initial state of the board is set to lock.
When you flash, it will fail with the message:

.. code-block:: console

Error: stm32x device protected

Unlocking with openocd makes it possible to flash.

.. code-block:: console

$ openocd -f /usr/share/openocd/scripts/interface/stlink-v2.cfg \
-f /usr/share/openocd/scripts/target/stm32f4x.cfg -c init\
-c "reset halt" -c "stm32f4x unlock 0" -c "reset run" -c shutdown

Here is an example for the :ref:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: mikroe_mini_m4_for_stm32
:goals: build flash

You should see the following message on the console:

.. code-block:: console

Hello World! mikroe_mini_m4_for_stm32

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: mikroe_mini_m4_for_stm32
:maybe-skip-config:
:goals: debug

.. _STM32F415RG:
https://www.st.com/resource/en/datasheet/stm32f415rg.pdf
.. _MINI-M4 for STM32 User Manual:
https://download.mikroe.com/documents/starter-boards/mini/stm32/f4/mini-m4-stm32-manual-v100.pdf

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2019, Kwon Tae-young <tykwon@m2i.co.kr>
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;
#include <st/f4/stm32f415Rg.dtsi>

/ {
model = "STMicroelectronics Mikroe MINI-M4 for STM32 board";
compatible = "st,stm32f415-mikroe-f415rg", "st,stm32f415";

chosen {
zephyr,console = &usart2;
zephyr,shell-uart = &usart2;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,ccm = &ccm0;
};

leds {
compatible = "gpio-leds";
orange_led_1: led_1 {
gpios = <&gpioc 12 GPIO_INT_ACTIVE_HIGH>;
label = "DATA LD1";
};
red_led_2: led_2 {
gpios = <&gpioc 13 GPIO_INT_ACTIVE_HIGH>;
label = "STAT LD2";
};
};

aliases {
led0 = &orange_led_1;
led1 = &red_led_2;
};
};

&usart2 {
current-speed = <115200>;
pinctrl-0 = <&usart2_pins_a>;
pinctrl-names = "default";
status = "ok";
};

&i2c2 {
status = "ok";
};

&spi1 {
status = "ok";
};

&timers3 {
status = "ok";

pwm {
status = "ok";
};
};

&usbotg_fs {
status = "ok";
};
@@ -0,0 +1,17 @@
identifier: mikroe_mini_m4_for_stm32
name: MIKROE_MINI_M4_FOR_STM32
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 128
flash: 1024
supported:
- uart
- gpio
- i2c
- spi
- pwm
- usb
@@ -0,0 +1,39 @@
CONFIG_ARM=y
CONFIG_BOARD_MIKROE_MINI_M4_FOR_STM32=y
CONFIG_SOC_SERIES_STM32F4X=y
CONFIG_SOC_STM32F415RG=y
# 168MHz system clock
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=168000000
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000

# Enable MPU
CONFIG_ARM_MPU=y

CONFIG_SERIAL=y

# console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# enable pinmux
CONFIG_PINMUX=y

# enable GPIO
CONFIG_GPIO=y

# clock configuration
CONFIG_CLOCK_CONTROL=y

# Clock configuration for Cube Clock control driver
CONFIG_CLOCK_STM32_HSE_CLOCK=16000000
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSE as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# produce 168MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=16
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=336
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=2
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=7
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=4
CONFIG_CLOCK_STM32_APB2_PRESCALER=2

0 comments on commit 689d71b

Please sign in to comment.
You can’t perform that action at this time.