Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/sh

info "[initramfs] K99-move-boot: starting"

# Disable MPDEC for now until android layer starts up and make sure atleast
# one CPU stays online to not hangup the boot
#echo 0 > /sys/kernel/msm_mpdecision/conf/enabled
echo 1 > /sys/devices/system/cpu/cpu1/online
echo 0 > /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled
echo 1 > /sys/devices/system/cpu/cpu1/online 2>/dev/null
echo 0 > /sys/module/pm_8x60/modes/cpu0/power_collapse/idle_enabled 2>/dev/null

# Move /mnt/boot to a location under the new root
tell_kmsg "Moving boot mount to: /rfs/uboot"
info "[initramfs] Moving boot mount to: /rfs/uboot"
mkdir -p /rfs/uboot
mount --move /mnt/boot /rfs/uboot
info "[initramfs] K99-move-boot: done"
Original file line number Diff line number Diff line change
@@ -1,35 +1,66 @@
#!/bin/sh

# mount boot partition:
info "[initramfs] S01-mount-boot: starting"

# Check if mmcblk0p13 exists
if [ ! -b /dev/mmcblk0p13 ]; then
info "[initramfs] Waiting for mmcblk0p13..."
sleep 2
if [ ! -b /dev/mmcblk0p13 ]; then
info "[initramfs] Available block devices:"
ls -la /dev/mmcblk* 2>/dev/null
fail "/dev/mmcblk0p13 not found"
fi
fi

# mount boot partition (may already be mounted rw for debug logging)
mkdir -p /mnt/boot
mount -o ro /dev/mmcblk0p13 /mnt/boot
if mount | grep -q "/mnt/boot"; then
info "[initramfs] /mnt/boot already mounted (debug logging), remounting ro..."
# Sync any pending writes before remounting read-only
sync
mount -o remount,ro /mnt/boot
else
mount -o ro /dev/mmcblk0p13 /mnt/boot
if [ $? -ne 0 ]; then
fail "Failed to mount /dev/mmcblk0p13 on /mnt/boot"
fi
fi

info "[initramfs] mmcblk0p13 mounted."

# use lvm.static binary file to initialize /dev/store
[ ! -d /var/lock ] && mkdir -p /var/lock
[ ! -d /run/lock ] && mkdir -p /run/lock

if [ -e /mnt/boot/usr/sbin/lvm.static ]
then
if [ -e /mnt/boot/usr/sbin/lvm.static ]; then
info "[initramfs] Activating LVM..."
export LVM_SYSTEM_DIR=/mnt/boot/etc/lvm
export LVM_SYSTEM_DIR=/mnt/boot/etc/lvm
info "LVM_SYSTEM_DIR: $LVM_SYSTEM_DIR"
sleep 3
/mnt/boot/usr/sbin/lvm.static vgchange -ay
/mnt/boot/usr/sbin/lvm.static vgchange -ay 2>&1
LVM_RC=$?
info "[initramfs] LVM vgchange first attempt: rc=$LVM_RC"
sleep 3
/mnt/boot/usr/sbin/lvm.static vgchange -ay 2>&1 > /media/internal/lvm.txt
/mnt/boot/usr/sbin/lvm.static vgchange -ay 2>&1
LVM_RC=$?
info "[initramfs] LVM vgchange second attempt: rc=$LVM_RC"
sleep 3
else
info "/mnt/boot/usr/sbin/lvm.static not found: skipping LVM2 volume group activation!"
fi

for g in `ls /dev/store`
do
info "Partition in dev/store: $g"
done
else
info "/mnt/boot/usr/sbin/lvm.static not found: skipping LVM2 volume group activation!"
fi

if [ ! -d /dev/store ]; then
fail "Failed to start LVM"
if [ -d /dev/store ]; then
info "[initramfs] LVM volumes found in /dev/store:"
for g in $(ls /dev/store); do
info " /dev/store/$g"
done
else
info "[initramfs] /dev/store does not exist after LVM activation"
info "[initramfs] Available /dev/mapper entries:"
ls -la /dev/mapper/ 2>/dev/null
info "[initramfs] Available /dev/dm-* entries:"
ls -la /dev/dm-* 2>/dev/null
fail "Failed to start LVM - /dev/store not found"
fi

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
SRC_URI:append:tenderloin = "\
file://S01-mount-boot.sh \
file://K99-move-boot.sh \
file://leia_pm4_470.fw \
file://leia_pfp_470.fw \
"

