devbis / z03mmc

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

error on xiaomi lywsd03mmc ble to zigbee (devbis.github.io/telink-zigbee/) #91

Closed Lousr1952 closed 10 months ago

Lousr1952 commented 10 months ago

12:13:50: Searching for devices 12:14:28: Get Advertising MAC (Web Experimental Features!) 12:14:28: Connecting to: ATC_4852E5 12:14:43: MAC: A4C1384852E5, Bat: 100%, Vbat: 3248 mV , Temp: 21.7°C, Humi: 54.56%, Count: 3, Flg: 4 12:14:51: Hardware Revision String: B1.6 12:14:51: Software Revision String: V4.4 12:14:51: Firmware Revision String: github.com/pvvx 12:14:51: Detected custom Firmware 12:14:51: Hardware Version: LYWSD03MMC B1.6, Software Version: 4.4, Sensor: SHT4x 12:14:51: Custom config HEX string: 55051000002804a9313104b4 12:15:10: File: ATC_ota_40000.bin 12:15:10: File size: 82516 bytes 12:15:10: Count: 5158 12:15:14: Start DFU 12:15:19: Update error: NotSupportedError: GATT operation failed for unknown reason. 12:15:19: Disconnected.

pvvx commented 10 months ago
  1. Go to the Over-the-air Webupdater Page TelinkMiFlasher.html
  2. In the Telink Flasher Page: Press Connect:. The browser should open a popup with visible Bluetooth devices. Choose the according target device to pair.
  3. Select BLE firmware version 4.6. Press Start Flashing. Wait for the firmware to finish.
  4. Click "Reconnect".
  5. In the file name field paste "https://github.com/devbis/z03mmc/releases/download/1.0.6/1141-0203-10063001-z03mmc.zigbee". Press Start Flashing. Wait for the firmware to finish.

If you do not use special OTA methods, then the Zigbee firmware from devbis results in a bricked device.

It is not recommended to use the devbis-patched firmware "ATC_ota_40000.bin" due to a large number of problems users have with it.

pellz0r commented 10 months ago

22:21:22: Searching for devices 22:21:40: Get Advertising MAC (Web Experimental Features!) 22:21:40: Connecting to: ATC_6A2F7E 22:21:42: MAC: A4C1386A2F7E, Bat: 100%, Vbat: 2972 mV , Temp: 24.37°C, Humi: 37.63%, Count: 16, Flg: 4 22:21:49: Hardware Revision String: B1.6 22:21:49: Software Revision String: V4.4 22:21:49: Firmware Revision String: github.com/pvvx 22:21:49: Detected custom Firmware 22:21:49: Hardware Version: LYWSD03MMC B1.6, Software Version: 4.4, Sensor: SHT4x 22:21:49: Custom config HEX string: 55051000002804a9313104b4 22:22:32: Load firmware file 'ATC_v46.bin'... 22:22:32: File: ATC_v46.bin 22:22:32: File size: 82612 bytes 22:22:32: Count: 5164 22:22:35: Start DFU 22:24:23: Update done after 107.08 seconds 22:24:27: Disconnected. 22:24:30: Reconnect 22:24:35: Hardware Revision String: B1.6 22:24:35: Software Revision String: V4.6 22:24:35: Firmware Revision String: github.com/pvvx 22:24:35: Detected custom Firmware 22:24:35: Hardware Version: LYWSD03MMC B1.6, Software Version: 4.6, Sensor: SHT4x 22:24:35: Custom config HEX string: 55051000002804a9313104b4 22:24:54: File: 1141-0203-10063001-z03mmc.zigbee 22:24:54: Zigbee OTA Info: ManCode: 1141, ImageType: 0203, FwVer: 10063001 22:24:54: APP Release: 1.0 Build: 0.6, Stack Version: 3.0 Release: 0.1 22:24:54: File size: 130004 bytes 22:24:54: Count: 8126 22:25:01: Start DFU 22:25:07: Clear Ext.OTA region (126kib)... 22:25:17: Clean Flash OTA region: 0x040000, size: 128 kbytes. Go OTA... 22:25:22: Update error: NotSupportedError: GATT operation failed for unknown reason. 22:25:22: Disconnected.

pvvx commented 10 months ago

Run OTA again. If Flash contains many records, then the connection may break the first time when clearing. There are dependencies on the properties of the BT adapter to support connections at varying intervals.

The OTA connection may be interrupted when the battery is low.

File size: 82612 bytes Update done after 107.08 seconds

This indicates poor connection quality or BT adapter. For a normal BT adapter, the transmission and recording time of this volume is up to 50 seconds.

02:53:10: File: https://raw.githubusercontent.com/pvvx/ZigbeeTLc/master/bin/ZCGDK2_v0114.bin
02:53:10: File size: 128756 bytes
02:53:10: Count: 8048
02:53:21: Start DFU
02:54:04: Update done after 42.156 seconds

I have not yet seen any reports of Zigbee firmware running successfully on LYWSD03MMC B1.5/B1.6.

