完美设备
The Perfect Device

原始链接: https://sometimes.digital/posts/the-perfect-device/

## “本地家居”实验:破解小米智能时钟 这次探索源于希望利用“云”的实用功能——特别是本地运行设备的能力——而无需完全采用智能家居生态系统。作者发现了一个有希望的候选者:小米智能时钟,本质上是一款没有电池的Android手机,具有方便的外形。 虽然全球版本受到Google服务集成的限制,但这款时钟是可以破解的。使用MTKClient和Lineage OS等工具,可以将其从这些限制中解放出来。这个过程并不简单,由于最近的仓库清理,变得复杂,并且需要Windows和Linux方面的专业知识。 一旦破解,时钟就会变成一个多功能的控制面板。作者成功安装了音乐流媒体应用程序(通过Tempus的Navidrome)、安全的网络访问(Tailscale)和自定义应用程序(Peristyle、SystemUI Tuner)。潜在用途扩展到数字相框、厨房显示屏,甚至本地数据(如公交时刻表或传感器读数)的仪表盘。尽管硬件存在限制(无法维修的外壳),但该项目展示了夺回对日常设备控制权的潜力。

黑客新闻 新的 | 过去的 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 完美设备 (sometimes.digital) 3 分,由 surprisetalk 1小时前发布 | 隐藏 | 过去的 | 收藏 | 讨论 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

The Perfect Device

I promise, I am not setting up a smart home. The Wi-Fi kettle was a gift, and I haven’t connected it to the Internet anyway. But I have been curious what The Cloud has to offer. I have been dabbling. I’m not a fan of most of it, but some features are really cool: for example, the infamous Tuya devices can fully run on a local network, without any outside traffic. So I am not setting up a smart home, but I may be setting up a localhost home, as Tomoe called it.

And recently I found an almost perfect device that, after a little bit of hacking, can be very useful as a control panel of sorts for this self-hosted set-up: the Xiaomi Smart Clock. It is basically an Android phone without a battery, but the form factor makes it quite convenient. The lack of a battery has its upsides (don’t need to worry about it), but also downsides (it’s tethered to a power socket). I’m not really serious about it being perfect: while the firmware is hackable, the hardware is just impossible to repair, the casing all glued together and seemingly quite brittle. Still, I found it interesting enough.

I like the idea of a clock being smart. All clocks are smart, in a way. Who really knows how those crystals inside actually work?

There are two versions of this device, one for the Chinese market, and one for the global one. Here is a video that compares their functions. The Chinese version seems to have more features, and works with other Xiaomi devices. The global one is heavily integrated with Google Home and Google Assistant – this makes it incompatible with other Xiaomi devices. On the global version, you can play videos, but only with Chromecast, and you can play music, but only with YouTube Music or Spotify.

So, this device is pretty dumb actually, by default, for the reasons of capitalist greed. A prisoner of the shareholders’ interest. Thankfully, hackers have freed it.

For those trying tho hack their Xiaomi Smart Clocks, the starting point will probably be this forum thread on XDA. The author of the thread posted the Lineage OS image and the instructions on how to flash it. The instructions could be a little clearer, so some of the responders in the thread felt obligated to post their own process, each of them a little different. They all probably thought that they can write their own one clear and definitive guide to getting this thing to work. I thought that too, but I now know that such guide is simply impossible…

The guide features a tool called MTKClient. It is a flashing tool for devices based on MediaTek SOCs that uses exploits in the chips to edit partitions on the device. Many Android devices are based on these chips, so it seems fairly popular in the Android hacking community. It can be used to back up the original firmware, disable security locks, and install alternative firmware. There exists an hour long YouTube video made by the author of the tool in which he explains how it all works. Back when the AI assistant devices were all the hype, some sources reported that this exploit can be used to hack Rabbit r1s.

Unfortunately, just as my clock finally arrived from Italy on 21st of January, I realised that three days prior the mtkclient repo had been wiped and replaced with a couple of new commits containing a new version. Not only is the whole commit history gone, but also all the discussions in GitHub issues, which, based on the cached previews in search results, seemed pretty helpful. My first thought was, was the hacker hacked himself? But the more realistic possibility is that, for whatever reason, he just deleted the old repository and created a new one. Some issues have been archived by Wayback Machine though, so the lucky ones will still find the answers to their questions archived.

