Boot Chain, Dynamic Partitions & Tiered Storage
Running OpenHarmony cleanly on modern Android GKI 6.x A/B hardware requires bridging the device's stock bootloader and super dynamic partition layout into OpenHarmony's two-stage switch_root initialization chain without touching low-level boot firmware.
1. Two-Stage init_boot to switch_root Pipeline
Stage-1 PID1 (UniOHOS/core/early-bringup)
init_boot_{a,b} carries the first-stage ramdisk and modular PID1 router (stage1-init):
- Early Pseudo-Filesystems & Permissions: Mounts
/proc,/sys, and/dev, explicitly settingchmod 0755 /dev(and socket directories) so non-root OpenHarmony services never hitEACCESon Unix domain sockets. - Solderless Early Diagnostics:
- Initializes a persistent ring buffer at a reserved offset in
misc(e.g.,misc+0x1000, leaving standard BCB untouched) to capture/dev/kmsgand PID1 checkpoints across panics or watchdog resets. - Starts
usb-udc-guardto bring up ConfigFSUSB ACM(/dev/ttyACM0) andhdcearly without physical UART soldering.
- Initializes a persistent ring buffer at a reserved offset in
- Dynamic Partition Mapping (
super/liblp/dm-linear):- Reads AOSP LP metadata headers from the physical
superblock device and creates/dev/block/mapper/*dm-lineartargets for the active target slot (system_b,vendor_b,sys_prod_b,chip_prod_b,odm_b,*_dlkm_b).
- Reads AOSP LP metadata headers from the physical
- Early Kernel Module Closure:
- Loads required early
.komodules fromvendor_bootin topological dependency order, treatingEEXIST(already loaded) as non-fatal so watchdog and storage drivers always initialize cleanly.
- Loads required early
- Staging Mount &
switch_root:- Mounts the OpenHarmony root filesystem onto
/usr(OpenHarmony's standard staging mountpoint), appliesfstab.required, verifies critical modem/calibration partitions remainro,norecovery, and executes:textswitch_root /usr /bin/init --second-stage
- Mounts the OpenHarmony root filesystem onto
Stage-2 OpenHarmony Init
Once /bin/init --second-stage takes over as PID1 inside Musl userland, it mounts /system, /vendor, /sys_prod, /chip_prod, and /data, brings up samgr, hilogd, hdf_devmgr, and hdcd, and triggers graphics and isolated Sidecar services.
2. Tiered Read-Only EROFS & 64KB PTE_CONT Alignment
Read-only system partitions (system, vendor, sys_prod, chip_prod, odm) use EROFS (LZ4, LZ4HC, or ZSTD):
- Tier-0 Hot Shared Libraries (
tier0-preload.txt): High-frequency cold-boot libraries (such aslibrender_service.z.so,libace_compatible.z.so,libipc_single.z.so, and display VDIs) can be packed uncompressed (FLAT_PLAIN) and aligned on64KBboundaries (16 x 4KBblocks) viaUniOHOS/builder/fs-tools/tools/erofs_v2_64k_packer.py. - ARM64
PTE_CONTCoalescing: On 4KB-page ARM64 kernels with large folios,64KB-aligned hot text/code mappings enablePTE_CONTcontiguous TLB entries (1 TLB entry covering 16x 4KB pages), reducing cold-start iTLB pressure. - Deterministic Offline Verification:
fs-toolsvalidates every packed image via unmodifiedfsck.erofs --extractSHA-256 roundtrip matching and deterministic two-round builds (R1 == R2).
3. Native F2FS /data with Lightweight HMFS ioctl Compatibility
Instead of requiring destructive conversion of /data to a proprietary filesystem format, UniOHOS keeps the device's native Linux F2FS partition and adds a lightweight HMFS ioctl compatibility patch (0xf5xx, matching UniOHOS/builder/fs-tools/tools/hmfs_ioctl_compat.h) inside the GPL-2.0-only kernel patch stack (patches/20-hmos/). This preserves full native F2FS tooling, fscrypt support, and recovery compatibility.