diff --git a/boards/arm/stm32f3_disco/Kconfig.board b/boards/arm/stm32f3_disco/Kconfig.board new file mode 100644 index 00000000000..937beba4e7c --- /dev/null +++ b/boards/arm/stm32f3_disco/Kconfig.board @@ -0,0 +1,10 @@ +# Kconfig - STM32F3DISCOVERY board configuration +# +# Copyright (c) 2017 I-SENSE group of ICCS +# +# SPDX-License-Identifier: Apache-2.0 +# + +config BOARD_STM32F3_DISCO + bool "STM32F3DISCOVERY Development Board" + depends on SOC_STM32F303XC diff --git a/boards/arm/stm32f3_disco/Kconfig.defconfig b/boards/arm/stm32f3_disco/Kconfig.defconfig new file mode 100644 index 00000000000..b9ea90bae87 --- /dev/null +++ b/boards/arm/stm32f3_disco/Kconfig.defconfig @@ -0,0 +1,13 @@ +# Kconfig - STM32F3DISCOVERY board configuration +# +# Copyright (c) 2017 I-SENSE group of ICCS +# +# SPDX-License-Identifier: Apache-2.0 +# + +if BOARD_STM32F3_DISCO + +config BOARD + default stm32f3_disco + +endif # BOARD_STM32F3_DISCO diff --git a/boards/arm/stm32f3_disco/Makefile b/boards/arm/stm32f3_disco/Makefile new file mode 100644 index 00000000000..c925263c43a --- /dev/null +++ b/boards/arm/stm32f3_disco/Makefile @@ -0,0 +1,2 @@ +# No C files (yet) +obj- += dummy.o diff --git a/boards/arm/stm32f3_disco/Makefile.board b/boards/arm/stm32f3_disco/Makefile.board new file mode 100644 index 00000000000..e47333183d6 --- /dev/null +++ b/boards/arm/stm32f3_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/stm32f3_disco/board.h b/boards/arm/stm32f3_disco/board.h new file mode 100644 index 00000000000..f94aec98f48 --- /dev/null +++ b/boards/arm/stm32f3_disco/board.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 I-SENSE group of ICCS + * + * 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 red LED */ +#define LD3_GPIO_PORT "GPIOE" +#define LD3_GPIO_PIN 9 + +/* LD4 blue LED */ +#define LD4_GPIO_PORT "GPIOE" +#define LD4_GPIO_PIN 8 + +/* LD5 orange LED */ +#define LD5_GPIO_PORT "GPIOE" +#define LD5_GPIO_PIN 10 + +/* LD6 green LED */ +#define LD6_GPIO_PORT "GPIOE" +#define LD6_GPIO_PIN 15 + +/* LD7 green LED */ +#define LD7_GPIO_PORT "GPIOE" +#define LD7_GPIO_PIN 11 + +/* LD8 orange LED */ +#define LD8_GPIO_PORT "GPIOE" +#define LD8_GPIO_PIN 14 + +/* LD9 blue LED */ +#define LD9_GPIO_PORT "GPIOE" +#define LD9_GPIO_PIN 12 + +/* LD10 red LED */ +#define LD10_GPIO_PORT "GPIOE" +#define LD10_GPIO_PIN 13 + +/* 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/stm32f3_disco/doc/img/en.stm32f3discovery.jpg b/boards/arm/stm32f3_disco/doc/img/en.stm32f3discovery.jpg new file mode 100644 index 00000000000..d381f61a03b Binary files /dev/null and b/boards/arm/stm32f3_disco/doc/img/en.stm32f3discovery.jpg differ diff --git a/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst b/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst new file mode 100644 index 00000000000..3fd4e84d783 --- /dev/null +++ b/boards/arm/stm32f3_disco/doc/stm32f3_disco.rst @@ -0,0 +1,210 @@ +.. _stm32f3_disco_board: + +ST STM32F3DISCOVERY +################### + +Overview +******** + +The STM32F3DISCOVERY Discovery kit features an ARM Cortex-M4 based STM32F303VC +MCU with everything required for beginners and experienced users to get +started quickly. Here are some highlights of the STM32F3DISCOVERY 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 for PCB version A or B or ST-LINK/V2-B for PCB version + C and newer, debugger/programmer with SWD connector +- Board power supply: through USB bus or from an external 3 V or 5 V supply + voltage +- External application power supply: 3 V and 5 V + +- Ten LEDs: + + - 3.3 V power on (LD1) + - USB communication (LD2) + - Eight user LEDs: red (LD3/LD10), blue (LD4/LD9), orange (LD5/LD9) + and green (LD6/LD7) + +- Two push-buttons: USER and RESET +- USB USER with Mini-B connector +- L3GD20, ST MEMS motion sensor, 3-axis digital output gyroscope +- LSM303DLHC, ST MEMS system-in-package featuring a 3D digital linear + acceleration sensor and a 3D digital magnetic sensor + +.. image:: img/en.stm32f3discovery.jpg + :width: 350px + :align: center + :height: 531px + :alt: STM32F3DISCOVERY + +More information about the board can be found at the +`STM32F3DISCOVERY website`_. + +Hardware +******** + +STM32F3DISCOVERY Discovery kit provides the following hardware components: + +- STM32F303VCT6 in LQFP100 package +- ARM |reg| 32-bit Cortex |reg| -M4 CPU with FPU +- 72 MHz max CPU frequency +- VDD from 2.0 V to 3.6 V +- 256 KB Flash +- 40 KB SRAM +- Routine booster: 8 Kbytes of SRAM on instruction and data bus +- GPIO with external interrupt capability +- 4x12-bit ADC with 39 channels +- 2x12-bit D/A converters +- RTC +- General Purpose Timers (13) +- USART/UART (5) +- I2C (2) +- SPI (3) +- CAN +- USB 2.0 full speed interface +- Infrared transmitter +- DMA Controller + +More information about STM32F303VC can be found here: + - `STM32F303VC on www.st.com`_ + - `STM32F303xC reference manual`_ + +Supported Features +================== + +The Zephyr stm32f3_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 | ++-----------+------------+-------------------------------------+ + +Other hardware features are not yet supported on Zephyr porting. + +The default configuration can be found in the defconfig file: + + ``boards/arm/stm32f3_disco/stm32f3_disco_defconfig`` + + +Pin Mapping +=========== + +STM32F3DISCOVERY Discovery kit has 6 GPIO controllers. These controllers are +responsible for pin muxing, input/output, pull-up, etc. + +For mode details please refer to `STM32F3DISCOVERY board User Manual`_. + +Default Zephyr Peripheral Mapping: +---------------------------------- +- UART_1_TX : PA9 +- UART_1_RX : PA10 +- UART_2_TX : PA2 +- UART_2_RX : PA3 +- USER_PB : PA0 +- LD3 : PE9 +- LD4 : PE8 +- LD5 : PE10 +- LD6 : PE15 +- LD7 : PE11 +- LD8 : PE14 +- LD9 : PE12 +- LD10 : PE13 + +System Clock +============ + +STM32F3DISCOVERY 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 72 MHz, driven by 8 MHz MCO from the ST Link. + +Serial Port +=========== + +STM32F3DISCOVERY Discovery kit has up to 5 UARTs. The Zephyr console output +is assigned to UART1. Default settings are 115200 8N1. + + +Programming and Debugging +************************* + +Flashing +======== + +STM32F3DISCOVERY Discovery kit includes a ST-LINK/V2 or ST-LINK/V2-B embedded +debug tool interface. This interface is supported by the openocd version +included in Zephyr SDK. + +Flashing an application to STM32F3DISCOVERY +------------------------------------------- + +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=stm32f3_disco + +Connect the STM32F3DISCOVERY Discovery kit to your host computer using the USB +ST-LINK port. Then, enter the following command: + +.. code-block:: console + + $ make BOARD=stm32f3_disco flash + +Run a serial host program to connect with your board. For PCB version A or B a +TTL(3.3V) serial adapter is required. For PCB version C and newer a Virtual Com +Port (VCP) is available on the USB ST-LINK port. + +.. code-block:: console + + $ minicom -D /dev/ + +Replace with the port where the STM32F3DISCOVERY board can be +found. For example, under Linux, /dev/ttyUSB0. + +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=stm32f3_disco debug + + +.. _STM32F3DISCOVERY website: + http://www.st.com/en/evaluation-tools/stm32f3discovery.html + +.. _STM32F3DISCOVERY board User Manual: + http://www.st.com/resource/en/user_manual/dm00063382.pdf + +.. _STM32F303VC on www.st.com: + http://www.st.com/en/microcontrollers/stm32f303vc.html + +.. _STM32F303xC reference manual: + http://www.st.com/resource/en/reference_manual/dm00043574.pdf diff --git a/boards/arm/stm32f3_disco/stm32f3_disco.yaml b/boards/arm/stm32f3_disco/stm32f3_disco.yaml new file mode 100644 index 00000000000..b756ff9e06c --- /dev/null +++ b/boards/arm/stm32f3_disco/stm32f3_disco.yaml @@ -0,0 +1,7 @@ +identifier: stm32f3_disco +name: STM32F3DISCOVERY +type: mcu +arch: arm +toolchain: + - zephyr + - gccarmemb diff --git a/boards/arm/stm32f3_disco/stm32f3_disco_defconfig b/boards/arm/stm32f3_disco/stm32f3_disco_defconfig new file mode 100644 index 00000000000..da273d9bdea --- /dev/null +++ b/boards/arm/stm32f3_disco/stm32f3_disco_defconfig @@ -0,0 +1,52 @@ +CONFIG_ARM=y +CONFIG_BOARD_STM32F3_DISCO=y +CONFIG_SOC_SERIES_STM32F3X=y +CONFIG_SOC_STM32F303XC=y +# 72MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 +CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 + +# ARM Options +CONFIG_CPU_HAS_FPU=y + +# Floating Point Options +CONFIG_FLOAT=y + +# enable uart driver +CONFIG_SERIAL=y +CONFIG_UART_STM32=y +# enable USART1 - passthrough to STLINK v2-1 connector +CONFIG_UART_STM32_PORT_1=y +# enable console on this port by default +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1" + +# enable pinmux +CONFIG_PINMUX=y +CONFIG_PINMUX_STM32=y + +# enable GPIO ports A, B, E +CONFIG_GPIO=y +CONFIG_GPIO_STM32=y +CONFIG_GPIO_STM32_PORTA=y +CONFIG_GPIO_STM32_PORTB=y +CONFIG_GPIO_STM32_PORTE=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 +# however, the board does not have an external oscillator, so just use +# the 8MHz clock signal coming from integrated STLink +CONFIG_CLOCK_STM32_HSE_BYPASS=y +# produce 72MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_PREDIV=1 +CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/boards/arm/stm32f3_disco/support/openocd.cfg b/boards/arm/stm32f3_disco/support/openocd.cfg new file mode 100644 index 00000000000..c39a3506910 --- /dev/null +++ b/boards/arm/stm32f3_disco/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/stm32f3discovery.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 de7123025e1..614467f2de6 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_STM32F3_DISCO) += stm32/pinmux_board_stm32f3_disco.o obj-$(CONFIG_BOARD_STM32F4_DISCO) += stm32/pinmux_board_stm32f4_disco.o obj-$(CONFIG_BOARD_STM32F469I_DISCO) += stm32/pinmux_board_stm32f469i_disco.o obj-$(CONFIG_BOARD_NUCLEO_F411RE) += stm32/pinmux_board_nucleo_f411re.o diff --git a/drivers/pinmux/stm32/pinmux_board_stm32f3_disco.c b/drivers/pinmux/stm32/pinmux_board_stm32f3_disco.c new file mode 100644 index 00000000000..6ecec38e3e2 --- /dev/null +++ b/drivers/pinmux/stm32/pinmux_board_stm32f3_disco.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017 I-SENSE group of ICCS + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include +#include "pinmux/pinmux.h" + +#include "pinmux_stm32.h" + +/* pin assignments for STM32F3DISCOVERY board */ +static const struct pin_config pinconf[] = { +#ifdef CONFIG_UART_STM32_PORT_1 + {STM32_PIN_PA9, STM32F3_PINMUX_FUNC_PA9_USART1_TX}, + {STM32_PIN_PA10, STM32F3_PINMUX_FUNC_PA10_USART1_RX}, +#endif /* CONFIG_UART_STM32_PORT_1 */ +#ifdef CONFIG_UART_STM32_PORT_2 + {STM32_PIN_PA2, STM32F3_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F3_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 d9d83502a32..655b43b9827 100644 --- a/dts/arm/Makefile +++ b/dts/arm/Makefile @@ -43,6 +43,6 @@ dtb-$(CONFIG_BOARD_SAM4S_XPLAINED) = sam4s_xplained.dts_compiled dtb-$(CONFIG_BOARD_OLIMEX_STM32_E407) = olimex_stm32_e407.dts_compiled dtb-$(CONFIG_BOARD_CC2650_SENSORTAG) = cc2650_sensortag.dts_compiled dtb-$(CONFIG_BOARD_STM32_MIN_DEV) = stm32_min_dev.dts_compiled - +dtb-$(CONFIG_BOARD_STM32F3_DISCO) = stm32f3_disco.dts_compiled always := $(dtb-y) endif diff --git a/dts/arm/st/stm32f303.dtsi b/dts/arm/st/stm32f303.dtsi new file mode 100644 index 00000000000..86ce849f726 --- /dev/null +++ b/dts/arm/st/stm32f303.dtsi @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 I-SENSE group of ICCS + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/ { + flash0: flash { + reg = <0x08000000 DT_FLASH_SIZE>; + }; + + sram0: memory { + reg = <0x20000000 DT_SRAM_SIZE>; + }; + + soc { + usart1: serial@40013800 { + compatible = "st,stm32-usart", "st,stm32-uart"; + reg = <0x40013800 0x400>; + interrupts = <37 0>; + status = "disabled"; + label = "UART_1"; + }; + + usart2: serial@40004400 { + compatible = "st,stm32-usart", "st,stm32-uart"; + reg = <0x40004400 0x400>; + interrupts = <38 0>; + status = "disabled"; + label = "UART_2"; + }; + + usart3: serial@40004800 { + compatible = "st,stm32-usart", "st,stm32-uart"; + reg = <0x40004800 0x400>; + interrupts = <39 0>; + status = "disabled"; + label = "UART_3"; + }; + }; +}; + +&nvic { + arm,num-irq-priority-bits = <4>; +}; diff --git a/dts/arm/stm32f3_disco.dts b/dts/arm/stm32f3_disco.dts new file mode 100644 index 00000000000..cd8a1ec2713 --- /dev/null +++ b/dts/arm/stm32f3_disco.dts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 I-SENSE group of ICCS + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "STMicroelectronics STM32F3DISCOVERY board"; + compatible = "st,stm32f3discovery", "st,stm32f303"; + + chosen { + zephyr,console = &usart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; +}; + +&usart1 { + current-speed = <115200>; + status = "ok"; +}; + +&usart2 { + current-speed = <115200>; + status = "ok"; +}; diff --git a/dts/arm/stm32f3_disco.fixup b/dts/arm/stm32f3_disco.fixup new file mode 100644 index 00000000000..cba346350e2 --- /dev/null +++ b/dts/arm/stm32f3_disco.fixup @@ -0,0 +1,20 @@ +/* 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_40013800_BASE_ADDRESS +#define CONFIG_UART_STM32_PORT_1_BAUD_RATE ST_STM32_USART_40013800_CURRENT_SPEED +#define CONFIG_UART_STM32_PORT_1_IRQ_PRI ST_STM32_USART_40013800_IRQ_0_PRIORITY +#define CONFIG_UART_STM32_PORT_1_NAME ST_STM32_USART_40013800_LABEL +#define PORT_1_IRQ ST_STM32_USART_40013800_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 CONFIG_UART_STM32_PORT_2_NAME ST_STM32_USART_40004400_LABEL +#define PORT_2_IRQ ST_STM32_USART_40004400_IRQ_0