COMPATIBLE_MACHINE:tenderloin = "tenderloin"
Expand All @@ -14,6 +16,15 @@ do_install:append:tenderloin() {
install -m 0755 ${WORKDIR}/K99-move-boot.sh ${D}/scripts/local-bottom/K99-move-boot.sh
echo ". /scripts/local-premount/S01-mount-boot.sh" >> ${D}/scripts/local-premount/ORDER
echo ". /scripts/local-bottom/K99-move-boot.sh" >> ${D}/scripts/local-bottom/ORDER

# Install Adreno 200 (Z180) GPU firmware for early boot
# Must be /lib/firmware (not /usr/lib) for kernel firmware loader
install -d ${D}/lib/firmware
install -m 0644 ${WORKDIR}/leia_pm4_470.fw ${D}/lib/firmware/leia_pm4_470.fw
install -m 0644 ${WORKDIR}/leia_pfp_470.fw ${D}/lib/firmware/leia_pfp_470.fw
}

FILES:${PN} += "/scripts/local-premount /scripts/local-bottom"
FILES:${PN} += "/scripts/local-premount /scripts/local-bottom /lib/firmware"

# Skip usrmerge check - initramfs needs /lib/firmware for kernel firmware loader
INSANE_SKIP:${PN}:append:tenderloin = " usrmerge"
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[Unit]
Description=Load the ath6kl WiFi kernel module
After=android-system.service
Requires=android-system.service
Description=Load ath6kl WiFi module for HP TouchPad
After=systemd-modules-load.service
Before=network-pre.target

[Service]
Type=oneshot
ExecStart=/sbin/modprobe ath6kl
RemainAfterExit=yes
# Load ath6kl_sdio which pulls in ath6kl_core automatically
# Prefix with '-' so boot continues if WiFi module is missing
ExecStart=-/sbin/modprobe ath6kl_sdio

[Install]
WantedBy=basic.target
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[Unit]
Description=Enable SWAP from LVM partition

# NOTE: We need this to unbreak out boot process and to correctly mount the
# existing swap from a LVM partition. Somehow systemd isn't able to detect
# on startup that the LVM partition specified in /etc/fstab already exists
# so we have to defer its activation for now a bit to make sure we correctly
# activate our SWAP space.
Description=Enable swap on LVM swap partition
After=dev-mapper-store\x2dswap.device
Requires=dev-mapper-store\x2dswap.device

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/swapon /dev/mapper/store-swap

[Install]
WantedBy=basic.target
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion meta-hp/recipes-kernel/linux/linux-hp-tenderloin_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ KMETA = "kernel-meta"
KBUILD_DEFCONFIG:tenderloin = "tenderloin_debug_defconfig"
KCONFIG_MODE = "alldefconfig"

SRCREV_machine = "77b0c4fe6ce0774b986cb5c70fb758f8f09a9570"
SRCREV_machine = "51e099a2f81d2357dfda1ae2818cad32413c3b84"
SRCREV_meta = "8ac9b1baf5d3cc1cb53a87a449b52f253dc32cab"

SRC_URI = " \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,68 @@ mkdir -p /dev

# mount basic virtual fs
mount_proc_sys_dev_configfs ""

# Mount devtmpfs for automatic device node creation by kernel
echo "Mounting devtmpfs..."
mount -t devtmpfs devtmpfs /dev 2>/dev/null || echo "devtmpfs mount failed (may already be mounted)"

echo "Populate /dev thanks to mdev"
start_mdev

# Give kernel time to probe devices (eMMC, USB controller)
echo "Waiting for device initialization..."
sleep 2
# redirect log
# setup_log

echo "/proc/cmdline:"
cat /proc/cmdline

### Setup persistent debug log ###
# Mount boot partition early for persistent logging (before USB setup)
# This allows debugging USB issues even without serial console
DEBUGLOG=""
BOOT_DEV=""
# Wait for and find boot partition - try common locations
echo "Looking for boot partition..."
for i in 1 2 3 4 5; do
for dev in /dev/mmcblk0p13 /dev/mmcblk0p1 /dev/sda1; do
if [ -b "$dev" ]; then
BOOT_DEV="$dev"
break 2
fi
done
echo "Waiting for block devices... ($i)"
sleep 1
done

