Compare commits

...
5 Commits
7 changed files with 221 additions and 32 deletions

No files matched your search

+124
View File
@@ -0,0 +1,124 @@
---
# Seeed XIAO STM32C5 as a CANopen node (mrk's canopen hub + canopen_entities), MCUboot, OTA over CAN from can2mqtt
# (upload .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin).
# Needs: substitutions node_id; the esphomeplatformzephyr fork (esphome-zephyr).
# Pinout:
# PB12 user LED (active low) -> LED (light binary)
# PH2 BOOT0, left alone (a pull-up there sends software resets to ROM DFU)
# PB5/PB13 FDCAN2 RX/TX, PB14 CAN_STB -> on-board transceiver (board DTS)
# PB3/PB4 I2C2 SCL/SDA, LSM6DS3TR-C @0x6A -> on-board IMU (motion lsm6ds)
# First flash (TinyUF2 erased with mcu-stm32-xiao-c5-eraser.yaml), hold BOOT + press RESET for ROM DFU:
# dfu-util -a 0 -s 0x08000000 -D .esphome/build/<node>/.west_build/mcuboot/zephyr/zephyr.bin
# dfu-util -a 0 -s 0x08008000:leave -D .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin
external_components:
- source: github://mrk-its/esphome-canopen@dc6efff43e0076a5c2820800e6ff5ce28ee4c678 # canopen_entities; newer needs consts the zephyr fork lacks
components: [canopen, canopen_entities]
stm32:
variant: STM32C5
board: xiao_stm32c5
framework:
advanced:
bootloader: mcuboot
# required by the fork for MCUboot on the XIAO; the first flash is dfu-util by hand (see above)
runner: stm32cubeprogrammer
logger:
logs:
# canbus logs every frame at DEBUG; over USB CDC that stalls the loop and the RX queue overflows
canbus: INFO
i2c:
# pins come from the board DTS (i2c2: PB3/PB4), STM32C5 takes no sda:/scl:
- id: i2c_imu
dts_node_override: i2c2
motion:
- platform: lsm6ds
id: imu
i2c_id: i2c_imu
address: 0x6A
update_interval: 5s
sensor:
- platform: lsm6ds
id: imu_temp
name: IMU Temperature
- platform: motion
motion_id: imu
id: pitch
type: pitch
name: Pitch
- platform: motion
motion_id: imu
id: roll
type: roll
name: Roll
output:
- platform: gpio
id: led_out
pin:
number: PB12
inverted: true
light:
- platform: binary
name: LED
id: led
output: led_out
# no button on PH2: it is BOOT0, and with BOOT_SEL on the pin (after tinyuf2_eraser) an internal pull-up there makes
# every software reset (OTA, reboot) start the ROM DFU bootloader instead of MCUboot
canbus:
- platform: zephyr_can
id: can_bus
can_id: 0
bit_rate: 500kbps
# an SDO block (16 frames) arrives back to back and must fit the RX queue (default 8)
rx_buffer_size: 32
canopen:
id: can_gate
canbus_id: can_bus
node_id: ${node_id}
heartbeat_interval: 5s
canopen_entities:
canopen_id: can_gate
entities:
- id: led
index: 1
tpdo: 0
# 2-byte encoding over min..max, so the three fit one TPDO
- id: pitch
index: 3
tpdo: 1
size: 2
min_value: -180
max_value: 180
- id: roll
index: 4
tpdo: 1
size: 2
min_value: -180
max_value: 180
- id: imu_temp
index: 5
tpdo: 1
size: 2
min_value: -40
max_value: 125
remote_logs:
level: INFO
ota:
- platform: canopen_entities
# the XIAO's board layout has slot0 one sector larger than slot1 (swap-move); with the fork's default
# (offset) MCUboot finds the slots incompatible and never installs the update
swap_method: move
# confirms the new MCUboot image after a good boot; without it MCUboot rolls back at the next reset
safe_mode:
+7
View File
@@ -1,6 +1,7 @@
--- ---
# Hardware: ESP32 DevKit # Hardware: ESP32 DevKit
# Pinout: # Pinout:
# GPIO2 -> LED (switch gpio, on-board blue LED)
# GPIO17 -> i2c (i2c sda) # GPIO17 -> i2c (i2c sda)
# GPIO18 -> i2c (i2c scl) # GPIO18 -> i2c (i2c scl)
# GPIO19 -> as3935_i2c (as3935_i2c irq_pin) # GPIO19 -> as3935_i2c (as3935_i2c irq_pin)
@@ -145,3 +146,9 @@ sensor:
# canopen: DEBUG # canopen: DEBUG
# can_driver: DEBUG # can_driver: DEBUG
# timer_driver: DEBUG # timer_driver: DEBUG
switch:
- platform: gpio
name: LED
id: blue_led
pin: 2
+25 -25
View File
@@ -3,14 +3,14 @@
# Pinout: # Pinout:
# GPIO0 Grove A pin 4, UART TX -> uart_m10 (uart tx_pin) # GPIO0 Grove A pin 4, UART TX -> uart_m10 (uart tx_pin)
# GPIO1 Grove A pin 3, UART RX -> uart_m10 (uart rx_pin) # GPIO1 Grove A pin 3, UART RX -> uart_m10 (uart rx_pin)
# GPIO18 Grove B pin 4 (USB D-), UART TX -> uart_neo6m (uart tx_pin) # GPIO18 Grove B pin 4 (USB D-), UART TX -> uart_at6668 (uart tx_pin)
# GPIO19 Grove B pin 3 (USB D+), UART RX -> uart_neo6m (uart rx_pin) # GPIO19 Grove B pin 3 (USB D+), UART RX -> uart_at6668 (uart rx_pin)
# GPIO20 UART0 RX (on-board USB to UART), unused: logger is API only # GPIO20 UART0 RX (on-board USB to UART), unused: logger is API only
# GPIO21 UART0 TX (on-board USB to UART), unused: logger is API only # GPIO21 UART0 TX (on-board USB to UART), unused: logger is API only
# Grove pin order: GND, 5V, signal, signal # Grove pin order: GND, 5V, signal, signal
# Receivers: # Receivers:
# Grove A XYZ GNSS YM-250, u-blox M10 (ROM SPG 5.10, PROTVER 34.10), 38400 baud -> gnss_m10 (ubx) # Grove A XYZ GNSS YM-250, u-blox M10 (ROM SPG 5.10, PROTVER 34.10), 38400 baud -> gnss_m10 (ubx)
# Grove B APM NEO-6M, u-blox 6 (7.03), 9600 baud -> gnss_neo6m (nmea) # Grove B M5Stack Cap LoRa-1262 GNSS, AT6668 (CASIC), 115200 baud -> gnss_at6668 (casic)
substitutions: substitutions:
device: eworkbench device: eworkbench
name: Electronics Workbench name: Electronics Workbench
@@ -38,9 +38,9 @@ packages:
ipv6_only: !include common/ipv6_only.yaml ipv6_only: !include common/ipv6_only.yaml
external_components: external_components:
# geolocation hub + nmea and ubx platforms, esphome/esphome#23301 (stacked on #23293) # geolocation hub + nmea, ubx and casic platforms: esphome/esphome#23301 (stacked on #23293) + casic, not upstream yet
- source: github://pr#23301 - source: github://randybb/esphome@geolocation-casic
components: [geolocation, nmea, ubx] components: [geolocation, nmea, ubx, casic]
logger: logger:
# The C3 has two UARTs and both receivers need one; logs go over the API only # The C3 has two UARTs and both receivers need one; logs go over the API only
@@ -104,19 +104,19 @@ uart:
} }
i += 5 + len; i += 5 + len;
} }
- id: uart_neo6m - id: uart_at6668
rx_pin: 19 rx_pin: 19
tx_pin: 18 tx_pin: 18
baud_rate: 9600 baud_rate: 115200
geolocation: geolocation:
- platform: ubx - platform: ubx
id: gnss_m10 id: gnss_m10
uart_id: uart_m10 uart_id: uart_m10
update_interval: 10s update_interval: 10s
- platform: nmea - platform: casic
id: gnss_neo6m id: gnss_at6668
uart_id: uart_neo6m uart_id: uart_at6668
update_interval: 10s update_interval: 10s
sensor: sensor:
@@ -157,33 +157,33 @@ sensor:
type: vertical_accuracy type: vertical_accuracy
name: M10 Vertical Accuracy name: M10 Vertical Accuracy
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: latitude type: latitude
name: NEO-6M Latitude name: AT6668 Latitude
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: longitude type: longitude
name: NEO-6M Longitude name: AT6668 Longitude
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: altitude type: altitude
name: NEO-6M Altitude name: AT6668 Altitude
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: speed type: speed
name: NEO-6M Speed name: AT6668 Speed
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: course type: course
name: NEO-6M Course name: AT6668 Course
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: satellites type: satellites
name: NEO-6M Satellites name: AT6668 Satellites
- platform: geolocation - platform: geolocation
geolocation_id: gnss_neo6m geolocation_id: gnss_at6668
type: hdop type: hdop
name: NEO-6M HDOP name: AT6668 HDOP
time: time:
- platform: geolocation - platform: geolocation
+18 -4
View File
@@ -501,21 +501,35 @@ interval:
then: then:
- component.update: display_tft - component.update: display_tft
# head touch gestures: a touch episode ends after 250 ms without contact; # head touch gestures: a touch episode ends after 250 ms without contact;
# tap = short episode, stroke = longer episode that reaches the pads one after another # tap = short episode, stroke = longer episode that reaches the pads one after another.
# Each ST25R scan switches its RF field on and the pads report a 50-350 ms phantom touch, at any
# si12t sensitivity, so the NFC reader is scanned from here: every 2 s between episodes, with the
# pads ignored for 400 ms afterwards, and at once when an episode starts (a card being laid on).
- interval: 50ms - interval: 50ms
then: then:
- lambda: |- - lambda: |-
static bool active = false; static bool active = false;
static uint32_t start = 0, last_on = 0; static uint32_t start = 0, last_on = 0, last_scan = 0;
static uint32_t first_on[3]; static uint32_t first_on[3];
const uint32_t now = millis();
if (!active) {
if (now - last_scan >= 2000) {
last_scan = now;
id(nfc_reader).update();
return;
}
if (now - last_scan < 400)
return;
}
const bool on[3] = {id(head_touch_1).state != "No touch", id(head_touch_2).state != "No touch", const bool on[3] = {id(head_touch_1).state != "No touch", id(head_touch_2).state != "No touch",
id(head_touch_3).state != "No touch"}; id(head_touch_3).state != "No touch"};
const uint32_t now = millis();
if (on[0] || on[1] || on[2]) { if (on[0] || on[1] || on[2]) {
if (!active) { if (!active) {
active = true; active = true;
start = now; start = now;
last_scan = now;
id(nfc_reader).update();
first_on[0] = first_on[1] = first_on[2] = 0; first_on[0] = first_on[1] = first_on[2] = 0;
} }
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@@ -898,7 +912,7 @@ event:
st25r_i2c: st25r_i2c:
id: nfc_reader id: nfc_reader
i2c_id: i2c_bsp i2c_id: i2c_bsp
update_interval: 200ms update_interval: never # polled from the head touch interval, see there
on_tag: on_tag:
- lambda: |- - lambda: |-
id(nfc_changed_ms) = millis(); id(nfc_changed_ms) = millis();
+34
View File
@@ -0,0 +1,34 @@
---
# One-shot for a Seeed XIAO STM32C5 still on TinyUF2: erases TinyUF2 5 s after boot (mrk's tinyuf2_eraser, LED on when
# done), then hold BOOT + press RESET (ROM DFU, 0483:df11) and flash the MCUboot build of the node:
# dfu-util -a 0 -s 0x08000000 -D .esphome/build/<node>/.west_build/mcuboot/zephyr/zephyr.bin
# dfu-util -a 0 -s 0x08008000:leave -D .esphome/build/<node>/.west_build/zephyr/zephyr/zephyr.signed.bin
esphome:
name: mcu-stm32-xiao-c5-eraser
on_boot:
priority: -100
then:
- delay: 5s
- tinyuf2_eraser.erase: eraser
# LED on: erased, go to DFU (BOOT + RESET)
- output.turn_on: led_out
external_components:
- source: github://mrk-its/esphome-canopen@canopen_entities
components: [tinyuf2_eraser]
stm32:
variant: STM32C5
board: xiao_stm32c5
logger:
tinyuf2_eraser:
id: eraser
output:
- platform: gpio
id: led_out
pin:
number: PB12
inverted: true
+13
View File
@@ -0,0 +1,13 @@
---
# Hardware: Seeed XIAO STM32C5 #1, CANopen node 0x20 (see common/xiao_stm32c5_canopen.yaml); its LED is light
# entity 1 (0x2011:1 / 0x2012:1), the server for mcu-stm32-xiao-c5-sdo-client.yaml (esphome#22410 test)
# USB serial: 3838333031365105001F005D (TinyUF2: 5D001F000551363130333838)
substitutions:
node_id: "0x20"
esphome:
name: mcu-stm32-xiao-c5
friendly_name: XIAO STM32C5
packages:
node: !include common/xiao_stm32c5_canopen.yaml
-3
View File
@@ -74,9 +74,6 @@ esp32:
# ipv6_only: !include common/ipv6_only.yaml # ipv6_only: !include common/ipv6_only.yaml
external_components: external_components:
# modem from before esphome#22817: its CFUN=0 at start powers the SIM7600's SIM down for good (SIM failure)
- source: github://esphome/esphome@200bf69035292853fa427d2e737d0b2da7de25d0
components: [modem]
- source: github://m5stack/esphome-yaml - source: github://m5stack/esphome-yaml
components: [axp192] components: [axp192]
refresh: 1h refresh: 1h