diff --git a/CODEOWNERS b/CODEOWNERS index 3b6ed4a4ab4..b289f7591fc 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -84,6 +84,7 @@ /boards/arm/v2m_beetle/ @fvincenzo /boards/arm/olimexino_stm32/ @ydamigos /boards/arm/sensortile_box/ @avisconti +/boards/arm/steval_fcu001v1/ @Navin-Sankar /boards/arm/stm32*_disco/ @erwango /boards/arm/stm32f3_disco/ @ydamigos /boards/arm/stm32*_eval/ @erwango diff --git a/boards/arm/steval_fcu001v1/CMakeLists.txt b/boards/arm/steval_fcu001v1/CMakeLists.txt new file mode 100644 index 00000000000..d1b8108cfed --- /dev/null +++ b/boards/arm/steval_fcu001v1/CMakeLists.txt @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_PINMUX) +zephyr_library() +zephyr_library_sources(pinmux.c) +zephyr_library_include_directories(${ZEPHYR_BASE}/drivers) +endif() diff --git a/boards/arm/steval_fcu001v1/Kconfig.board b/boards/arm/steval_fcu001v1/Kconfig.board new file mode 100644 index 00000000000..9ed03f0f55a --- /dev/null +++ b/boards/arm/steval_fcu001v1/Kconfig.board @@ -0,0 +1,11 @@ +# Kconfig - STM32 Flight Controller Unit board configuration +# +# Copyright (c) 2019 Linumiz +# +# SPDX-License-Identifier: Apache-2.0 +# + +config BOARD_STEVAL_FCU001V1 + bool "STM32 Flight Controller Unit" + depends on SOC_STM32F401XC + diff --git a/boards/arm/steval_fcu001v1/Kconfig.defconfig b/boards/arm/steval_fcu001v1/Kconfig.defconfig new file mode 100644 index 00000000000..ce1a9bc05c6 --- /dev/null +++ b/boards/arm/steval_fcu001v1/Kconfig.defconfig @@ -0,0 +1,37 @@ +# Kconfig - STM32 Flight Controller Unit board configuration +# +# Copyright (c) 2019 Linumiz +# +# SPDX-License-Identifier: Apache-2.0 +# + + +if BOARD_STEVAL_FCU001V1 + +config BOARD + default "steval_fcu001v1" + +if UART_CONSOLE + +config UART_1 + default y + +endif # UART_CONSOLE + +if I2C + +config I2C_2 + default y + +endif # I2C + + +if PWM + +config PWM_STM32_2 + default y + +endif #PWM + + +endif # BOARD_STEVAL_FCU001V1 diff --git a/boards/arm/steval_fcu001v1/board.cmake b/boards/arm/steval_fcu001v1/board.cmake new file mode 100644 index 00000000000..79f93bd9e6d --- /dev/null +++ b/boards/arm/steval_fcu001v1/board.cmake @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32F401CC" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) + + diff --git a/boards/arm/steval_fcu001v1/doc/img/steval_fcu001v1.jpg b/boards/arm/steval_fcu001v1/doc/img/steval_fcu001v1.jpg new file mode 100644 index 00000000000..5dd7281706b Binary files /dev/null and b/boards/arm/steval_fcu001v1/doc/img/steval_fcu001v1.jpg differ diff --git a/boards/arm/steval_fcu001v1/doc/index.rst b/boards/arm/steval_fcu001v1/doc/index.rst new file mode 100644 index 00000000000..d93c10c9ec0 --- /dev/null +++ b/boards/arm/steval_fcu001v1/doc/index.rst @@ -0,0 +1,161 @@ +.. _steval_fcu001v1: + +STM32 Flight Controller Unit +############################ + +Overview +******** + +The STEVAL-FCU001V1 is a Cortex M4 MCU-based flight controller unit for toy quad-copter drones. + +.. figure:: img/steval_fcu001v1.jpg + :width: 753px + :align: center + :height: 699px + :alt: STM32 Flight Controller Unit + +Hardware +******** + +STM32 Flight Controller Unit provides the following hardware components: + +- STM32F401CC in UFQFPN48 package +- ARM |reg| 32-bit Cortex |reg|-M4 MCU with FPU +- 84MHz max MCU frequency +- VDD from 1.7 V to 3.6 V +- 256 KB FLASH +- 64 KB SRAM +- General Purpose Timers +- Watchdog Timers (2) +- On board sensors: + + - 3D Accelerometer and 3D Gyroscope: LSM6DSL + - 3D Magnetometer: LIS2MDL + - MEMS Pressure sensor: LPS22HD + +- 2 User LEDS +- USART/UART (1) +- I2C (1) +- Bluetooth LE over SPI + +More information about the STM32 Flight Controller Unit +can be found in these documents: + +- `STEVAL_FCU001V1 website`_ +- `STM32F401 reference manual`_ +- `STM32F401CC on www.st.com`_ + +Supported Features +================== + +The Zephyr steval_fcu001v1 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 | ++-----------+------------+------------------------------------+ +| I2C | on-chip | i2c | ++-----------+------------+------------------------------------+ + + +The default configuration can be found in the defconfig file: +``boards/arm/steval_fcu001v1/steval_fcu001v1_defconfig`` + +Default Zephyr Peripheral Mapping: +---------------------------------- + +- UART_1 TX/RX : PA9/PA10 +- I2C2 SCL/SDA : PB10/PB3 +- PWM_2_CH1 : PA0 +- LD1 : PB5 +- LD2 : PB4 + +System Clock +============ + +The steval_fcu001v1 system clock can be driven by an internal or external oscillator, +as well as by the main PLL clock. By default, the system clock is driven by the PLL clock at 84MHz, +driven by a 16MHz high-speed external clock. + +Serial Port +=========== + +The steval_fcu001v1 board has one UART. The Zephyr console output is assigned to UART1. +Default settings are 115200 8N1. + +I2C +=== + +The steval_fcu001v1 board has one I2C. The default I2C mapping for Zephyr is: + +- I2C2_SCL : PB10 +- I2C2_SDA : PB3 + +Programming and Debugging +************************* + +Applications for the ``steval_fcu001v1`` board configuration can be built and +flashed in the usual way (see :ref:`build_an_application` and +:ref:`application_run` for more details). + +Flashing +======== + +Flashing Zephyr onto the steval_fcu001v1 board requires an external ST-LINK/V2-1 programmer. +The programmer is attached to the P8 programming header with ARM-JTAG-20-10-Plug-in Adapter. + +Flashing an application to STEVAL_FCU001V1 +------------------------------------------ + +Connect the FT232-to-USB port to host system, and RX, TX, Gnd pins to +the P7 header of the steval_fcu001v1 board. Then run a serial host +program to connect with your steval_fcu001v1 via the FT232 board: + +.. code-block:: console + + $ minicom -D /dev/ttyUSB0 + +Now build and flash an application. Here is an example for :ref:`hello_world` + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: steval_fcu001v1 + :goals: build flash + +You should see the following message on the console: + +.. code-block:: console + + Hello World! steval_fcu001v1 + +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: steval_fcu001v1 + :maybe-skip-config: + :goals: debug + +.. _STEVAL_FCU001V1 website: + https://www.st.com/en/evaluation-tools/steval-fcu001v1.html + +.. _STM32F401CC on www.st.com: + https://www.st.com/en/microcontrollers-microprocessors/stm32f401cc.html + +.. _STM32F401 reference manual: + http://www.st.com/resource/en/reference_manual/dm00096844.pdf + diff --git a/boards/arm/steval_fcu001v1/pinmux.c b/boards/arm/steval_fcu001v1/pinmux.c new file mode 100644 index 00000000000..ea7de4e2f22 --- /dev/null +++ b/boards/arm/steval_fcu001v1/pinmux.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019 Linumiz + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#include + +/* pin assignments for STEVAL-FCU001V1 */ +static const struct pin_config pinconf[] = { +#ifdef CONFIG_UART_1 + {STM32_PIN_PA9, STM32F4_PINMUX_FUNC_PA9_USART1_TX}, + {STM32_PIN_PA10, STM32F4_PINMUX_FUNC_PA10_USART1_RX}, +#endif /* CONFIG_UART_1 */ +#ifdef CONFIG_PWM_STM32_2 + {STM32_PIN_PA0, STM32F4_PINMUX_FUNC_PA0_PWM2_CH1}, +#endif /* CONFIG_PWM_STM32_2 */ +#ifdef CONFIG_I2C_2 + {STM32_PIN_PB3, STM32F4_PINMUX_FUNC_PB3_I2C2_SDA}, + {STM32_PIN_PB10, STM32F4_PINMUX_FUNC_PB10_I2C2_SCL}, +#endif /* CONFIG_I2C_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/boards/arm/steval_fcu001v1/steval_fcu001v1.dts b/boards/arm/steval_fcu001v1/steval_fcu001v1.dts new file mode 100644 index 00000000000..9987a18e783 --- /dev/null +++ b/boards/arm/steval_fcu001v1/steval_fcu001v1.dts @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2019 Linumiz + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "STMicroelectronics Flight Controller Board"; + compatible = "st,flight-controller-board", "st,stm32f401"; + + chosen { + zephyr,console = &usart1; + zephyr,shell-uart = &usart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + red_led_1: led_1 { + gpios = <&gpiob 5 GPIO_INT_ACTIVE_HIGH>; + label = "User LD1"; + }; + + red_led_2: led_2 { + gpios = <&gpiob 4 GPIO_INT_ACTIVE_HIGH>; + label = "User LD2"; + }; + }; + + aliases { + led0 = &red_led_1; + led1 = &red_led_2; + }; +}; + + +&i2c2 { + status = "okay"; + clock-frequency = ; +}; + +&usart1 { + current-speed = <115200>; + pinctrl-0 = <&usart1_pins_a>; + pinctrl-names = "default"; + status = "okay"; +}; + +&timers2 { + status = "okay"; + + pwm { + status = "okay"; + }; +}; + +&rtc { + status = "okay"; +}; + +&iwdg { + status = "okay"; +}; diff --git a/boards/arm/steval_fcu001v1/steval_fcu001v1.yaml b/boards/arm/steval_fcu001v1/steval_fcu001v1.yaml new file mode 100644 index 00000000000..2d4c5a4c99a --- /dev/null +++ b/boards/arm/steval_fcu001v1/steval_fcu001v1.yaml @@ -0,0 +1,16 @@ +identifier: steval_fcu001v1 +name: FLIGHT-CONTROLLER-BOARD +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - gpio + - pwm + - i2c + - rtc + - watchdog +ram: 64 +flash: 256 diff --git a/boards/arm/steval_fcu001v1/steval_fcu001v1_defconfig b/boards/arm/steval_fcu001v1/steval_fcu001v1_defconfig new file mode 100644 index 00000000000..7ca5f15ef31 --- /dev/null +++ b/boards/arm/steval_fcu001v1/steval_fcu001v1_defconfig @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_ARM=y +CONFIG_BOARD_STEVAL_FCU001V1=y +CONFIG_SOC_SERIES_STM32F4X=y +CONFIG_SOC_STM32F401XC=y +CONFIG_CORTEX_M_SYSTICK=y + +# 84MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=84000000 + +# 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 + +# SYSCLK selection +CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y + +# use HSE as PLL input +CONFIG_CLOCK_STM32_PLL_SRC_HSE=y +CONFIG_CLOCK_STM32_HSE_CLOCK=16000000 + +# produce 84MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_M_DIVISOR=16 +CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=336 +CONFIG_CLOCK_STM32_PLL_P_DIVISOR=4 +CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=7 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 + +# APB1 clock must not exceed 50MHz limit +CONFIG_CLOCK_STM32_APB1_PRESCALER=2 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/boards/arm/steval_fcu001v1/support/openocd.cfg b/boards/arm/steval_fcu001v1/support/openocd.cfg new file mode 100644 index 00000000000..8412eea50e7 --- /dev/null +++ b/boards/arm/steval_fcu001v1/support/openocd.cfg @@ -0,0 +1,18 @@ +source [find interface/stlink.cfg] + +transport select hla_swd + +set WORKAREASIZE 0x10000 + +source [find target/stm32f4x.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 +}