if [ -n "$BOOT_DEV" ]; then
echo "Found boot device: $BOOT_DEV"
mkdir -p /mnt/boot
if mount -o rw "$BOOT_DEV" /mnt/boot 2>/dev/null; then
DEBUGLOG=/mnt/boot/initramfs-debug.log
echo "=== Initramfs boot log $(date 2>/dev/null || echo 'unknown') ===" > $DEBUGLOG
echo "Persistent debug log enabled at $DEBUGLOG"
else
echo "Failed to mount $BOOT_DEV"
fi
else
echo "WARNING: No boot partition found for debug logging"
echo "Available block devices:"
ls -la /dev/mmcblk* /dev/sd* 2>/dev/null || echo " (none)"
fi
export DEBUGLOG
###

### Detect debug mode ###
DEBUGMODE=no
if grep -q luneos_debug /proc/cmdline; then
DEBUGMODE=yes
info "Debug mode enabled via luneos_debug cmdline"
set -x
fi
###

### Detect recovery mode ###
RECOVERYMODE=no
# extract input device for key testing
Expand All @@ -36,36 +90,89 @@ echo "Recovery mode: $RECOVERYMODE"

setup_usb_network 172.16.42.2/16

# In debug mode, start telnet early so we can observe the entire boot
if [ "$DEBUGMODE" = "yes" ]; then
info "Starting early telnetd for debug..."
start_telnetd 172.16.42.2
info "Debug telnet available at 172.16.42.2"
info "Waiting 10s for debug connection before continuing boot..."
sleep 10
fi

if [ -f /scripts/local-premount/ORDER ]; then
info "Running local-premount hooks..."
. /scripts/local-premount/ORDER
info "local-premount hooks done"
fi

if [ "$RECOVERYMODE" = "yes" ] ; then
# start telnetd for this IP
start_telnetd 172.16.42.2

# start telnetd for this IP (skip if already started in debug mode)
if [ "$DEBUGMODE" != "yes" ]; then
start_telnetd 172.16.42.2
fi

# start minimalist recovery UI, and have a shell as fallback
/usr/bin/luneos_recovery_ui ||
/sbin/getty -L ttyS0 115200 linux

else
info "Searching for rootfs partition..."
# mount partition labeled "luneos-rootfs"
mount_root_partition "luneos-root" "/rfs"

mount_proc_sys_dev_configfs "/rfs"
info "Moving/mounting pseudo-filesystems to rootfs..."
# Mount fresh proc and sys for the new root
mkdir -p /rfs/proc /rfs/sys /rfs/config
mount -t proc -o nodev,noexec,nosuid proc /rfs/proc
mount -t sysfs -o nodev,noexec,nosuid sysfs /rfs/sys
# MOVE configfs (don't create new) to preserve USB gadget configuration
mount --move /config /rfs/config

#info "Stopping debug services"
#stop_telnetd
stop_mdev

if [ -f /scripts/local-bottom/ORDER ]; then
info "Running local-bottom hooks..."
. /scripts/local-bottom/ORDER
info "local-bottom hooks done"
fi


info "Umounting unneeded filesystems"
umount_proc_sys_dev_configfs ""
# Only unmount proc and sys; keep configfs mounted so the USB gadget
# (ECM network) stays alive through switch_root.
umount -l /sys
umount -l /proc

if [ "$DEBUGMODE" = "yes" ]; then
info "========================================"
info "Debug: rootfs contents:"
ls -la /rfs/ 2>/dev/null
info "Debug: /rfs/sbin/init:"
ls -la /rfs/sbin/init 2>/dev/null
info "Debug: rootfs mount:"
mount | grep rfs
info "========================================"
info "Debug: telnet is still running at 172.16.42.2"
info "Debug: connect now to inspect rootfs at /rfs"
info "Debug: waiting 10s before switch_root..."
info "Debug: to skip wait, create /tmp/continue"
info "========================================"
waited=0
while [ $waited -lt 10 ]; do
[ -f /tmp/continue ] && break
sleep 1
waited=$((waited + 1))
done
info "Debug: proceeding with switch_root"
stop_telnetd
fi

info "Switching to root filesystem"
# Sync debug log to disk before switch_root
[ -n "$DEBUGLOG" ] && sync
exec switch_root /rfs /sbin/init

# If switch_root fails we end up here
fail "switch_root to /rfs failed"
fi
Loading