diff --git a/boards/arm/stm32f4_disco/Kconfig.board b/boards/arm/stm32f4_disco/Kconfig.board new file mode 100644 index 00000000000..394de360038 --- /dev/null +++ b/boards/arm/stm32f4_disco/Kconfig.board @@ -0,0 +1,10 @@ +# Kconfig - STM32F4DISCOVERY board configuration +# +# Copyright (c) 2016 Linaro Limited. +# +# SPDX-License-Identifier: Apache-2.0 +# + +config BOARD_STM32F4_DISCO + bool "STM32F4DISCOVERY Development Board" + depends on SOC_STM32F407XG diff --git a/boards/arm/stm32f4_disco/Kconfig.defconfig b/boards/arm/stm32f4_disco/Kconfig.defconfig new file mode 100644 index 00000000000..4f33d5c3fb0 --- /dev/null +++ b/boards/arm/stm32f4_disco/Kconfig.defconfig @@ -0,0 +1,13 @@ +# Kconfig - STM32F4DISCOVERY board configuration +# +# Copyright (c) 2016 Linaro Limited. +# +# SPDX-License-Identifier: Apache-2.0 +# + +if BOARD_STM32F4_DISCO + +config BOARD + default stm32f4_disco + +endif # BOARD_STM32F4_DISCO diff --git a/boards/arm/stm32f4_disco/Makefile b/boards/arm/stm32f4_disco/Makefile new file mode 100644 index 00000000000..c925263c43a --- /dev/null +++ b/boards/arm/stm32f4_disco/Makefile @@ -0,0 +1,2 @@ +# No C files (yet) +obj- += dummy.o diff --git a/boards/arm/stm32f4_disco/Makefile.board b/boards/arm/stm32f4_disco/Makefile.board new file mode 100644 index 00000000000..e47333183d6 --- /dev/null +++ b/boards/arm/stm32f4_disco/Makefile.board @@ -0,0 +1,7 @@ +FLASH_SCRIPT = openocd.sh +DEBUG_SCRIPT = openocd.sh + +OPENOCD_LOAD_CMD = "flash write_image erase ${O}/${KERNEL_BIN_NAME} ${CONFIG_FLASH_BASE_ADDRESS}" +OPENOCD_VERIFY_CMD = "verify_image ${O}/${KERNEL_BIN_NAME} ${CONFIG_FLASH_BASE_ADDRESS}" + +export FLASH_SCRIPT OPENOCD_LOAD_CMD OPENOCD_VERIFY_CMD diff --git a/boards/arm/stm32f4_disco/board.h b/boards/arm/stm32f4_disco/board.h new file mode 100644 index 00000000000..d592fe18fe3 --- /dev/null +++ b/boards/arm/stm32f4_disco/board.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 Linaro Limited. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __INC_BOARD_H +#define __INC_BOARD_H + +#include + +/* USER push button */ +#define USER_PB_GPIO_PORT "GPIOA" +#define USER_PB_GPIO_PIN 0 + +/* LD3 orange LED */ +#define LD3_GPIO_PORT "GPIOD" +#define LD3_GPIO_PIN 13 + +/* LD4 green LED */ +#define LD4_GPIO_PORT "GPIOD" +#define LD4_GPIO_PIN 12 + +/* LD5 red LED */ +#define LD5_GPIO_PORT "GPIOD" +#define LD5_GPIO_PIN 14 + +/* LD6 blue LED */ +#define LD6_GPIO_PORT "GPIOD" +#define LD6_GPIO_PIN 15 + +/* 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 LD3_GPIO_PORT +#define LED0_GPIO_PIN LD3_GPIO_PIN + +#endif /* __INC_BOARD_H */ diff --git a/boards/arm/stm32f4_disco/doc/img/en.stm32f4_discovery.jpg b/boards/arm/stm32f4_disco/doc/img/en.stm32f4_discovery.jpg new file mode 100644 index 00000000000..1a3f3c9a49c Binary files /dev/null and b/boards/arm/stm32f4_disco/doc/img/en.stm32f4_discovery.jpg differ diff --git a/boards/arm/stm32f4_disco/doc/stm32f4_disco.rst b/boards/arm/stm32f4_disco/doc/stm32f4_disco.rst new file mode 100644 index 00000000000..61228933aab --- /dev/null +++ b/boards/arm/stm32f4_disco/doc/stm32f4_disco.rst @@ -0,0 +1,206 @@ +.. _stm32f4_disco_board: + +ST STM32F4DISCOVERY +################### + +Overview +******** + +The STM32F4DISCOVERY Discovery kit features an ARM Cortex-M4 based STM32F407VG MCU +with a wide range of connectivity support and configurations Here are +some highlights of the STM32F4DISCOVERY board: + + +- STM32 microcontroller in LQFP100 package +- Extension header for all LQFP100 I/Os for quick connection to prototyping board and easy probing +- On-board ST-LINK/V2 debugger/programmer with SWD connector +- Flexible board power supply: + + - USB VBUS or external source(3.3V, 5V, 7 - 12V) + - Power management access point + +- Eight LEDs: + + - USB communication (LD1) + - 3.3 V power on (LD2) + - Four user LEDs: orange (LD3), green (LD4), red (LD5), and blue (LD6) + - 2 USB OTG LEDs for VBUS (LD7) and over-current (LD8) + +- Two push-buttons: USER and RESET +- USB OTG FS with micro-AB connector +- LIS302DL or LIS3DSH ST MEMS 3-axis accelerometer +- MP45DT02 ST-MEMS audio sensor omni-directional digital microphone +- CS43L22 audio DAC with integrated class D speaker driver + +.. image:: img/en.stm32f4_discovery.jpg + :width: 350px + :align: center + :height: 550px + :alt: STM32F4DISCOVERY + +More information about the board can be found at the `STM32F4DISCOVERY website`_. + +Hardware +******** + +STM32F4DISCOVERY Discovery kit provides the following hardware components: + +- STM32F407VGT6 in LQFP100 package +- ARM®32-bit Cortex®-M4 CPU with FPU +- 168 MHz max CPU frequency +- VDD from 1.8 V to 3.6 V +- 1 MB Flash +- 192+4 KB SRAM including 64-Kbyte of core coupled memory +- GPIO with external interrupt capability +- 3x12-bit ADC with 24 channels +- 2x12-bit D/A converters +- RTC +- Advanced-control Timer +- General Purpose Timers (17) +- Watchdog Timers (2) +- USART/UART (6) +- I2C (3) +- SPI (3) +- SDIO +- 2xCAN +- USB 2.0 OTG FS with on-chip PHY +- USB 2.0 OTG HS/FS with dedicated DMA, on-chip full-speed PHY and ULPI +- 10/100 Ethernet MAC with dedicated DMA +- 8- to 14-bit parallel camera +- CRC calculation unit +- True random number generator +- DMA Controller + +More information about STM32F407VG can be found here: + - `STM32F407VG on www.st.com`_ + - `STM32F407 reference manual`_ + +Supported Features +================== + +The Zephyr stm32f4_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 | ++-----------+------------+-------------------------------------+ +| PWM | on-chip | pwm | ++-----------+------------+-------------------------------------+ + +Other hardware features are not yet supported on Zephyr porting. + +The default configuration can be found in the defconfig file: + + ``boards/arm/stm32f4_disco/stm32f4_disco_defconfig`` + + +Pin Mapping +=========== + +STM32F4DISCOVERY Discovry kit has 8 GPIO controllers. These controllers are responsible for pin muxing, +input/output, pull-up, etc. + +For mode details please refer to `STM32F4DISCOVERY board User Manual`_. + +Default Zephyr Peripheral Mapping: +---------------------------------- +- UART_1_TX : PB6 +- UART_1_RX : PB7 +- UART_2_TX : PA2 +- UART_2_RX : PA3 +- USER_PB : PA0 +- LD3 : PD13 +- LD4 : PD12 +- LD5 : PD14 +- LD6 : PD15 + +System Clock +============ + +STM32F4DISCOVERY System Clock could be driven by internal or external oscillator, +as well as main PLL clock. By default System clock is driven by PLL clock at 168MHz, +driven by 8MHz high speed external clock. + +Serial Port +=========== + +STM32F4DISCOVERY Discovery kit has up to 6 UARTs. The Zephyr console output is assigned to UART2. +Default settings are 115200 8N1. + + +Programming and Debugging +************************* + +Flashing +======== + +STM32F4DISCOVERY Discovery kit includes an ST-LINK/V2 embedded debug tool interface. +This interface is supported by the openocd version included in Zephyr SDK. + +Flashing an application to STM32F4DISCOVERY +------------------------------------------- + +The sample application :ref:`hello_world` is being used in this tutorial: + +.. code-block:: console + + $/samples/hello_world + +To build the Zephyr kernel and application, enter: + +.. code-block:: console + + $ cd + $ source zephyr-env.sh + $ cd $ZEPHYR_BASE/samples/hello_world/ + $ make BOARD=stm32f4_disco + +Connect the STM32F4DISCOVERY Discovery kit to your host computer using the USB port. +Then, enter the following command: + +.. code-block:: console + + $ make BOARD=stm32f4_disco flash + +Run a serial host program to connect with your board: + +.. code-block:: console + + $ minicom -D /dev/ttyACM0 + +You should see the following message: + +.. code-block:: console + + Hello World! arm + + +Debugging +========= + +Access gdb with the following make command: + +.. code-block:: console + + $ make BOARD=stm32f4_disco debug + + +.. _STM32F4DISCOVERY website: + http://www.st.com/en/evaluation-tools/stm32f4discovery.html + +.. _STM32F4DISCOVERY board User Manual: + http://www.st.com/resource/en/user_manual/dm00039084.pdf + +.. _STM32F407VG on www.st.com: + http://www.st.com/en/microcontrollers/stm32f407vg.html + +.. _STM32F407 reference manual: + http://www.st.com/resource/en/reference_manual/dm00031020.pdf diff --git a/boards/arm/stm32f4_disco/stm32f4_disco_defconfig b/boards/arm/stm32f4_disco/stm32f4_disco_defconfig new file mode 100644 index 00000000000..96d498abb46 --- /dev/null +++ b/boards/arm/stm32f4_disco/stm32f4_disco_defconfig @@ -0,0 +1,41 @@ +CONFIG_ARM=y +CONFIG_BOARD_STM32F4_DISCO=y +CONFIG_SOC_SERIES_STM32F4X=y +CONFIG_SOC_STM32F407XG=y +# 168MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=168000000 +CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 + +# Enable MPU +CONFIG_STM32_ARM_MPU_ENABLE=y + +# enable USART2 - passthrough to STLINK v2 connector +CONFIG_UART_STM32_PORT_2=y +# enable console on this port by default +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_2" + +# enable pinmux +CONFIG_PINMUX=y + +# enable GPIO ports A, B, C +CONFIG_GPIO=y + +# clock configuration +CONFIG_CLOCK_CONTROL=y + +# Clock configuration for Cube Clock control driver +CONFIG_CLOCK_STM32_HSE_CLOCK=8000000 +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=4 +CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=72 +CONFIG_CLOCK_STM32_PLL_P_DIVISOR=2 +CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=3 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 + +#enable DTS +CONFIG_HAS_DTS=y diff --git a/boards/arm/stm32f4_disco/support/openocd.cfg b/boards/arm/stm32f4_disco/support/openocd.cfg new file mode 100644 index 00000000000..837f0cd2958 --- /dev/null +++ b/boards/arm/stm32f4_disco/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/stm32f4discovery.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 +} diff --git a/drivers/pinmux/Makefile b/drivers/pinmux/Makefile index 0e5adf9eff5..ad787b17d38 100644 --- a/drivers/pinmux/Makefile +++ b/drivers/pinmux/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_BOARD_STM3210C_EVAL) += stm32/pinmux_board_stm3210c_eval.o obj-$(CONFIG_BOARD_NUCLEO_F334R8) += stm32/pinmux_board_nucleo_f334r8.o obj-$(CONFIG_BOARD_STM32373C_EVAL) += stm32/pinmux_board_stm32373c_eval.o obj-$(CONFIG_BOARD_NUCLEO_F401RE) += stm32/pinmux_board_nucleo_f401re.o +obj-$(CONFIG_BOARD_STM32F4_DISCO) += stm32/pinmux_board_stm32f4_disco.o obj-$(CONFIG_BOARD_NUCLEO_F411RE) += stm32/pinmux_board_nucleo_f411re.o obj-$(CONFIG_BOARD_NUCLEO_F413ZH) += stm32/pinmux_board_nucleo_f413zh.o obj-$(CONFIG_BOARD_96B_CARBON) += stm32/pinmux_board_carbon.o diff --git a/drivers/pinmux/stm32/pinmux_board_stm32f4_disco.c b/drivers/pinmux/stm32/pinmux_board_stm32f4_disco.c new file mode 100644 index 00000000000..2fe057d99a4 --- /dev/null +++ b/drivers/pinmux/stm32/pinmux_board_stm32f4_disco.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016 Linaro Limited. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include "pinmux/pinmux.h" + +#include "pinmux_stm32.h" + +/* pin assignments for STM32F4DISCOVERY board */ +static const struct pin_config pinconf[] = { +#ifdef CONFIG_UART_STM32_PORT_1 + {STM32_PIN_PB6, STM32F4_PINMUX_FUNC_PB6_USART1_TX}, + {STM32_PIN_PB7, STM32F4_PINMUX_FUNC_PB7_USART1_RX}, +#endif /* CONFIG_UART_STM32_PORT_1 */ +#ifdef CONFIG_UART_STM32_PORT_2 + {STM32_PIN_PA2, STM32F4_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F4_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); diff --git a/dts/arm/Makefile b/dts/arm/Makefile index 488a9bc09e2..ffa2ef6992c 100644 --- a/dts/arm/Makefile +++ b/dts/arm/Makefile @@ -23,6 +23,7 @@ dtb-$(CONFIG_BOARD_STM32_MINI_A15) = stm32_mini_a15.dts_compiled dtb-$(CONFIG_BOARD_STM32L496G_DISCO) = stm32l496g_disco.dts_compiled dtb-$(CONFIG_BOARD_NUCLEO_F334R8) = nucleo_f334r8.dts_compiled dtb-$(CONFIG_BOARD_STM32373C_EVAL) = stm32373c_eval.dts_compiled +dtb-$(CONFIG_BOARD_STM32F4_DISCO) = stm32f4_disco.dts_compiled dtb-$(CONFIG_BOARD_96B_NITROGEN) = 96b_nitrogen.dts_compiled dtb-$(CONFIG_BOARD_NRF52_PCA10040) = nrf52_pca10040.dts_compiled dtb-$(CONFIG_BOARD_NRF52_BLENANO2) = nrf52_blenano2.dts_compiled diff --git a/dts/arm/stm32f4_disco.dts b/dts/arm/stm32f4_disco.dts new file mode 100644 index 00000000000..24a03f2f7bb --- /dev/null +++ b/dts/arm/stm32f4_disco.dts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "STMicroelectronics STM32F4DISCOVERY board"; + compatible = "st,stm32f4discovery", "st,stm32f407"; + + chosen { + zephyr,console = &usart2; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; +}; + +&usart1 { + current-speed = <115200>; + status = "ok"; +}; + +&usart2 { + current-speed = <115200>; + status = "ok"; +}; diff --git a/dts/arm/stm32f4_disco.fixup b/dts/arm/stm32f4_disco.fixup new file mode 100644 index 00000000000..f2ea618b4b3 --- /dev/null +++ b/dts/arm/stm32f4_disco.fixup @@ -0,0 +1,18 @@ +/* This file is a temporary workaround for mapping of the generated information + * to the current driver definitions. This will be removed when the drivers + * are modified to handle the generated information, or the mapping of + * generated data matches the driver definitions. + */ + + +#define CONFIG_NUM_IRQ_PRIO_BITS ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS + +#define CONFIG_UART_STM32_PORT_1_BASE_ADDRESS ST_STM32_USART_40011000_BASE_ADDRESS +#define CONFIG_UART_STM32_PORT_1_BAUD_RATE ST_STM32_USART_40011000_CURRENT_SPEED +#define CONFIG_UART_STM32_PORT_1_IRQ_PRI ST_STM32_USART_40011000_IRQ_0_PRIORITY +#define PORT_1_IRQ ST_STM32_USART_40011000_IRQ_0 + +#define CONFIG_UART_STM32_PORT_2_BASE_ADDRESS ST_STM32_USART_40004400_BASE_ADDRESS +#define CONFIG_UART_STM32_PORT_2_BAUD_RATE ST_STM32_USART_40004400_CURRENT_SPEED +#define CONFIG_UART_STM32_PORT_2_IRQ_PRI ST_STM32_USART_40004400_IRQ_0_PRIORITY +#define PORT_2_IRQ ST_STM32_USART_40004400_IRQ_0 diff --git a/scripts/sanity_chk/arches/arm.ini b/scripts/sanity_chk/arches/arm.ini index 866e33f67a1..ab04d878eb0 100644 --- a/scripts/sanity_chk/arches/arm.ini +++ b/scripts/sanity_chk/arches/arm.ini @@ -8,7 +8,7 @@ platforms = qemu_cortex_m3 frdm_k64f arduino_due nucleo_f103rb stm32_mini_a15 stm3210c_eval nucleo_f334r8 stm32373c_eval mps2_an385 frdm_kw41z sam_e70_xplained curie_ble nrf52_blenano2 hexiwear_kw40z cc3220sf_launchxl frdm_kl25z disco_l475_iot1 nucleo_l432kc - nucleo_f413zh stm32l496g_disco + nucleo_f413zh stm32l496g_disco stm32f4discovery supported_toolchains = zephyr gccarmemb