From a07bce90f9b8ef3c2016ff7d36b9c0a7fc46a6bf Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Tue, 27 Oct 2026 21:17:53 +0100 Subject: [PATCH] stm32-*" initial stm32 (zephyr) devices --- mcu-stm32-blackpill.yaml | 79 ++++++++++++++++++++++++++++++++++++++++ mcu-stm32-nucleo.yaml | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 mcu-stm32-blackpill.yaml create mode 100644 mcu-stm32-nucleo.yaml diff --git a/mcu-stm32-blackpill.yaml b/mcu-stm32-blackpill.yaml new file mode 100644 index 0000000..9139622 --- /dev/null +++ b/mcu-stm32-blackpill.yaml @@ -0,0 +1,79 @@ +--- +# Hardware: WeAct Black Pill STM32F401CCU6 (256K flash, no radio) +# Pinout: +# PA11/PA12 USB-C -> logger (USB CDC), flashing via ROM DFU (hold BOOT0, tap NRST) +# PC13 blue LED (active low) -> LED (light binary) +# PA0 KEY (active low) -> Button (binary_sensor gpio) +esphome: + name: mcu-stm32-blackpill + friendly_name: STM32 Black Pill + +# needs the esphomeplatformzephyr fork (esphome-zephyr), upstream has no zephyr: platform yet +zephyr: + variant: STM32F4 + board: blackpill_f401cc + framework: + type: zephyr + advanced: + runner: dfu-util + # no network, so no OTA: one image slot, MCUboot only verifies and boots it + single_slot: true + # NVS sector = flash page; needs >= 2 of them, so storage takes the two 16K pages (sectors 2-3) + kconfig_options: + SETTINGS_NVS_SECTOR_COUNT: 2 + # the stock table puts slot1 at 0x40000, past the end of the 256K flash; + # MCUboot in sectors 0-1, storage in 2-3, the app in 4-5. + # MCUboot needs the same table; the fork appends its own code-partition = &boot_partition after it + overlays: + app: &partitions | + &flash0 { + /delete-node/ partitions; + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 DT_SIZE_K(32)>; + read-only; + }; + storage_partition: partition@8000 { + label = "storage"; + reg = <0x00008000 DT_SIZE_K(32)>; + }; + slot0_partition: partition@10000 { + label = "image-0"; + reg = <0x00010000 DT_SIZE_K(192)>; + }; + }; + }; + / { chosen { zephyr,code-partition = &slot0_partition; }; }; + mcuboot: *partitions + +logger: + hardware_uart: USB_CDC + +output: + - platform: gpio + id: led_out + pin: + number: PC13 + inverted: true + +light: + - platform: binary + name: LED + id: led + output: led_out + +binary_sensor: + - platform: gpio + name: Button + pin: + number: PA0 + inverted: true + mode: + input: true + pullup: true + on_press: + light.toggle: led diff --git a/mcu-stm32-nucleo.yaml b/mcu-stm32-nucleo.yaml new file mode 100644 index 0000000..5f56765 --- /dev/null +++ b/mcu-stm32-nucleo.yaml @@ -0,0 +1,70 @@ +--- +# Hardware: ST NUCLEO-F411RE (STM32F411RE, 512K flash, no radio) +# Pinout: +# PA2/PA3 USART2 TX/RX -> ST-LINK virtual COM port (logger) +# PA5 LD2 green (active high) -> LED (light binary) +# PC13 B1 user (active low) -> Button (binary_sensor gpio) +esphome: + name: mcu-stm32-nucleo + friendly_name: STM32 Nucleo + +# needs the esphomeplatformzephyr fork (esphome-zephyr), upstream has no zephyr: platform yet +zephyr: + variant: STM32F4 + board: nucleo_f411re + framework: + type: zephyr + # no network, so no OTA: one image slot, MCUboot only verifies and boots it + single_slot: true + # NVS sector = flash page; needs >= 2 of them, so storage takes the two 16K pages (sectors 2-3) + kconfig_options: + SETTINGS_NVS_SECTOR_COUNT: 2 + # nucleo_f411re ships no partitions at all: MCUboot in sectors 0-1, storage in 2-3, the app in 4-7. + # MCUboot needs the same table; the fork appends its own code-partition = &boot_partition after it + overlays: + app: &partitions | + &flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + boot_partition: partition@0 { + label = "mcuboot"; + reg = <0x00000000 DT_SIZE_K(32)>; + read-only; + }; + storage_partition: partition@8000 { + label = "storage"; + reg = <0x00008000 DT_SIZE_K(32)>; + }; + slot0_partition: partition@10000 { + label = "image-0"; + reg = <0x00010000 DT_SIZE_K(448)>; + }; + }; + }; + / { chosen { zephyr,code-partition = &slot0_partition; }; }; + mcuboot: *partitions + +logger: + +output: + - platform: gpio + id: led_out + pin: PA5 + +light: + - platform: binary + name: LED + id: led + output: led_out + +# B1 has an external pull-up on the board +binary_sensor: + - platform: gpio + name: Button + pin: + number: PC13 + inverted: true + on_press: + light.toggle: led