Files
oxmc 918038437b hwinfo: native helper for bootloader and VideoCore versions; memtier: drop awk
pawlet-hwinfo is now a C++ binary. It reads the bootloader git hash and
build-timestamp from the chosen/bootloader device-tree node and queries the
VideoCore firmware revision, hash and variant over the /dev/vcio mailbox.
Both are formatted date-first like vcgencmd/rpi-eeprom-update.

pawlet-memtier reads MemTotal with shell builtins instead of awk, which is
labelled vendor_file and not executable from the memtier domain.
2026-10-13 21:03:23 -07:00

46 lines
1.7 KiB
Bash

#!/vendor/bin/sh
#
# Copyright (C) 2026 oxmc / PawletOS
#
# SPDX-License-Identifier: Apache-2.0
#
# pawlet-memtier: reads actual RAM at early boot and sets a memory tier so a
# single image can self-tune across RAM SKUs (1GB-16GB+) without per-board
# build config. Must run in `on early-init`, before lmkd/zygote start, since
# min_free_kbytes and the dalvik heap props are read once at process start
# and effectively immutable after.
#
# Does NOT set ro.config.low_ram: that property is system_restricted_prop
# (system/sepolicy/public/te_macros, system_restricted_prop macro) with a
# hard compiled-in neverallow against any non-coredomain writer -- vendor_init
# genuinely cannot set it, this isn't a sepolicy rule to add, it's a Treble
# boundary. (It's also a ro.* property, meant to be set once from build.prop,
# not re-derived at runtime.) So isLowRamDevice()/RoSystemProperties.CONFIG_LOW_RAM
# stays whatever the build sets it to; this script only drives min_free_kbytes
# (direct /proc write, no property_service involved) and dalvik.vm.* heap
# props (vendor_init already has set_prop to dalvik_config_prop).
# Shell builtins only: /vendor/bin/awk is a separate binary labeled plain
# vendor_file, which the pawlet_memtier domain isn't allowed to exec.
MEM_KB=
while read -r key value _; do
if [ "$key" = "MemTotal:" ]; then
MEM_KB=$value
break
fi
done < /proc/meminfo
if [ "$MEM_KB" -le 2097152 ]; then # <= 2GB
TIER=low
MINFREE=16384
elif [ "$MEM_KB" -le 4194304 ]; then # <= 4GB
TIER=mid
MINFREE=24576
else # > 4GB
TIER=high
MINFREE=32768
fi
echo "$MINFREE" > /proc/sys/vm/min_free_kbytes
setprop vendor.memtier "$TIER"