Jump to content

Xiaomi Mi Box 3 (xiaomi-once)

From postmarketOS Wiki
Note pmOS can't run on its internal storage.However, it's possible to boot pmOS from USB Stick.
Note This device is supported as part of a generic port. Refer to Amlogic Generic TV Box (amlogic-tvbox) for installation instructions and more information.
Xiaomi Mi Box 3
Running XFCE4
Running XFCE4
Manufacturer Xiaomi
Name Mi Box 3
Codename xiaomi-once
Released 20XX
Type set-top box
Hardware
Chipset Amlogic S905X-H
CPU Quad-core 1.5 GHz Cortex-A53
GPU Mali-450 MP3
Display HDMI
Storage 4/8 GB
Memory 1/2 GB
Architecture aarch64
Software
Original software
The software and version the device was shipped with.
Android (TV) 6.0.1
Extended version
The most recent supported version from the manufacturer.
Android (TV) 9
Optional software MIUI TV
FOSS bootloader yes
postmarketOS
Category testing
Mainline
Instead of a Linux kernel fork, it is possible to run (Close to) Mainline.
yes
Generic port Amlogic Generic TV Box (amlogic-tvbox)
Device package device-amlogic-tvbox out-of-tree
Kernel package linux-postmarketos-amlogic
Features
Flashing
Whether it is possible to flash the device with pmbootstrap flasher.
Broken
USB Networking
After connecting the device with USB to your PC, you can connect to it via telnet (initramfs) or SSH (booted system).
Untested
Screen
Whether the display works; ideally with sleep mode and brightness control.
Works
Multimedia
3D Acceleration
Works
Audio
Audio playback, microphone, headset and buttons.
Partial
IR TX
Works
Connectivity
WiFi
Works
Bluetooth
Works
Miscellaneous
FDE
Full disk encryption and unlocking with unl0kr.
Untested
USB OTG
USB On-The-Go or USB-C Role switching.
Untested
HDMI/DP
Video and audio output with HDMI or DisplayPort.
Partial
Sensors
Power Sensor
Sensor to monitor current, voltage and power. Not fuel gauge!
Untested
Note This port is only tested on the mdz-16-ab variant. If you get it working on the mdz-16-aa variant then please let us know. Thanks!

This port has been dropped from postmarketOS repos. It may be re-added at a later time if someone steps up. In the meantime, use the generic Amlogic reference board port.

There are 2 variants:

  • Mi Box 3/mdz-16-ab, running Android TV and sold everywhere else, this one can be intercepted on boot using a UART adapter if it is running android 8.
  • Mi Box 3C/mdz-16-aa, running MIUI TV and sold in China. Seems to only have 4GB of storage and 1GB of RAM, this one might be able to be intercepted on boot, although with limited success.

Some people succeeded at flashing the mdz-16-ab firmware to an mdz-16-aa set-top box though.

Note that these instructions are only expected to work on the mda-16-ab variant.

Note about the stock u-boot

If running Android 8/7/6

It can be intercepted when it is booting.

It will load either aml_autoscript (more info) or recovery.img (android recovery mode image), both at the root of a USB stick, the latter being booted when Android TV and the recovery mode aren't bootable.

If running Android 9

You can not intercept the Mi Box while booting.

In order to install postmarketOS on a Mi Box currently running android 9, follow the guide for #Downgrading from Android 9 to Android 8.

Installation

Warning WARNING: DO NOT PLUG multiple USB stick to the TV box when it boots.If you do have multiple USB stick plugged in during boot, please make sure the usb 0 in u boot is the pm os usb stick.
Warning WARNING: DO NOT PLUG USB drives that had pmOS installed to the TV box when it boots into Android because Android will destroy file permissions!
Note A UART-to-TTY adapter is required to intercept U-Boot, alternative methods have not been worked out yet.
Note This guide requires pmbootstrap, you will need a device running a linux operating system to use it. (see pmbootstrap/Installation)

Before doing everything here, please follow the instructions in #Downgrading from Android 9 to Android 8 if your Mi Box is currently running Android 9.

Only installing to a USB drive works currently.

Follow instructions in Amlogic Generic AArch64 TV Box (amlogic-aarch64-tvbox) to put pmOS on a USB stick, select device "p241".

Note plasma-desktop (among other Wayland-based desktops) will most likely never work with the Mi Box, XFCE4 is recommended.

