The Xiaomi Smart Clock is an Android based smart clock that runs Android Go 10. There are two variants: the LX04 for China (LX04) and the X04G for the rest of the world. They have the same hardware but LineageOS can only be installed on the LX04 as the LineageOS image for this device assumes the LX04 partition layout. Fortunately the X04G can be flashed to the LX04.
This guide is based on:
- Rainygortex3's XDA thread
- octathorp's XDA thread
- octathorp's tools
- Informatic's research
- AyraHikari's guide
Goal
The goal is to have the Xiaomi Smart Clock running View Assist Companion App.
While you can get Android Go 10 running ViewAssist Companion App (VACA), it's more straightforward to get LineageOS running on the device and then have VACA run on it.
If you have a Chinese Market Smart Clock (LX04), first flash it to an X04G, then proceed to the LineageOS instructions.
If you have a rest-of-world clock (X04G) proceed to the LineageOS instructions.
Necessary Software
To Install LineageOS
- Download and install mtkclient to backup your device and flash it as necessary. Follow the instructions to install all its dependencies.
- Download and install the Android SDK and Platform Tools for
adb
andfastboot
. - Download the LineageOS image
For LX04 -> X04G Conversion
- If you have an Chinese market clock (LX04) download the following files from AyraHikari's github repo: boot1_for_microx04g.bin, gpt_x04g.bin, and preloader_mico_x04g.bin and the
Global Dump ROM Dump_mico_x04g.tar.xz
linked to from the Tools section.
Backup your Clock
This is important, back up your clock. You will use files from the backup plus downloaded files to flash your clock to the new software.
Regardless of which clock you have, use mtkclient
to back up your clock first.
Follow these instructions to use mtkclient to back up the flash and partitions of your clock.
China Edition (LX04) -> Global Edition (X04G) Instructions
- Unlock the bootloader on the clock by running:
python mtk.py da seccfg unlock
- Flash the partition layout for the global edition (downloaded from AyraHikari's github) to the clock:
python mtk.py wf {Replace this with the path to gpt_x04g.bin from github} --noreconnect
- Flash the global edition partitions (unzipped from Global Dump ROM Dump_mico_x04g.tar.xz)to the clock:
python mtk.py wl --preloader {Replace this with the path to preloader_mico_x04g.bin from github} --noreconnect {Replace this with the path to the unzipped Global Dump ROM Dump_mico_x04g.tar.xz}
- Flash boot1 from the global edition (from AyraHikari's github) to the clock's preloader:
python mtk.py w preloader {Replace this with the path to the downloaded boot1_for_microx04g.bin} --parttype=boot1 --preloader {Replace this with the path to the downloaded preloader_mico_x04g.bin}
- Erase the userdata, cache, and proinfo on the clock:
python mtk.py e userdata,cache,proinfo
- Write proinfo from your backup to the clock:
python mtk.py w proinfo {Replace this with the path to your backed up original proinfo.bin}
- Reset the clock:
python mtk.py reset
Wait for the clock to fully boot to make sure the flashing worked. It will take some time to boot for the first time (on the order of minutes).
Installing LineageOS on X04G
Installing LineageOS on your X04G is relatively easy (especially compared to going from LX04 -> X04G).
- Unlock the clock's bootloader:
python mtk.py da seccfg unlock
- Flash the superimage
fastboot flash super super.img
- Flash vbmeta:
fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
- Flash the boot image:
fastboot flash boot boot.img
- Reboot
fastboot reboot
Depending on various OS vagaries, you may need to manually set the clock to fastboot mode. Do so by:
- Hold down the volume up and down buttons while you connect the clock to your computer. You will get to a
No Command
screen. - At the
No Command
screen, hold the Mute button and click the volume up button. Release the Mute button - Use the volume down button to highlight
Enter fastboot
and click the Mute button to selectEnter fastboot
- Use the volume buttons to highlight
Reboot to bootloader
and click the Mute button to select.
The clock will then reboot to fastboot mode and you can run the above commands. You will have to do this before each fastboot command if your computer won't force the clock into fastboot when running the fastboot
command.
Setting up ViewAssist Companion App in LineageOS.
Booting LineageOS
Booting LineageOS on the clock will take a long time and will spend a period of time showing a white box on a black screen. This is expected.
LineageOS Settings
There are a few settings that you should modify to expand the screen real-estate and enable ADB.
Change screen size
- Open Settings > Display > Display size and text and set Display size so that the slider is all the way to the left.
Enable ADB
- Open Settings > About device, scroll down to Build number and tap it until it says you're a Developer
- Open Settings > System > Developer options, scroll down to USB debugging and disable and enable it so you have ADB enabled over USB.
Install the VACA app
- From your computer while connected to the clock:
adb install {Replace this with the path to the VACA app}
Set up VACA in Home Assistant
- Adopt the VACA install on the Smart Clock in Home Assistant.
- Set the gain as appropriate to your environment; I have set it to 0.
- Set the wake word threshold as appropriate to your environment; I have it set to 8.
You're done!
Enjoy!