xiaoai-patch README

The project's README from github.com/duhow/xiaoai-patch. As one markdown file: README.md.

XiaoAi Speakers

XiaoAi Speakers patched


This repo contains custom scripts and patches, to make a custom rootfs image free of propietary software, and installing open source programs.
Patches and scripts can be tweaked, so if really want, you can keep the original functions of the Chinese XiaoAi assistant, and install new programs as well.

The main purpose of this toolset is to have your DIY Voice Assistant (Alexa-like) and Smart Speaker, with lots of integrations for music and automation.

By using MPD, Snapcast, Shairport-Sync, Upmpdcli, Squeezelite, you can make your speaker a full media player compatible with multiple cast protocols, and also have a voice assistant powered by Porcupine and Whisper that can interact with your Home Assistant.
Everything powered by Open Source Software!

Compatibility

🛒 The page contains affiliated links, if you would like to purchase the speaker and support this project, feel free to use it!

Model Name Target version
LX06 - supported 🛒 Xiaoai Speaker Pro (black, infrared) ⭐📝 1.74.10
L06A - supported 🛒 Xiaoai Speaker (white, no infrared) 📝 1.74.10
LX01 - supported Xiaomi Mi AI Speaker Mini 1.32.6
L09A - supported Xiaoai Speaker Art (China, white) 1.76.4
L09B - supported Xiaoai Speaker Art Battery (Black) - untested 1.69.54
L09G - not supported Xiaomi Mi Smart Speaker (Global, Google Assistant)
LX05 - encrypted, supported 🛒 Xiaoai Speaker Play 🔐
L05B - not supported Xiaoai Speaker Play Enhanced Edition, no Clock LED (NuttX) - details
L05C - not supported 🛒 Xiaoai Speaker Play Enhanced Edition, with Clock LED (NuttX)
L05G - not supported Xiaomi Smart Speaker IR Control (Global, Google Assistant)
L15A - encrypted, not fully supported 🛒 Xiaomi Mi AI Speaker 2 Gen 🔐
L16A - not tested 🛒 Xiaomi Sound by HARMAN AudioEFX
L17A - not tested 🛒 Xiaomi Sound Pro
L07A - not tested Redmi XiaoAI Speaker Play
M03A - not tested Xiaomi Sound Move
MDZ-25-DT - not tested Xiaomi Mi AI Speaker 1 Gen (?) - S12
XMYX01JY - not tested Xiaomi XiaoAI HD
YLAI01YL - blocked (not tested) Yeelight Voice Control Assistant

🔐 Encrypted speaker partitions

Some speakers such as LX05 or L15A, change the rootfs partition and include a DER certificate to verify the system. This may block any changes on non-signed squashfs. Recommended to NOT flash, you may have an invalid rootfs and potentially lock yourself! You can check this by running binwalk if it contains a Certificate entry:

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             Squashfs filesystem, little endian, version 4.0, compression:xz, size: 32240378 bytes,
                              2430 inodes, blocksize: 262144 bytes, created: 2021-04-28 06:34:34
32243716      0x1EC0004       Certificate in DER format (x509 v3), header length: 4, sequence length: 830

Requirements

[!WARNING]
Supported and Tested setup is Linux OS with amd64 arch. Other hosts (Apple M1, Windows) are not tested nor supported. Feel free to make a PR if you have a fix for this.

[!IMPORTANT]
If using WSL, be sure to enable setCaseSensitiveInfo.

You will also need the following tools:

Usage

Get a copy of your rootfs filesystem from your speaker. It can also be from a system upgrade file. It should be something similar as this:

nc -vlp 8888 > $HOME/backup-image
# -----
dd if=/dev/mtd4 of=/tmp/image
nc $IP_ADDR 8888 < /tmp/image

Since the speakers filesystem is read-only format, we have to reflash it to add the new applications and patches. There are three steps to perform this: extract, patch, build.

Optionally but recommended, prepare the packages you want to install by editing the packages.sh script.

