devbis / z03mmc

Xiaomi LYWSD03MMC Zigbee Firmware
GNU General Public License v3.0
963 stars 46 forks source link

How to OTA custom firmware? #160

Closed aurbod closed 2 months ago

aurbod commented 2 months ago

Hello! This is a follow-up question to issue #18 : I would like to create a custom firmware and upload it via OTA. So far, I have not been successfull. This is what I tried:

However, it always says "No update available":


info  2024-08-28 06:26:06: Checking if update available for '0xa4c138631a34bea1'
info  2024-08-28 06:26:12: No update available for '0xa4c138631a34bea1'
info  2024-08-28 06:26:12: MQTT publish: topic 'zigbee2mqtt/0xa4c138631a34bea1', payload '{"battery":100,"comfort_humidity_max":85,"comfort_humidity_min":50,"comfort_temperature_max":25,"comfort_temperature_min":20,"enable_display":"ON","humidity":56.64,"humidity_calibration":0,"linkquality":160,"show_smiley":"SHOW","temperature":23.42,"temperature_calibration":0.04,"temperature_display_mode":"celsius","update":{"installed_version":285224961,"latest_version":285224961,"state":"idle"}}'
info  2024-08-28 06:26:12: MQTT publish: topic 'zigbee2mqtt/bridge/response/device/ota_update/check', payload '{"data":{"id":"0xa4c138631a34bea1","updateAvailable":false},"status":"ok","transaction":"mf831-1"}'

I even tried the add.js script from https://github.com/Koenkk/zigbee-OTA/tree/master to create my very own index.json, but this did not work either. Am I missing something? Do I need to change the "-DMANUFACTURER_CODE" in the build command?

aurbod commented 2 months ago

For reference this is my index.json created by add.js

cat index.json
[
    {
        "fileVersion": 302067713,
        "fileSize": 131378,
        "manufacturerCode": 4417,
        "imageType": 515,
        "sha512": "ae83e077d91fc4b2ca658c2d9754daa6675b632863f62aa1edd786bf909b2541c25b63752972b791be546527cecfca99c50c598085c3a948e72a206a95b99444",
        "url": "https://github.com/Koenkk/zigbee-OTA/raw/master/images/Telink/1141-0203-12013001-z03mmc.zigbee",
        "path": "images/Telink/1141-0203-12013001-z03mmc.zigbee"
    }
]

I've changed the url to /opt/zigbee2mqtt/data/ota/1141-0203-12013001-z03mmc.zigbee and removed the "path" entry, this did not work either.

devbis commented 2 months ago

Before starting OTA the device checks OTA file's header against manufacturer ID and device ID. In 1.1.0 vendor ID is 0xdb15 and device ID is 0x0203 You need to keep these values OR mangle them in OTA header. I just added options in tools/make_ota.py to let you set old values in the header and use your own ones in the binary.

aurbod commented 2 months ago

Hi Ivan, thank you so much for your quick reply and fix! I was able to update my custom firmware as follows:

That was it! Afterwards I did a manual update check in zigbee2mqtt, it detected the new firmware, the whole OTA took around 15 min. I've posted the result in issue #18

Thanks!