- C 99.2%
- Assembly 0.3%
- CMake 0.2%
- Linker Script 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
- Motor: build soft start/stop ramps per speed (0% = half, 50% = original, 100% = double), ramp time stays constant; safety timeout scales with move - Zigbee: MotorSpeed attribute (0x0005) in the settings cluster, stored in EE - z2m converter: motor_speed setting - Bump FW_VERSION to 3 |
||
| .vscode | ||
| Bootloader | ||
| cmake | ||
| Core | ||
| Drivers | ||
| Middlewares/ST | ||
| STM32_WPAN | ||
| tools | ||
| Utilities | ||
| zigbee2mqtt | ||
| .clangd | ||
| .cproject | ||
| .gitignore | ||
| .mxproject | ||
| .project | ||
| BackBlind.ioc | ||
| CMakeLists.txt | ||
| CMakePresets.json | ||
| ReadMe.md | ||
| startup_stm32wb5mxx_cm4.s | ||
| STM32WB5MMGHX_FLASH.ld | ||
| STM32WB5MMGHX_RAM.ld | ||
| stm32wb5mxx_flash_cm4.ld | ||
BackBlind
Software project for controlling the Blinds in the Back of the house.
First steps
- Working pheriphals;
- Working BLE connection (easy to test with phone);
- Encoder + Button
- Motor control
- I2C
- Light sensor
- BME
Next steps
- Change to Zigbee
- Add to HA OTA updates (Zigbee)
The firmware can be updated over Zigbee with the standard OTA Upgrade cluster
(client on endpoint 1). Flash layout, see Core/Inc/ota_layout.h:
| Address | Size | Content |
|---|---|---|
0x08000000 |
16 KB | Bootloader (Bootloader/) |
0x08004000 |
212 KB | Application |
0x08039000 |
212 KB | Download slot |
0x0806E000 |
4 KB | Update record |
0x08070000 |
64 KB | Zigbee NVM (kept, device stays paired) |
How it works:
- The device finds the OTA server on the coordinator and asks for a new image at startup and once a day. A "check for update" from the server (Image Notify) also starts a query.
- The image is downloaded into the download slot, then the CRC is checked and an update record is written.
- After the server says to upgrade, the device reboots. The bootloader checks the image again, copies it to the application slot, and starts it.
First time (wired)
Devices running the old firmware (app at 0x08000000) must be flashed once over SWD:
build/<preset>/Bootloader/Bootloader.hex(at0x08000000)- the application as usual (debugger /
BackBlind.elf, now linked at0x08004000)
The debugger only flashes the application, so the bootloader stays in place.
Releasing an update
- Increase
FW_VERSIONinCMakeLists.txt. - Build. This creates
build/<preset>/BackBlind-<version>.ota(manufacturer0x1041, image type0x0002) usingtools/make_ota.py. - Offer the
.otafile through the OTA server. For zigbee2mqtt use a local OTA index (ota: zigbee_ota_override_index_location). The device definition (external converter) must have OTA enabled.
Notes:
- If STM32CubeMX regenerates the linker scripts, set
FLASHback toORIGIN = 0x08004000, LENGTH = 212K.make_ota.pyrefuses images that are not linked for the app slot. - Only the M4 application is updated. The CPU2 wireless stack is not.
Zigbee interface
| Endpoint | Device | Clusters |
|---|---|---|
| 1 | Window covering | Basic, Identify, Window Covering (0x0102), BackBlind settings (0xFC10), OTA client |
| 2 | Simple sensor | Identify, Temperature, Humidity, Pressure, Illuminance |
Window Covering (standard): tilt only blind. CurrentPositionTiltPercentage (0% = open,
100% = closed), Up/Open goes to OpenLevel, Down/Close to 100%, Stop, Go To Tilt Percentage.
Mode bit 0 (reversed) inverts the motor direction.
BackBlind settings cluster 0xFC10 (manufacturer specific, plain integers):
| Attr | Name | Type | Description |
|---|---|---|---|
0x0000 |
TiltRange | uint16 | Encoder steps from 0% to 100% (default 944) |
0x0001 |
DeadSteps | uint16 | Encoder steps of gear play on a direction change |
0x0002 |
OpenLevel | uint8 | Tilt (%) for the Up/Open command (default 50) |
0x0003 |
StartupLevel | uint8 | Tilt (%) assumed after a power loss |
0x0004 |
SyncLevel | uint8 | Write: the blind is now at x% (no movement) |
The settings are stored in their own EE words and survive re-pairing.
zigbee2mqtt: copy zigbee2mqtt/backblind.mjs to <z2m data>/external_converters/.