uzbek-plus/b9/b9c/rootfs/init
q 4a7224c41f B9: built-in display (ST7735S SPI) in Linux and persistent B9C cache
- B9A: read-only audit of stock LK/DT: the panel is an ST7735S 128x128 on SPI (BLSP1 QUP4,
  16 MHz, mode 3, D/C GPIO116, RESET GPIO118), backlight = PM8916 MPP4 current sink 40 mA.
- B9B: upstream panel-mipi-dbi with the stock init sequence as firmware; MPP4 sink via pinctrl
  + gpio-backlight; first light with correct colours/orientation/offsets.
- B9C: fbcon (6x8, 21x16) on tty1 + getty, UART console kept, aurora-display service;
  cache B9C b9ce13c9 written and verified, cold boots with LTE + Wi-Fi + display.
- B9L (RAM only): lk2nd second stage with an msm8916 SPI panel port shows a picture before Linux.
- Sanitizer: whitelist for b8/ and b9/.
2026-10-03 01:45:02 +03:00

142 lines
7.1 KiB
Text
Executable file

#!/bin/busybox sh
# Aurora RAM boot MM1 — QMI1 + ModemManager (qcom-soc) + D-Bus + polkit + eudev.
# R2/T4: B6P init + telnetd on NCM. B8F: + Wi-Fi service autostart (aurora-wifi).
# B9C: + hostname aurora, display service (fbcon/backlight on the ST7735S) and a getty on tty1.
# B6P: after eMMC RO + /firmware RO + USB NCM, autostarts /etc/init.d/aurora-modem (B6N-proven lifecycle).
# NEVER mounts, fsck's, formats, trims or writes any mmcblk* device.
# No block devices, no firmware, no radios. Never exits (failures leave the UART shell).
/bin/busybox mkdir -p /proc /sys /dev /tmp /usr/bin /usr/sbin /sbin
/bin/busybox --install -s
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t devtmpfs devtmpfs /dev 2>/dev/null
mount -t configfs configfs /sys/kernel/config
hostname aurora # B9C: getty prompt 'aurora login:'
log() { echo "[init] $*"; echo "[init] $*" > /dev/kmsg 2>/dev/null; }
echo
echo "=== AURORA RAM BOOT MM1 + B6P modem service ==="
uname -a
echo "--- model"; cat /proc/device-tree/model; echo
echo "--- cmdline"; cat /proc/cmdline
emmc_ro() {
for i in $(seq 1 100); do [ -b /dev/mmcblk0 ] && break; sleep 0.1; done
if [ ! -b /dev/mmcblk0 ]; then log "EMMC: /dev/mmcblk0 did not appear"; return 1; fi
sleep 0.5 # let partition nodes settle
for d in /dev/mmcblk0 /dev/mmcblk0p* /dev/mmcblk0boot*; do [ -b "$d" ] && blockdev --setro "$d"; done
bad=0; n=0
for d in /dev/mmcblk0 /dev/mmcblk0p* /dev/mmcblk0boot*; do
[ -b "$d" ] || continue; n=$((n+1)); r=$(blockdev --getro "$d")
[ "$r" = "1" ] || { bad=1; log "EMMC-RO FAIL $d getro=$r"; }
done
echo "EMMC-RO-SUMMARY devices=$n all_ro=$([ $bad = 0 ] && echo YES || echo NO)"
[ $bad = 0 ] || return 2
log "EMMC: all $n block devices read-only (getro=1)"
}
emmc_report() {
echo "=== EMMC-INFO-BEGIN"
C=/sys/class/block/mmcblk0/device
for f in name manfid oemid cid date serial type; do echo "$f=$(cat $C/$f 2>/dev/null)"; done
echo "size_512=$(cat /sys/class/block/mmcblk0/size) logical_block=$(cat /sys/class/block/mmcblk0/queue/logical_block_size) bytes=$(blockdev --getsize64 /dev/mmcblk0)"
cat /proc/partitions
echo "=== EMMC-GPT-BEGIN (pN name start_512 size_512 ro)"
for p in /sys/class/block/mmcblk0p*; do
b=$(basename $p); nm=$(sed -n 's/^PARTNAME=//p' $p/uevent)
echo "$b $nm $(cat $p/start) $(cat $p/size) $(cat $p/ro)"
done
echo "=== EMMC-GPT-END"
echo "=== EMMC-SHA-BEGIN"
for want in sbl1 rpm DDR sec aboot hyp tz tzbak; do
for p in /sys/class/block/mmcblk0p*; do
nm=$(sed -n 's/^PARTNAME=//p' $p/uevent)
[ "$nm" = "$want" ] && echo "$nm $(basename $p) $(sha256sum /dev/$(basename $p) | cut -d' ' -f1)"
done
done
echo "=== EMMC-SHA-END"
echo "=== EMMC-INFO-END"
}
emmc_ro && EMMC_RO_OK=1 # RO FIRST, before anything else touches the disk
nv_snapshot() { # $1 = before|after ; reads RO block devices only
o=/tmp/nv-$1.txt; : > $o
for want in modemst1 modemst2 fsg fsc persist; do
for p in /sys/class/block/mmcblk0p*; do
[ "$(sed -n 's/^PARTNAME=//p' $p/uevent)" = "$want" ] && echo "$want $(basename $p) $(sha256sum /dev/$(basename $p) | cut -d' ' -f1)" >> $o
done
done
echo "stat $(cat /sys/block/mmcblk0/stat)" >> $o
}
b1_modem_fat() {
mkdir -p /dev/disk/by-partlabel /firmware
for p in /sys/class/block/mmcblk0p*; do
n=$(sed -n 's/^PARTNAME=//p' $p/uevent); [ -n "$n" ] && ln -sf /dev/$(basename $p) /dev/disk/by-partlabel/$n
done
M=$(readlink /dev/disk/by-partlabel/modem); echo "B1 modem partition by PARTLABEL: modem -> $M ro=$(blockdev --getro $M)"
[ "$(blockdev --getro $M)" = 1 ] || { log "B1: modem partition not RO - NOT mounting"; return 1; }
mount -t vfat -o ro,nosuid,nodev,noexec,shortname=lower $M /firmware || { log "B1: mount failed"; return 1; }
grep " /firmware " /proc/mounts
grep " /firmware " /proc/mounts | grep -q " ro," || { log "B1: /firmware is NOT ro - unmounting"; umount /firmware; return 1; }
(cd /firmware && find . -type f | sort | while read f; do echo "$(sha256sum "$f" | cut -d' ' -f1) ${f#./}"; done) > /tmp/fw-sha.txt
echo "B1 firmware files: $(wc -l < /tmp/fw-sha.txt)"
echo -n /firmware/image > /sys/module/firmware_class/parameters/path
log "B1: modem FAT mounted RO at /firmware, firmware path /firmware/image"
}
if [ "$EMMC_RO_OK" = 1 ]; then
echo "stat-before-B1 $(cat /sys/block/mmcblk0/stat)" > /tmp/stat-before-B1.txt
nv_snapshot before
b1_modem_fat && B1_OK=1
fi
usb_up() {
for i in $(seq 1 50); do
udc=$(ls /sys/class/udc 2>/dev/null | head -1)
[ -n "$udc" ] && break
sleep 0.2
done
echo "--- /sys/class/udc:"; ls -l /sys/class/udc 2>&1
if [ -z "$udc" ]; then log "NO UDC found - USB gadget skipped"; return 1; fi
# DEVELOPMENT-ONLY IDs (same dev setup as JZ02: Google 18d1:d001) - not for production
G=/sys/kernel/config/usb_gadget/aurora
mkdir -p $G || return 1
echo 0x18d1 > $G/idVendor
echo 0xd001 > $G/idProduct
mkdir -p $G/strings/0x409
echo "Aurora" > $G/strings/0x409/manufacturer
echo "Aurora RAM Boot" > $G/strings/0x409/product
echo "<EMMC_SERIAL>" > $G/strings/0x409/serialnumber
mkdir -p $G/functions/ncm.usb0 || { log "ncm function create FAILED"; return 1; }
mkdir -p $G/configs/c.1/strings/0x409
echo "NCM" > $G/configs/c.1/strings/0x409/configuration
ln -s $G/functions/ncm.usb0 $G/configs/c.1/
echo "$udc" > $G/UDC || { log "bind to UDC '$udc' FAILED"; return 1; }
log "usb gadget bound to UDC '$udc'"
ifc=$(cat $G/functions/ncm.usb0/ifname 2>/dev/null)
log "ncm ifname='$ifc' dev_addr=$(cat $G/functions/ncm.usb0/dev_addr) host_addr=$(cat $G/functions/ncm.usb0/host_addr)"
[ -n "$ifc" ] || return 1
ip link set lo up
ip addr add 172.16.42.1/24 dev "$ifc"
ip link set "$ifc" up
ip addr show "$ifc"
log "network: $ifc 172.16.42.1/24 up (static, no DHCP)"
}
usb_up || log "USB/NCM setup incomplete - staying on UART shell"
# R2/T4 (RAM-only, DEVELOPMENT): unauthenticated root telnet shell on the NCM link only (bind 172.16.42.1:23).
if ip addr show | grep -q " 172.16.42.1/24 "; then
mkdir -p /dev/pts; mount -t devpts devpts /dev/pts || log "T4: devpts mount FAILED"
if telnetd -l /bin/sh -b 172.16.42.1 -p 23; then log "T4: telnetd started on 172.16.42.1:23"; else log "T4: telnetd start FAILED"; fi
else log "T4: no 172.16.42.1 - telnetd NOT started"; fi
# B9C: display (no disk/radio access): fbcon on tty1 + backlight, and a display-only getty on tty1 (UART shell below unchanged).
/etc/init.d/aurora-display start
( while true; do getty 0 tty1 linux; sleep 2; done ) > /dev/null 2>&1 < /dev/null &
if [ "$EMMC_RO_OK" = 1 ]; then emmc_report; else log "EMMC: RO not confirmed or device missing - NO further disk access"; fi
echo "B1_OK=${B1_OK:-0}"
# B6P: modem autostart only when every eMMC device is RO and the modem FAT is mounted RO (the controller re-checks both).
if [ "$EMMC_RO_OK" = 1 ] && [ "$B1_OK" = 1 ]; then /etc/init.d/aurora-modem start; else log "B6P: modem autostart SKIPPED (EMMC_RO_OK=${EMMC_RO_OK:-0} B1_OK=${B1_OK:-0})"; fi
# B8F: Wi-Fi autostart (Pronto + wcn36xx + test AP) under the same RO gates; the service itself waits for modem START OK/FAIL.
if [ "$EMMC_RO_OK" = 1 ] && [ "$B1_OK" = 1 ]; then /etc/init.d/aurora-wifi start; else log "B8F: wifi autostart SKIPPED"; fi
echo "=== entering shell (exit restarts it) ==="
while true; do
setsid cttyhack sh
echo "shell exited, restarting"; sleep 1
done