diff --git a/boards/arm/nucleo_l011k4/CMakeLists.txt b/boards/arm/nucleo_l011k4/CMakeLists.txt new file mode 100644 index 00000000000..d1b8108cfed --- /dev/null +++ b/boards/arm/nucleo_l011k4/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/nucleo_l011k4/Kconfig.board b/boards/arm/nucleo_l011k4/Kconfig.board new file mode 100644 index 00000000000..aa6401045f7 --- /dev/null +++ b/boards/arm/nucleo_l011k4/Kconfig.board @@ -0,0 +1,8 @@ +# STM32 Nucleo-32 development board with STM32L011K4 MCU configuration + +# Copyright (c) 2020 Steven Daglish +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_NUCLEO_L011K4 + bool "NUCLEO-32 L011K4 Development Board" + depends on SOC_STM32L011XX diff --git a/boards/arm/nucleo_l011k4/Kconfig.defconfig b/boards/arm/nucleo_l011k4/Kconfig.defconfig new file mode 100644 index 00000000000..527a93140cb --- /dev/null +++ b/boards/arm/nucleo_l011k4/Kconfig.defconfig @@ -0,0 +1,15 @@ +# STM32 Nucleo-32 development board with STM32L011K4 MCU + +# Copyright (c) 2020 Steven Daglish +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NUCLEO_L011K4 + +config BOARD + default "nucleo_l011k4" + +config SPI_STM32_INTERRUPT + default y + depends on SPI + +endif # BOARD_NUCLEO_L011K4 diff --git a/boards/arm/nucleo_l011k4/board.cmake b/boards/arm/nucleo_l011k4/board.cmake new file mode 100644 index 00000000000..7c88105a59a --- /dev/null +++ b/boards/arm/nucleo_l011k4/board.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32L011K4" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/nucleo_l011k4/doc/img/nucleo_l011k4.jpg b/boards/arm/nucleo_l011k4/doc/img/nucleo_l011k4.jpg new file mode 100644 index 00000000000..ca0471e4fa3 Binary files /dev/null and b/boards/arm/nucleo_l011k4/doc/img/nucleo_l011k4.jpg differ diff --git a/boards/arm/nucleo_l011k4/doc/index.rst b/boards/arm/nucleo_l011k4/doc/index.rst new file mode 100644 index 00000000000..d6bb446fff3 --- /dev/null +++ b/boards/arm/nucleo_l011k4/doc/index.rst @@ -0,0 +1,169 @@ +.. _nucleo_l011k4_board: + +ST Nucleo L011K4 +################ + +Overview +******** +The STM32 Nucleo-32 development board with STM32L011K4 MCU, supports Arduino Nano V3 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 Arduino* Nano V3 connectivity support allow easy functionality +expansion of the STM32 Nucleo open development platform with a wide choice of +specialized shields. + +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_l011k4.jpg + :width: 426px + :height: 319px + :align: center + :alt: Nucleo L011K4 + +More information about the board can be found at the `Nucleo L011K4 website`_. + +Hardware +******** +Nucleo L011K4 provides the following hardware components: + +- STM32 microcontroller in LQFP32 package +- Extension resource: + + - Arduino* Nano V3 connectivity + +- ARM* mbed* +- On-board ST-LINK/V2-1 debugger/programmer with SWD connector: + + - Selection-mode switch to use the kit as a standalone ST-LINK/V2-1 + +- Flexible board power supply: + + - USB VBUS or external source (3.3V, 5V, 7 - 12V) + - Power management access point + +- Three LEDs: + + - USB communication (LD1), user LED (LD2), power LED (LD3) + +- One push-button: RESET +- USB re-enumeration capability. Three different interfaces supported on USB: + + - Virtual COM port + - Mass storage + - Debug port + +- Support of wide choice of Integrated Development Environments (IDEs) including: + + - IAR + - ARM Keil + - GCC-based IDEs + +More information about STM32L011K4 can be found in the +`STM32L0x1 reference manual`_ + + +Supported Features +================== + +The Zephyr nucleo_l011k4 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 | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c controller | ++-----------+------------+-------------------------------------+ +| SPI | on-chip | spi controller | ++-----------+------------+-------------------------------------+ +| EEPROM | on-chip | eeprom | ++-----------+------------+-------------------------------------+ + +Other hardware features are not yet supported in this Zephyr port. + +The default configuration can be found in the defconfig file: +``boards/arm/nucleo_l011k4/nucleo_l011k4_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. All GPIOs are high current +capable except for analog inputs. + +Default Zephyr Peripheral Mapping: +---------------------------------- + +- UART_2 TX/RX : PA2/PA15 (ST-Link Virtual Port Com) +- I2C1 SCL/SDA : PA4/PA10 (Arduino I2C) +- SPI1 SCK/MISO/MOSI : 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_l011k4`` 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 L011K4 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 L011K4 +---------------------------------------- + +Here is an example for the :ref:`blinky-sample` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/basic/blinky + :board: nucleo_l011k4 + :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:`hello_world` application. + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: nucleo_l011k4 + :maybe-skip-config: + :goals: debug + +References +********** + +.. target-notes:: + +.. _Nucleo L011K4 website: + http://www.st.com/en/evaluation-tools/nucleo-l011k4.html + +.. _STM32L0x1 reference manual: + https://www.st.com/resource/en/reference_manual/dm00108282-ultralowpower-stm32l0x1-advanced-armbased-32bit-mcus-stmicroelectronics.pdf + +.. _STM32 Nucleo-32 board User Manual: + https://www.st.com/resource/en/user_manual/dm00231744-stm32-nucleo32-boards-mb1180-stmicroelectronics.pdf diff --git a/boards/arm/nucleo_l011k4/nucleo_l011k4.dts b/boards/arm/nucleo_l011k4/nucleo_l011k4.dts new file mode 100644 index 00000000000..6268d9ae6eb --- /dev/null +++ b/boards/arm/nucleo_l011k4/nucleo_l011k4.dts @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2020 Steven Daglish + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include + +/ { + model = "STMicroelectronics STM32L011K4-NUCLEO board"; + compatible = "st,stm32l011k4-nucleo"; + + chosen { + zephyr,console = &usart2; + zephyr,shell-uart = &usart2; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + green_led_2: led_2 { + gpios = <&gpiob 3 GPIO_ACTIVE_HIGH>; + label = "User LD2"; + }; + }; + + gpio_keys { + compatible = "gpio-keys"; + user_button: button { + label = "User"; + gpios = <&gpioa 12 GPIO_ACTIVE_LOW>; + }; + }; + + aliases { + led0 = &green_led_2; + eeprom-0 = &eeprom; + }; +}; + +&usart2 { + pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa15>; + current-speed = <115200>; + status = "okay"; +}; + +&i2c1 { + pinctrl-0 = <&i2c1_scl_pa4 &i2c1_sda_pa10>; + status = "okay"; + clock-frequency = ; +}; + +&spi1 { + status = "okay"; +}; + +&eeprom { + status = "okay"; +}; diff --git a/boards/arm/nucleo_l011k4/nucleo_l011k4.yaml b/boards/arm/nucleo_l011k4/nucleo_l011k4.yaml new file mode 100644 index 00000000000..482dc095abb --- /dev/null +++ b/boards/arm/nucleo_l011k4/nucleo_l011k4.yaml @@ -0,0 +1,15 @@ +identifier: nucleo_l011k4 +name: ST Nucleo L011K4 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - gpio + - i2c + - spi + - eeprom +ram: 2 +flash: 16 diff --git a/boards/arm/nucleo_l011k4/nucleo_l011k4_defconfig b/boards/arm/nucleo_l011k4/nucleo_l011k4_defconfig new file mode 100644 index 00000000000..2f11cccf64b --- /dev/null +++ b/boards/arm/nucleo_l011k4/nucleo_l011k4_defconfig @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Zephyr Kernel Configuration +CONFIG_SOC_SERIES_STM32L0X=y + +# Platform Configuration +CONFIG_SOC_STM32L011XX=y + +# General Kernel Options +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000 + +# Kernel Options due to Low Memory (2k) +CONFIG_MAIN_STACK_SIZE=320 +CONFIG_IDLE_STACK_SIZE=100 +CONFIG_ISR_STACK_SIZE=256 + +# Serial Drivers +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=y +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# Pinmux Driver +CONFIG_PINMUX=y + +# GPIO Controller +CONFIG_GPIO=y + +# Clock configuration +CONFIG_CLOCK_CONTROL=y +# SYSCLK selection +CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y +# PLL configuration +CONFIG_CLOCK_STM32_PLL_SRC_HSI=y +# produce 32MHz clock at PLL output +CONFIG_CLOCK_STM32_PLL_MULTIPLIER=4 +CONFIG_CLOCK_STM32_PLL_DIVISOR=2 +CONFIG_CLOCK_STM32_AHB_PRESCALER=1 +CONFIG_CLOCK_STM32_APB1_PRESCALER=1 +CONFIG_CLOCK_STM32_APB2_PRESCALER=1 diff --git a/boards/arm/nucleo_l011k4/pinmux.c b/boards/arm/nucleo_l011k4/pinmux.c new file mode 100644 index 00000000000..ddb015b05b9 --- /dev/null +++ b/boards/arm/nucleo_l011k4/pinmux.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 Steven Daglish + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include + +#include + +/* pin assignments for NUCLEO-L011K4 board */ +static const struct pin_config pinconf[] = { +#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI + {STM32_PIN_PA5, STM32L0_PINMUX_FUNC_PA5_SPI1_SCK}, + {STM32_PIN_PA6, STM32L0_PINMUX_FUNC_PA6_SPI1_MISO}, + {STM32_PIN_PA7, STM32L0_PINMUX_FUNC_PA7_SPI1_MOSI}, +#endif +}; + +static int pinmux_stm32_init(const 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/nucleo_l011k4/support/openocd.cfg b/boards/arm/nucleo_l011k4/support/openocd.cfg new file mode 100644 index 00000000000..399b76d1e2f --- /dev/null +++ b/boards/arm/nucleo_l011k4/support/openocd.cfg @@ -0,0 +1,23 @@ +# This is an ST NUCLEO-L011K4 board with single STM32L011K4 chip. +# http://www.st.com/en/evaluation-tools/nucleo-l011k4.html +source [find interface/stlink.cfg] + +transport select hla_swd + +#set WORKAREASIZE 0x2000 + +source [find target/stm32l0.cfg] + +# There is only system reset line and JTAG/SWD command can be issued when SRST +reset_config srst_only + +$_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 +}