After you created the image, connect the UART and USB to your Mi Box (refer to the image on the right of the page, note that a shared ground connection may be required, which can be achieved by connecting ground to the metal heat shield).

Next, intercept U-Boot when it's booting using your UART adapter, you should get a shell.

Note U-Boot will run commands that are saved in the bootcmd environment variable. By default bootcmd contains commands to load Android TV.

Run the following commands to modify the default boot behavior for making pmOS automatically boot when it powered on and a pm os usb stick is pluged in:

once# setenv bootandroid "${bootcmd}"
once# setenv bootcmd "usb start;ext4load usb 0:1 ${loadaddr} aml_autoscript;autoscr ${loadaddr};run bootandroid"
once# saveenv

Run those command to reboot after you have modified the default boot behavior

once# reset

You can still boot into android by unplugging the pmOS usb stick after you have modify the default boot behavior, you should NEVER have your USB drive plugged into the Mi Box if you're booting android as this destroys file permissions, you should also refrain from updating to Android 9 as this may stop you from intercepting boot.

You can manually boot pmOS if you dont want to modify the default boot behavior.

Run these commands to boot pmOS:

once# usb start
once# ext4load usb 0:1 ${loadaddr} aml_autoscript
once# autoscr ${loadaddr}

Downgrading from Android 9 to Android 8

Warning WARNING: THIS WILL ERASE ALL DATA ON YOUR MI BOX. CONSIDER YOURSELF WARNED.
Warning WARNING: DO NOT PLUG USB DRIVE BEFORE RECOVERY MODE IS ON IN STEP 3

There's a guide for downgrading from Android 9 to 8: https://forum.xda-developers.com/t/mi-box-3-mdz-16-ab-downgrade-android-9-pie-to-android-8-oreo.4194075/

If that guide doesn't work, try this:

Warning WARNING: DO NOT unplug the Mi Box from it's power connector or the USB drive until the update is complete, otherwise you may brick your device.
  1. Plug a USB drive into your computer and format it as FAT32
  2. Download via BitTorrent or MEGA
  3. Extract update.zip and xiaomi_update from the zip file, as well as recovery.img from update.zip and put them at the root of your USB drive
  4. Power your Mi Box on and boot it into the recovery mode
  5. Plug your USB drive to it
  6. 'Apply update from EXT' > 'From Udisk' > update.zip (note: "Udisk" is a translation error in the recovery)
  7. Flash and reboot! Your Mi Box should reboot a few times. You should see a progress bar after that. (It only flashed U-Boot, and Android 9 isn't bootable from it, and thus it loads recovery.img from the USB drive, which runs xiaomi_update)
  8. After that, it's going to boot into Android 8, which will fail. It's then going to boot into recovery mode and you should see the following error message: "Cannot load Android system. Your data may be corrupt. If you continue to get this message, you may need to perform a factory data reset and erase all user data stored on this device."
  9. 'Factory data reset' > 'Yes'
  10. Then it should reboot automatically by itself
  11. Done!

Recover back to the default booting behavior

Run these commands:

once# setenv bootcmd ${bootandroid}
once# setenv bootandroid 
once# saveenv

Recovery

The following instructions would show a wobble circle with a progress bar.

Warning WARNING: This might cause your device to be in a state of endless bootloop

Boot into recovery mode

  1. Unplug power from Mi Box 3
  2. Remove batteries from remote control
  3. Press and hold middle select button + back button on the remote
  4. While holding select+back, put batteries back in remote
  5. Reconnect power to the Mi Box 3
  6. Hold the remote close to the Mi Box 3 and wait for recovery screen

Source: https://l.opnxng.com/r/AndroidTV/comments/g3mw3s/xiaomi_mi_box_3_reboot_into_recovery_mode

Unlocking the bootlocker

This device has a locked bootloader (It seems only mda-16-ab have this kind of bootloader) and thus, can only run Xiaomi signed images.

exkc found out the Mi Box can chainboot an unlocked bootloader from the locked bootloader via "multiboot" mode. There has been some work on unlocking the android 6 bootloader which could allow you to boot an unsigned boot image directly from the stock bootloader, however this work has not been made publicly available.

Maintainer

Users owning this device

  • Ceater (Notes: Boots, can downgrade to android 8.0 Oreo, does not own a UART to USB adapter.)
  • Lotigara (Notes: Can boot pmOS from USB flash by setting 'bootcmd' to 'run recovery_from_udisk')
  • Weeweezzz

See also