Publish Platina Linux source base for Xiaomi Mi 8 Lite

This commit is contained in:
Sukecz
2026-10-23 11:10:29 +02:00
commit b7eb4289b7
95 changed files with 275710 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
# Building Platina Linux
This is a source-only development port. The candidate kernel builds, but the new
integrated Tianma display still needs its first successful physical boot test.
An image built here is a candidate, not a ready-made stable release.
## Build host
Use Linux, Python 3.11+, Git, Make, a POSIX shell and sudo. The build creates
pmbootstrap chroots and needs Internet access, substantial disk space and time.
It uses two jobs at nice level 10. No host services or phones are restarted.
On Debian/Ubuntu, typical host tools are:
```sh
sudo apt install git python3 make sudo openssh-client e2fsprogs util-linux kmod mtools fastboot
# Optional: only needed for make splash / custom image conversion.
sudo apt install python3-pil fonts-dejavu-core
```
`make doctor` reports missing core tools without installing them. Kernel compilers
and package dependencies are installed inside the build chroots by pmbootstrap.
Python's standard library is enough for the basic offline test suite; image
conversion uses Pillow on the build host.
## Personal build inputs
```sh
mkdir -p config
cp /PATH/TO/YOUR/ADMINISTRATOR-KEY.pub config/admin-builder.pub
```
Use a dedicated key if appropriate. Only its **public** half enters the image.
The user account is `server`, with passwordless sudo for administration. Password
and root SSH login are disabled. Keep the private key outside this repository.
Firmware is not distributed here. From a legally obtained matching stock ROM,
extract `images/NON-HLOS.bin` without running any ROM scripts, and obtain the
matching `a512_zap.elf` GPU firmware from your own vendor firmware. The pinned
reference is the Mi 8 Lite global stock firmware V12.0.3.0.QDTMIXM; other inputs
are rejected if their hashes differ.
The recipe expects three local inputs: `a512_zap.elf`,
`firmware-xiaomi-platina-bdwlan.tar.gz` and `firmware-xiaomi-platina-modem.tar.gz`.
The helper reads the FAT firmware image with mtools, creates deterministic
archives and checks all three against the recipe before writing them:
```sh
python3 scripts/prepare-firmware.py \
--modem-image /PATH/TO/NON-HLOS.bin \
--gpu-firmware /PATH/TO/a512_zap.elf
```
The output is `config/firmware/`, which is ignored by Git. Missing matching
firmware is a build prerequisite; this repository does not silently substitute
another phone's calibration, modem firmware or administrator key.
## Prepare and compile
```sh
make check
./scripts/project prepare --profile candidate --fetch
make kernel PROFILE=candidate
make images OUTPUT=candidate-local
make verify DIR=artifacts/candidate-local
make audit DIR=artifacts/candidate-local
```
Preparation pins pmbootstrap, pmaports and its channel table from
`project/sources.lock.json`. It creates a new managed checkout and refuses to
overwrite one. After changing a versioned recipe, run `make sync` before rebuilding.
Checksum checks parse APKBUILD as text rather than executing its shell on the host.
The image contains the public key and proprietary firmware you provided. It is
therefore **your local installation image**, not automatically a public artifact.
The builder stops pmbootstrap mounts before copying/hashing filesystem images.
Source revisions are pinned, but external Alpine repositories/toolchain packages
are not fully frozen; bit-for-bit reproducible full builds are not promised.
## Scope initramfs module indexes
The mkinitfs version used by this port can copy full-rootfs module indexes into
an initramfs containing only some modules. Before booting or flashing, regenerate
indexes for the modules that are actually included:
```sh
python3 scripts/scope-initramfs-modules.py artifacts/candidate-local/boot.img \
--release 7.2.12-sdm660 --output artifacts/candidate-local-scoped
make verify DIR=artifacts/candidate-local-scoped
```
Use **candidate-local-scoped/boot.img** with **candidate-local/xiaomi-platina.img**.
The scoping tool preserves the kernel, DTB and rootfs command line; it does not
create a second root filesystem and does not flash anything.
Exported files include boot.img, xiaomi-platina.img, initramfs, kernel and DTB.
Keep the manifest and corresponding APKs for your own rollback records.
## Optional display assets
```sh
make splash
python3 scripts/prepare-display-frame.py your-image.png --output artifacts/custom-frame
```
The original logo is preserved; the integration version is added during rendering.
These commands create local bundles. `make images` does not yet install the
versioned splash bundle automatically; see [display setup](DISPLAY.md).
+88
View File
@@ -0,0 +1,88 @@
# Platina display support
The tested Mi 8 Lite has a **Tianma NT36672A 1080 × 2280** panel. Display support
has two separate states:
| State | Status |
|---|---|
| Integration 0.1.1 logo with a temporary LCD power/wake helper | 🟢 Physically verified, including automatic start and subsequent backlight shutdown |
| Integrated driver / DT in kernel 7.2.12-r1 | 🟠 Compiled and audited offline; physical boot and power cycles pending |
The candidate is in `ports/candidate/linux-postmarketos-qcom-sdm660/0030-platina-tianma-panel.patch`.
It adds the panel-specific command sequence, correct regulator names, reset timing,
DT binding and initialization-error cleanup to the NT36672A driver. The stock
command sequence is recorded in `project/display/tianma-reference.json` and
compared by offline tests. This is not a verified BOE TD4320 configuration.
## Optional controller setup
After testing a successful boot with the integrated driver, install the renderer
and controller on **your phone**. The files listed below are source files from
this repository; transfer them using your own authenticated SSH connection.
```sh
# On the phone, from the directory to which you transferred these scripts:
sudo install -m755 phone-splash.py /usr/local/sbin/platina-splash
sudo install -m755 phone-display.py /usr/local/sbin/platina-display
```
For the logo, run `make splash` on the build host. Transfer its three runtime files
`release.json`, `version` and `frame.bgrx.gz` from `artifacts/platina-linux-0.1.1/`
into a new phone directory `/usr/local/share/platina/releases/0.1.1/`, then create
`/usr/local/share/platina/current` pointing to `releases/0.1.1`. If updating an
existing setup, back up its assets/hook first and use a new versioned directory.
The phone renderer uses Python's standard library, without Pillow or a desktop.
```sh
sudo platina-display status
sudo platina-display on --brightness 25
sudo platina-display brightness --brightness 10
sudo platina-display off
sudo platina-display show --seconds 7
sudo platina-display show --directory /PATH/TO/CUSTOM-FRAME --seconds 60
```
`status` only reads sysfs. Changes require root and the actual bound Tianma driver;
the tool refuses the old panel-simple driver or a simultaneously loaded temporary
DCS helper. `on` keeps the current framebuffer visible until `off` is requested;
it may show the console. `show` is bounded to one hour and turns the panel off on
completion, ordinary error, SIGTERM or Ctrl-C. Display operations share the splash
lock. An external SIGKILL cannot run Python cleanup.
`off` requests `FB_BLANK_POWERDOWN` through DRM after clearing the backlight.
A brightness value of zero alone is not proof that the LCD rails are powered off.
Regulator counts and actual repeated wake behavior must be checked on the device.
Prepare another image on the build host:
```sh
python3 scripts/prepare-display-frame.py picture.png --output artifacts/custom-frame
```
The converter preserves aspect ratio, adds black padding and produces a preview,
BGRX framebuffer data and a checksum manifest. Transfer the generated frame bundle
separately; this command does not contact the phone.
## Boot logo
The optional `phone-headless.start` hook starts the logo in the background for
seven seconds, with a timeout and cleanup. On the integrated panel it selects the
new controller. On the old boot it selects the temporary session only when that
kernel-specific module was explicitly installed. Do not install the old helper
blindly, or auto-load it alongside the integrated driver.
Only install the hook after manual rendering and powerdown have worked. The
current clean-image builder keeps the backlight dark and does not automatically
install a generated splash bundle. SSH must remain independent of splash success.
## Hardware acceptance
Confirm the picture physically, test several brightness values and at least ten
off/on cycles, inspect DRM/DCS/kernel errors and compare regulator state before
and after. Verify normal reboot, logo timeout, SSH and temperature/charging.
Measured power savings are a separate result; they have not been established.
Do not live-unbind/rebind the MSM DRM stack: a previous attempt caused an Oops.
For future dashboards the same frame format can carry status screens. Animations
or interactive UIs can later use standard DRM/KMS or a Wayland client after the
panel lifecycle works reliably. Touchscreen support remains a separate porting task.
+19
View File
@@ -0,0 +1,19 @@
# Xiaomi Mi 8 Lite / platina hardware
The target is **Xiaomi Mi 8 Lite**, codename **platina**, Qualcomm **Snapdragon 660
(SDM660)**, ARM64. Maintainer tests used model **M1808D2TG**, 4 GB RAM and 64 GB eMMC.
Verify your own device; its marketing name alone does not identify the board.
The tested LCD is **Tianma NT36672A**, 1080 × 2280. The original community port
selected a BOE TD4320 descriptor. Those panels are not interchangeable merely
because their resolution matches. The current source candidate changes the DT
to the tested Tianma variant. BOE devices require their own configuration and test.
The device package uses USB network gadget mode and NetworkManager. Charging
behavior depends on the cable, host port and charger. Test the chosen supply
under the intended load; a visible charge indicator is not a sustained power test.
The phone has to stay awake for this headless-server use case.
Before repurposing an older phone, inspect its battery and check its storage
health. Keep a recovery route through the unlocked bootloader and Fastboot.
See the [feature matrix](../README.md#feature-status) for actual support status.
+145
View File
@@ -0,0 +1,145 @@
# Install Linux on Xiaomi Mi 8 Lite (platina)
**Development port.** The maintainer's existing installation boots and provides
SSH, but the checked-in integrated Tianma display candidate has not yet passed
its physical boot/power-cycle test. There is no supported prebuilt installer.
Build your own images using [BUILDING.md](BUILDING.md).
These steps are for a **fresh installation** on **Mi 8 Lite / platina**.
Flashing `userdata` destroys Android apps and personal data. For an existing Linux
installation, do not follow the userdata step: keep its filesystem UUID and use
a separately prepared boot/module update with a current backup.
## 1. Prepare recovery and identify the device
- Back up your Android data, the original boot/vbmeta images and the phone-specific
partitions needed for recovery, using a method you have actually verified.
Fastboot is not a universal partition-backup tool.
- Retain the matching stock ROM and a working host-side Fastboot recovery path.
Backups may contain identity/calibration data; keep them private.
- Unlock the bootloader through Xiaomi's supported process before installing Linux.
Unlocking itself can erase data. This project supplies no bootloader bypass.
- Check the **platina** codename and **Tianma NT36672A** panel variant.
See [hardware](HARDWARE.md). Do not use the Tianma candidate on an unverified BOE unit.
- Use reliable USB power and a charged, healthy battery. Keep physical access
throughout the first boot and recovery test.
Enter Fastboot with **Volume Down + Power** from power-off. With only the intended
phone attached, inspect it before any write:
```sh
fastboot devices
fastboot getvar product
fastboot oem device-info
fastboot getvar partition-size:boot
fastboot getvar partition-size:userdata
```
Confirm product `platina`, unlocked status and sufficient partition sizes.
The tested Fastboot boot-image limit was `0x3ffc000` bytes. Recheck your device;
a full raw backup of a partition can exceed the maximum accepted image length.
General device/mode information is also in the
[postmarketOS Mi 8 Lite wiki](https://wiki.postmarketos.org/wiki/Xiaomi_Mi_8_Lite_(xiaomi-platina)).
That page may describe a different kernel/port; use this repository's feature
matrix for this integration's support status.
## 2. Build and verify your own image pair
Follow BUILDING.md through the offline audit and module-index scoping stages.
The examples below assume these files exist:
```sh
ROOTFS=artifacts/candidate-local/xiaomi-platina.img
BOOT=artifacts/candidate-local-scoped/boot.img
make verify DIR=artifacts/candidate-local
make verify DIR=artifacts/candidate-local-scoped
```
The boot command line must refer to the UUID of that root filesystem. Do not mix
a newly generated clean rootfs with a boot prepared for another installation.
All exported modules must match the kernel. Archive your build manifest and APKs.
## 3. Fresh rootfs, vbmeta and RAM boot
**The following commands write to the phone. Run them only after completing the
backup, identification and offline checks.** A RAM boot avoids a permanent kernel
write, but it does not undo a preceding userdata or vbmeta write.
```sh
# Permanently replaces Android user data with your local Linux root filesystem.
fastboot -S 128M flash userdata "$ROOTFS"
# Generates and flashes AVB metadata with verification disabled for this port.
./scripts/pmbootstrap flasher flash_vbmeta
# Test the new kernel/initramfs in RAM before writing the boot partition.
fastboot boot "$BOOT"
```
Stop on any error. Do not flash GPT, bootloader, recovery, persist or modem identity
partitions. Leave the bootloader unlocked. The Fastboot `OKAY` message alone
proves neither that Linux booted nor that the display works.
If USB transfer hangs, investigate the host/cable/Fastboot transport before retrying.
Do not replace a failed RAM test with a blind permanent flash. Never unbind/rebind
MSM DRM on a live system as a substitute for booting the correct device tree.
## 4. Establish SSH and Wi-Fi
The phone's USB gadget address is **172.16.42.1/24**, user **server**. Configure the
host side of the identified USB network interface for **172.16.42.2/24**, without
replacing the host's normal default route. Some desktops do not automatically
choose that address. Use your Linux host's normal network manager and configure
only the interface belonging to this phone.
Verify the phone's SSH host key through a trusted local console or a verified
recovery session before recording it in known_hosts. `ssh-keyscan` by itself does
not authenticate the device. Keep strict host-key checking enabled.
```sh
ssh -i /PATH/TO/YOUR/PRIVATE-KEY -o StrictHostKeyChecking=yes server@172.16.42.1
```
The phone's dedicated administrator has passwordless sudo; password and root SSH
login are disabled. Add your Wi-Fi profile interactively on the phone, so the
passphrase does not become a repository file or shell argument:
```sh
sudo nmcli --ask device wifi connect YOUR_WIFI_SSID
ip -brief address show wlan0
```
Use its DHCP address, or `platina.local` where mDNS works. Test a second SSH
session over Wi-Fi before unplugging USB. USB administration does not by itself
provide Internet access: the host must explicitly share a connection if needed.
No router, firewall, forwarding or VPN changes are made by the build tools.
## 5. Validate, then install the boot image
Verify `uname -r`, the root filesystem, OpenRC services, SSH, Wi-Fi reconnect,
charging/temperature and kernel logs. For the new display candidate, require a
visible correct picture and repeated on/off tests; see [DISPLAY.md](DISPLAY.md).
Retain your stock boot and a way to return to Fastboot throughout.
When the RAM boot is successful, return physically to Fastboot and install the
**same tested** boot image:
```sh
fastboot flash boot "$BOOT"
fastboot reboot
```
Confirm a normal eMMC boot and automatic service startup, then test a separate
charger with Wi-Fi. Test long-term stability and charging under the intended
workload before relying on it as a 24/7 server.
## Recovery and future updates
On a failed candidate, return to Fastboot and restore the verified boot image for
the matching installation and module tree. A stock Android boot alone does not
restore Android userdata that has already been replaced. Follow your stock-ROM
recovery procedure if reverting the whole installation.
For later kernel updates, preserve rootfs UUID, pair kernel/modules/initramfs,
back up the active module tree and configuration, and check any package hooks
before installation. Do not automatically install a new kernel from a rolling
repository. Build, offline audit, RAM test and permanent flash are separate steps.
+58
View File
@@ -0,0 +1,58 @@
# Licensing
## Decision
**GPL-2.0-only** is the license for original Platina integration contributions,
including original scripts, tests, documentation and the supplied logo, unless
an individual file specifies otherwise. See [LICENSE](../LICENSE) and [NOTICE](../NOTICE).
The main reason is practical: this is a Linux kernel/device port, and its kernel
patches should remain usable under Linux's GPLv2 terms. This does not mean that
all software running on the phone has to use GPLv2.
| Option considered | Fit for this project |
|---|---|
| MIT | Good for permissive standalone tools; would not remove inherited kernel/copyleft requirements |
| Apache-2.0 | Explicit patent terms, but not compatible with GPL-2.0-only kernel combinations |
| GPL-3.0-only | Useful for many projects; cannot simply replace Linux's GPL-2.0-only terms |
| **GPL-2.0-only** | **Chosen for original integration work and kernel changes; matches the kernel's licensing baseline** |
Sources: [Linux kernel licensing rules](https://docs.kernel.org/process/license-rules.html),
[GNU license compatibility](https://www.gnu.org/licenses/license-list.html), and
[Apache's GPL compatibility explanation](https://apache.org/licenses/GPL-compatibility.html).
## Third-party material keeps its license
This source repository is an aggregate, not a claim that all included components
are one GPLv2 program. Existing copyrights and SPDX notices are retained.
- **Kernel patches/configuration:** kernel GPLv2 terms and relevant per-file SPDX
identifiers. Some files allow later GPL versions or have compatible dual licenses.
- **Inherited pmaports packaging:** GPLv3 where the upstream packaging
license applies. The package's `license=` field describes its installed payload;
it is not by itself a license grant for every packaging script.
- **Device data:** MIT as declared by the community device package, with original
author/maintainer attribution retained. Applicable kernel DT notices still apply.
- **Public firmware recipe and board-index helper:** newly written GPL-2.0-only
source. The public firmware revision is 2-r5 to distinguish this packaging change.
- **Firmware binaries:** proprietary and absent from this Git repository. Each
builder supplies matching inputs locally and must respect their own usage rights.
- **External toolchains/packages:** retain their own licenses; the source repository
does not vendor the full distro or claim ownership of those projects.
The upstream community repository has no blanket top-level LICENSE at the time
of this review. We therefore preserve its explicit kernel/device notices and do
not redistribute its firmware helper under an invented blanket license.
Full attribution and license texts are in NOTICE and LICENSES/.
## Source publication versus image publication
This initial public repository contains source and the project logo. It does not
publish APKs, prebuilt disk/boot images, stock ROMs or device calibration backups.
Building a local image does not automatically grant permission to redistribute
its proprietary firmware, nor make a personalized SSH key/configuration public.
Any future binary release requires a separate component/source and firmware-rights
review. A GPL-covered kernel binary must be accompanied by the corresponding
source and notices under the applicable license terms. Existing third-party
rights are preserved; the repository's project license cannot replace them.