The new version caused some issues for me, so I eventually used a fork with an older version.

I use Linux, by the way. For a while now I have been using Linux Mint. More often for online shopping than programming these days, but still. Everything just works on Linux, you know? Except for this clock. It just doesn’t see it. I must be missing a driver of some kind. I’m glad I didn’t delete the Windows partition, even though it has felt like dead wood (until now).

Here are the official instructions, including steps for Windows, Linux, and macOS.
For Windows, here’s what I downloaded and installed (listed in the order of installation):

  1. Backup the stock firmware: python mtk.py rf xiaomi_smart_clock_firmware.bin

The program will say that it is waiting for a device to be connected. Hold the volume up and down buttons and connect the device. Keep them pressed until the program displays progress bars indicating that the firmware is being read and saved. On my computer, the backup took around 15 minutes and the backed up firmware was around 4GB.

  1. Erase partitions: python mtk.py e metadata,userdata,md_udc

  2. Unlock the bootloader: python mtk.py da seccfg unlock

  3. Reboot the device: python mtk.py reset

The reboot was the last step that used mtkclient, so I hoped things would go smoother after that.
  1. Flash the boot partition: fastboot flash boot boot.img
  2. The guide on XDA says to first enter the bootloader on the device and then run the fastboot command, but what worked for me was first running the command, having it wait for a connection, and then connecting the device:

    1. Press and hold all three upper buttons.
    2. Connect the device to the computer.
    3. After 5 seconds release the middle button while still holding the other two buttons pressed.
    4. When the "No command" screen shows up:
      1. release the other buttons,
      2. press and hold the middle button,
      3. and press the volume up button once.
    5. Once the recovery menu screen shows up, release the middle button and select "Reboot to bootloader".
Not that!
  1. Flash the super partition: fastboot flash super super.img
  2. Flash the vbmeta partition fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
  3. Run fastboot reboot

The device should boot for around 5 minutes with many scary screens showing up in the process. This will be the case each time the device is rebooted from now on.

all signs of success

Eventually the device should boot up. The scale will not be set properly at first, so the first impression may not be the best. This can be fixed later in the UI settings. As far as I can tell, all modules work properly on Lineage OS: the touchscreen, Bluetooh, Wi-Fi, the light sensor, the microphone, and the speaker. The only issue was with the Wi-Fi: if the network is secured with WPA2/WPA3, the Wi-Fi won’t connect. The security setting has to be explicitly set to WPA2.

Welcom

My main goal for this device was to have it working as an easy to use music player for Navidrome. The quality of the speaker is not amazing, but it is good enough for me to play music on a Sunday morning. It could be also used with a Bluetooth speaker, if someone would want to do that. I installed Tempus, a Navidrome client, and was surprised how well it synced with the library.

I installed Tailscale – this was especially useful since the clock runs on its own WPA2 network and without Tailscale it wouldn’t be able to access the main one with WPA2/WPA3.

Tailscale is not optimized for the landscape view and each time I opened the app it would permanently rotate the UI into portrait mode. To lock the landscape view I installed SystemUI Tuner, a tool for viewing and modifying hidden settings. I also used it to hide status bar icons.

To manage installed apps, I installed an F-Droid client called Droid-ify.

To turn the light on and off (more about that in a while), I installed HTTP Shortcuts and created shortcuts that silently run HTTP requests.

I installed Peristyle, a live wallpaper manager, and set it up to cycle through holiday photos like a digital photo frame.

I also installed Chrono, a clock app, and Clima, a weather app.

What other things could one do with it? Obviously it could run Doom, no point in saying that. I like that it kind of looks a toy CRT monitor – it would be fairly funny to bring it to a coffee shop with a wireless keyboard and a mouse and get some work done. I can imagine having this little device set up in the kitchen area, as a sort of little TV, or to display recipes. The simple design could also be good for the elderly, especially since it could be used to make calls (through the Internet). Maybe a dashboard with temperature and air quality sensors? Or the statuses of ordered packages? Tomoe uses the local bus API to fetch information about buses departing from the nearby bus station – that’s something that would be cool to have at hand. Some people put Home Assistant on it, which could also work.

联系我们 contact @ memedata.com