-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
boards: arm: nucleo_f042k6: add support for nucleo_f042k6
Add support for Nucleo F042K6 Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
- Loading branch information
1 parent
5359225
commit 8cf84e2
Showing
10 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# STM32 Nucleo-32 development board with STM32F031K6 MCU configuration | ||
|
||
# Copyright (c) 2023 STMicroelectronics | ||
|
||
# SPDX -License-Identifier: Apache-2.0 | ||
|
||
config BOARD_NUCLEO_F042K6 | ||
bool "NUCLEO-32 F042K6 Development Board" | ||
depends on SOC_STM32F042X6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# STM32 Nucleo-32 development board with STM32F042K6 MCU | ||
|
||
# Copyright (c) 2023 STMicroelectronics | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if BOARD_NUCLEO_F042K6 | ||
|
||
config BOARD | ||
default "nucleo_f042k6" | ||
|
||
endif # BOARD_NUCLEO_F042K6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_runner_args(jlink "--device=STM32F042K6" "--speed=4000") | ||
|
||
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
.. _nucleo_f042k6_board: | ||
|
||
ST Nucleo F042K6 | ||
################ | ||
|
||
Overview | ||
******** | ||
The STM32 Nucleo-32 development board with STM32F042K6 MCU, supports Arduino nano connectivity. | ||
|
||
The STM32 Nucleo board provides an affordable, and flexible way for users to try out new concepts, | ||
and build prototypes with the STM32 microcontroller, choosing from the various | ||
combinations of performance, power consumption and features. | ||
|
||
The STM32 Nucleo board integrates the ST-LINK/V2-1 debugger and programmer. | ||
|
||
The STM32 Nucleo board comes with the STM32 comprehensive software HAL library together | ||
with various packaged software examples. | ||
|
||
.. image:: img/nucleo_f042k6.jpg | ||
:align: center | ||
:alt: Nucleo F042k6 | ||
|
||
More information about the board can be found at the `Nucleo F042K6 website`_. | ||
|
||
Hardware | ||
******** | ||
Nucleo F042K6 provides the following hardware components: | ||
|
||
- STM32 microcontroller in LQFP32 package | ||
|
||
- On-board ST-LINK/V2-1 debugger/programmer with SWD connector: | ||
|
||
- Flexible board power supply: | ||
|
||
- USB VBUS or external source (3.3V, 5V, 7 - 12V) | ||
|
||
- Three LEDs: | ||
|
||
- USB communication (LD1), user LED (LD2), power LED (LD3) | ||
|
||
- reset push button | ||
|
||
More information about STM32F042K6 can be found here: | ||
|
||
- `STM32F042 reference manual`_ | ||
- `STM32F042 data sheet`_ | ||
|
||
Supported Features | ||
================== | ||
|
||
The Zephyr nucleo_f042k6 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 | | ||
+-----------+------------+-------------------------------------+ | ||
| I2C | on-chip | i2c controller | | ||
+-----------+------------+-------------------------------------+ | ||
| SPI | on-chip | spi controller | | ||
+-----------+------------+-------------------------------------+ | ||
|
||
Other hardware features are not yet supported in this Zephyr port. | ||
|
||
The default configuration can be found in the defconfig file: | ||
``boards/arm/nucleo_f042k6/nucleo_f042k6_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. | ||
|
||
Board connectors: | ||
----------------- | ||
.. image:: img/nucleo_f042k6_connectors.jpg | ||
:align: center | ||
:alt: Nucleo F042K6 connectors | ||
|
||
Default Zephyr Peripheral Mapping: | ||
---------------------------------- | ||
|
||
- UART_1 TX/RX : PA2/PA15 (ST-Link Virtual COM Port) | ||
- I2C1 SCL/SDA : PB6/PB7 (Arduino I2C) | ||
- SPI1 NSS/SCK/MISO/MOSI : PA4/PA5/PA6/PA7 (Arduino SPI) | ||
- LD2 : PB3 | ||
|
||
|
||
For mode details please refer to `STM32 Nucleo-32 board User Manual`_. | ||
|
||
Programming and Debugging | ||
************************* | ||
|
||
Applications for the ``nucleo_f042k6`` board configuration can be built and | ||
flashed in the usual way (see :ref:`build_an_application` and | ||
:ref:`application_run` for more details). | ||
|
||
Flashing | ||
======== | ||
|
||
Nucleo F042K6 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 F042K6 | ||
---------------------------------------- | ||
|
||
Here is an example for the :ref:`blinky-sample` application. | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/basic/blinky | ||
:board: nucleo_f042k6 | ||
: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: nucleo_f042k6 | ||
:maybe-skip-config: | ||
:goals: debug | ||
|
||
References | ||
********** | ||
|
||
.. target-notes:: | ||
|
||
.. _Nucleo F042K6 website: | ||
https://www.st.com/en/evaluation-tools/nucleo-f042k6.html | ||
|
||
.. _STM32F042 reference manual: | ||
https://www.st.com/resource/en/reference_manual/dm00031936-stm32f0x1stm32f0x2stm32f0x8-advanced-armbased-32bit-mcus-stmicroelectronics.pdf | ||
|
||
.. _STM32F042 data sheet: | ||
https://www.st.com/resource/en/datasheet/stm32f042k6.pdf | ||
|
||
.. _STM32 Nucleo-32 board User Manual: | ||
https://www.st.com/resource/en/user_manual/dm00231744-stm32-nucleo32-boards-mb1180-stmicroelectronics.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2021 Sebastian Schwabe <sebastian.schwabe@mailbox.tu-dresden.de> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/dts-v1/; | ||
#include <st/f0/stm32f042X6.dtsi> | ||
#include <st/f0/stm32f042k(4-6)tx-pinctrl.dtsi> | ||
|
||
/ { | ||
model = "STMicroelectronics STM32F042K6-NUCLEO board"; | ||
compatible = "st,stm32f042k6-nucleo"; | ||
|
||
chosen { | ||
zephyr,console = &usart2; | ||
zephyr,shell-uart = &usart2; | ||
zephyr,sram = &sram0; | ||
zephyr,flash = &flash0; | ||
}; | ||
|
||
leds { | ||
compatible = "gpio-leds"; | ||
green_led_3: led_3 { | ||
gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; | ||
label = "User LD3"; | ||
}; | ||
}; | ||
|
||
pwmleds { | ||
compatible = "pwm-leds"; | ||
green_pwm_led: green_pwm_led { | ||
pwms = <&pwm3 32 PWM_MSEC(20) PWM_POLARITY_NORMAL>; | ||
}; | ||
}; | ||
|
||
aliases { | ||
led0 = &green_led_3; | ||
pwm-led0 = &green_pwm_led; | ||
}; | ||
}; | ||
|
||
&clk_lsi { | ||
status = "okay"; | ||
}; | ||
|
||
&clk_hsi { | ||
status = "okay"; | ||
}; | ||
|
||
&pll { | ||
prediv = <1>; | ||
mul = <6>; | ||
clocks = <&clk_hsi>; | ||
status = "okay"; | ||
}; | ||
|
||
&rcc { | ||
clocks = <&pll>; | ||
clock-frequency = <DT_FREQ_M(48)>; | ||
ahb-prescaler = <1>; | ||
apb1-prescaler = <1>; | ||
}; | ||
|
||
&timers3 { | ||
status = "okay"; | ||
|
||
pwm3: pwm { | ||
status = "okay"; | ||
pinctrl-0 = <&tim3_ch3_pb0>; | ||
pinctrl-names = "default"; | ||
}; | ||
}; | ||
|
||
&usart2 { | ||
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa15>; | ||
pinctrl-names = "default"; | ||
current-speed = <115200>; | ||
status = "okay"; | ||
}; | ||
|
||
&i2c1 { | ||
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; | ||
pinctrl-names = "default"; | ||
status = "okay"; | ||
clock-frequency = <I2C_BITRATE_FAST>; | ||
}; | ||
|
||
&spi1 { | ||
pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; | ||
pinctrl-names = "default"; | ||
cs-gpios = <&gpioa 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; | ||
status = "okay"; | ||
}; | ||
|
||
&adc1 { | ||
pinctrl-0 = <&adc_in0_pa0>; | ||
pinctrl-names = "default"; | ||
status = "okay"; | ||
}; | ||
|
||
&rtc { | ||
clocks = <&rcc STM32_CLOCK_BUS_APB1 0x10000000>, | ||
<&rcc STM32_SRC_LSI RTC_SEL(2)>; | ||
status = "okay"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
identifier: nucleo_f042k6 | ||
name: ST Nucleo F042K6 | ||
type: mcu | ||
arch: arm | ||
toolchain: | ||
- zephyr | ||
- gnuarmemb | ||
- xtools | ||
ram: 6 | ||
flash: 32 | ||
supported: | ||
- i2c | ||
- spi | ||
- gpio | ||
- adc | ||
testing: | ||
ignore_tags: | ||
- net | ||
- bluetooth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Zephyr Kernel Configuration | ||
CONFIG_SOC_SERIES_STM32F0X=y | ||
|
||
# Platform Configuration | ||
CONFIG_SOC_STM32F042X6=y | ||
|
||
# Serial Drivers | ||
CONFIG_SERIAL=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y | ||
# enable console | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y | ||
|
||
# GPIO Controller | ||
CONFIG_GPIO=y | ||
|
||
# Enable Clocks | ||
CONFIG_CLOCK_CONTROL=y | ||
|
||
# enable pin controller | ||
CONFIG_PINCTRL=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
source [find board/st_nucleo_f0.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 | ||
} |