mirror of
https://github.com/randybb/esphome-configs.git
synced 2026-12-06 09:06:52 +01:00
xiao-stm32c5: CANopen node package (canopen + canopen_entities, MCUboot, OTA over CAN), node 0x20 and the TinyUF2 eraser
This commit is contained in:
1 parent
0c93059c78
commit
71c31035e5
3 files changed
+171
No files matched your search
@@ -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:
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
Reference in new issue
Block a user