Lousr1952 commented 10 months ago

tried as you suggested,

13:12:55: Searching for devices 13:14:47: NotFoundError: User cancelled the requestDevice() chooser. 13:14:47: Reconnect 1 from 5 13:15:25: Searching for devices 13:15:36: Get Advertising MAC (Web Experimental Features!) 13:15:36: Connecting to: ATC_4852E5 13:15:36: MAC: A4C1384852E5, Bat: 100%, Vbat: 3048 mV , Temp: 24.01°C, Humi: 58.2%, Count: 4, Flg: 4 13:15:47: Hardware Revision String: B1.6 13:15:47: Software Revision String: V4.4 13:15:47: Firmware Revision String: github.com/pvvx 13:15:47: Detected custom Firmware 13:15:47: Hardware Version: LYWSD03MMC B1.6, Software Version: 4.4, Sensor: SHT4x 13:15:47: Custom config HEX string: 55051000002804a9313104b4 13:17:15: Load firmware file 'ATC_v46.bin'... 13:17:15: File: ATC_v46.bin 13:17:15: File size: 82612 bytes 13:17:15: Count: 5164 13:17:20: Start DFU 13:17:26: Update error: NotSupportedError: GATT operation failed for unknown reason. 13:17:26: Disconnected. 13:18:13: Reconnect 13:18:22: Hardware Revision String: B1.6 13:18:22: Software Revision String: V4.4 13:18:22: Firmware Revision String: github.com/pvvx 13:18:22: Detected custom Firmware 13:18:22: Hardware Version: LYWSD03MMC B1.6, Software Version: 4.4, Sensor: SHT4x 13:18:22: Custom config HEX string: 55051000002804a9313104b4 13:18:57: Load firmware file 'ATC_v46.bin'... 13:18:57: File: ATC_v46.bin 13:18:58: File size: 82612 bytes 13:18:58: Count: 5164 13:19:19: Load firmware file 'ATC_v46.bin'... 13:19:19: File: ATC_v46.bin 13:19:20: File size: 82612 bytes 13:19:20: Count: 5164 13:19:23: Start DFU 13:19:29: Update error: NotSupportedError: GATT operation failed for unknown reason. 13:19:30: Disconnected.

pellz0r commented 10 months ago

Tried on another LYWSD03MMC (brand new) using another device. This time the transfer took around 50s so a better BT connection. It fails on the same step again though when trying to flash 1141-0203-10063001-z03mmc.zigbee. It comes to block 7, and then just halts and disconnects... I guess it's because the B1.6 HW rev :(

pvvx commented 10 months ago

@pellz0r - Try using TelinkMiFlasher.html on Android device.


On Windows with Chrome, after flashing from the original version, it is advisable to:

  1. Restart the BT adapter power.
  2. Reset browser cache (ctrl+f5)
  3. Inpyt chrome://bluetooth-internals/ and reset browser cache.

Or use incognito mode in your browser.

Otherwise, the browser will remember the headers of the device with the original firmware, merge them with the new ones, and errors will inevitably occur. Another method is to change the MAC of the thermometer. Since the adapter and browser caches the description of BT devices with MAC binding


If OTA fails, setting a shorter connection interval helps on some BT adapters:

image

Options - from 100 to 1000 ms.

https://github.com/pvvx/ATC_MiThermometer/issues/393#issuecomment-1791704594

This is usually due to the adapter firmware version with incomplete support of Bluetooth standards. 90% of Chinese USB-BT adapters based on the ATS2851 chip have firmware with hundreds of errors... There are also many counterfeits of USB-BT on sale under third-party brand names, but they are made on different chips (usually ATS2851).

Example - USB VID/PID from CSR8510A10. But suddenly it became HCI 10.137 / LMP 10.137

And inside: image

Real CSR8510A10: image

pellz0r commented 10 months ago

I've managed to flash two of them to zigbee now! I went a bit loose cannon and just first flashed the ATC_ota_40000.bin file using the telink-zigbee flasher pager. After that was done I tried flashing z03mmc.bin using the same flasher page. It failed so I removed the battery from the device, put it back and then reconnected and successfully flashed the firmware :)

pvvx commented 10 months ago

It failed so I removed the battery from the device, put it back and then reconnected and successfully flashed the firmware

I have never performed such actions. Everything was always resolved without switching power. In addition to programming over the wire. Sometimes you have to start the chip using this method if there is no access to the Reset pin (if the SWS pin is reprogrammed to GPIO).

devbis commented 10 months ago

@Lousr1952 I received V1.6 HW sensors and confirm that OTA in transitional firmware is broken. After some research I found out that enabling uart breaks the ability to use OTA. For this case I just disable LCD for 1.5/1.6 revisions in transitional fw, now update works correctly. For already stuck devices the only known way is to flash via UART/SWS.

pvvx commented 10 months ago

@devbis - Thank you for giving a more specific indication of the causes of OTA instability in the program for thermometers B1.5 and B1.6. The instability has already been fixed in all current alternative versions of BLE firmware.