Build the docker image and run it to build all the packages. Probably it will take more than an hour.

[!CAUTION]
Run the build packages.sh process with Docker, since the package build performs some patching to the system, otherwise it could harm your GNU/Linux installation.

docker build -t xiaoai-patch packages
docker run -it -v $PWD:/xiaoai xiaoai-patch

You can now run the commands to prepare the new image.

sudo make clean
sudo make extract FILE=image-mtd4
sudo make patch MODEL=lx06
sudo make build MODEL=lx06

# or all at once :)
sudo make clean all FILE=image-mtd4 MODEL=lx06

[!TIP]
Ensure the image format is correct, by comparing the original and new images. Use file or other commands to check info.

After you have the new image ready, send it to the speaker, and flash the not-in-use rootfs partition, boot it and test.

:warning: Unbricking

You should have some wires soldered to the board to perform TTL in case it is required.
As long as you perform steps as described and not flashing content in wrong partitions, you can reverse failed boot with Uboot safely.

In order to enable Uboot menu, check in the environment partition that you have the setting bootdelay=3.
If is set to bootdelay=0 then Uboot will continue normal boot process and you won't be able to stop it unless you get into fastboot or recovery mode. (?)
In most cases, binary program is fw_setenv or fw_env and data is set into first partition as string.

Ensure you can access Uboot before writing changes, it is your rescue!

Hit any key to stop autoboot:  0

DISCLAIMER

YOU are responsible for any use or damage this software may cause. This repo and its content is intended for educational purposes only. Use at your own risk.

xiaoai-patch (duhow/xiaoai-patch)

personal-assistant
Searching Database…

What is this?A patching toolkit for XiaoAi smart speakers (小爱音箱) that strips proprietary software from the rootfs and installs open source programs, turning the stock speaker into a DIY voice assistant and media player.
Is this a flashable firmware patch or a standalone app?It is a custom firmware/rootfs patching toolset: you extract your speaker's existing rootfs image, patch it with new packages, rebuild it with Docker, then flash it back onto the speaker's unused partition.
How do I patch my speaker?Dump the rootfs filesystem from the speaker (or a system upgrade file), optionally edit packages.sh to choose what to install, then build the Docker image and run it to compile all packages before flashing the resulting image to the inactive rootfs partition.
What tools do I need on my build machine?You need squashfs-tools, mtd-utils (only for the S12 model), make, rsync, shasum and Docker; the build is only supported on Linux amd64, and WSL users must enable setCaseSensitiveInfo.
Is every speaker model safe to flash?No — models like LX05 and L15A use encrypted rootfs partitions with a certificate check, so flashing them is not recommended because it can brick the device; several other models are untested or not supported at all.
Which speaker models actually work with this?LX06 and L06A (Xiaoai Speaker Pro) are the main supported targets, with LX01 and L09A also supported; many other models like L09G, L05B/C/G and L15A are listed as not supported, untested, or blocked.
Can I build the patches from macOS or Windows?No, the build process is only tested and supported on Linux with amd64 architecture; Apple M1 and Windows hosts are not tested or supported.
What open source software gets installed on the speaker?Packages like MPD, Snapcast, Shairport-Sync, Upmpdcli and Squeezelite turn the speaker into a multi-protocol media player, while Porcupine and Whisper power a voice assistant that can talk to Home Assistant.
What happens if I brick my speaker during flashing?You can recover via U-Boot as long as you don't flash the wrong partitions; you need wires soldered to the board for TTL access and must ensure bootdelay is set to 3 so you can interrupt the boot process.
Can I keep the original Chinese XiaoAi assistant after patching?Yes, the patches and scripts are tweakable so you can retain the stock XiaoAi assistant functions while adding the new open source programs alongside it.
How long does building the firmware take?Building all the packages through the provided Docker image takes more than an hour, so patience is required.
Creator
duhow
Size
18.2 MB
Stars
781
Age
5y
Commits · 90 Days