Add ability to load btrfs, sound and usb drivers as a module (#176)

* Add ability to load btrfs and usb drivers as a module
* Add load sound driver
* firstboot: correct btrfs loading only on fs change

---------

Co-authored-by: Apaczer <94932128+Apaczer@users.noreply.github.com>
This commit is contained in:
tiopex
2025-07-05 23:22:02 +02:00
committed by GitHub
parent ba175a94f3
commit e306510c79
8 changed files with 117 additions and 44 deletions

View File

@@ -20,6 +20,7 @@
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/bin/mount -a
::sysinit:/bin/hostname -F /etc/hostname
::sysinit:/sbin/modprobe btrfs
::sysinit:/bin/mount /dev/mmcblk0p4 /mnt -o commit=5,flushoncommit,noatime,nodiratime,exec
::sysinit:/bin/mount /dev/mmcblk0p5 /roms -o rw,noatime
::sysinit:/bin/mount /dev/mmcblk0p1 /boot -t vfat -o ro,exec,utf8

View File

@@ -57,37 +57,6 @@ restore_temp_log_func(){
# load kernel modules
# load usb gadget
echo "Loading USB gadget" >> "${LOGS}"
mount none /sys/kernel/config -t configfs 2>&1 | tee -a "${LOGS}"
mkdir -p /sys/kernel/config/usb_gadget/g2 >> "${LOGS}" 2>&1
cd /sys/kernel/config/usb_gadget/g2 || echo "Failed to cd into /sys/kernel/config/usb_gadget/g2" >> "${LOGS}" 2>&1
mkdir -p configs/c.1 >> "${LOGS}" 2>&1
mkdir -p functions/ffs.mtp >> "${LOGS}" 2>&1
mkdir -p strings/0x409 >> "${LOGS}" 2>&1
mkdir -p configs/c.1/strings/0x409 >> "${LOGS}" 2>&1
echo 0x0100 > idProduct
echo 0x1D6B > idVendor
echo "Miyoo Handheld" > strings/0x409/manufacturer
echo "Miyoo CFW 2.0" > strings/0x409/product
echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
ln -s functions/ffs.mtp configs/c.1 2>&1 | tee -a "${LOGS}"
mkdir -p /dev/ffs-mtp >> "${LOGS}" 2>&1
mount -t functionfs mtp /dev/ffs-mtp 2>&1 | tee -a "${LOGS}"
if test "x${DEBUG_UMTPR}" == "xyes"; then
umtprd-debug >> "${LOGS_TEMP}" 2>&1 &
else
umtprd >> ${UMTPR_LOGS} 2>&1 & # since it's running in bg the stdout/stderr redirecction is constantly active, may brake unmounting so logging here to /dev/null
fi
sleep 1
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/g2/UDC
# Load the expected one screen driver from here with modprobe
## automatically from rootfs/lib/modules/VERSION
# The uEnv.txt is autogenerated by u-boot from HW which outputs
@@ -130,6 +99,13 @@ else
fi
fi
# Load sound modules
cmdline=$(cat /proc/cmdline)
snd_val=$(echo "$cmdline" | sed -n 's/.*miyoo\.miyoo_snd=\([0-9]\+\).*/\1/p')
modprobe miyoo miyoo_snd="$snd_val" 2>&1 | tee -a "${LOGS}"
# check if it's first boot and defer to the firstboot script if yes
if grep -sq FIRSTBOOT\=\1 "${HOME}/options.cfg"; then
test -r "${BOOTDIR}/firstboot.done" \
@@ -185,6 +161,41 @@ else
export CONSOLE_VARIANT="unknown"
fi
# load usb modules
modprobe sunxi 2>&1 | tee -a "${LOGS}"
modprobe usb_f_fs 2>&1 | tee -a "${LOGS}"
# load usb gadget
echo "Loading USB gadget" >> "${LOGS}"
mount none /sys/kernel/config -t configfs 2>&1 | tee -a "${LOGS}"
mkdir -p /sys/kernel/config/usb_gadget/g2 >> "${LOGS}" 2>&1
cd /sys/kernel/config/usb_gadget/g2 || echo "Failed to cd into /sys/kernel/config/usb_gadget/g2" >> "${LOGS}" 2>&1
mkdir -p configs/c.1 >> "${LOGS}" 2>&1
mkdir -p functions/ffs.mtp >> "${LOGS}" 2>&1
mkdir -p strings/0x409 >> "${LOGS}" 2>&1
mkdir -p configs/c.1/strings/0x409 >> "${LOGS}" 2>&1
echo 0x0100 > idProduct
echo 0x1D6B > idVendor
echo "Miyoo Handheld" > strings/0x409/manufacturer
echo "Miyoo CFW 2.0" > strings/0x409/product
echo "Conf 1" > configs/c.1/strings/0x409/configuration
echo 120 > configs/c.1/MaxPower
ln -s functions/ffs.mtp configs/c.1 2>&1 | tee -a "${LOGS}"
mkdir -p /dev/ffs-mtp >> "${LOGS}" 2>&1
mount -t functionfs mtp /dev/ffs-mtp 2>&1 | tee -a "${LOGS}"
if test "x${DEBUG_UMTPR}" == "xyes"; then
umtprd-debug >> "${LOGS_TEMP}" 2>&1 &
else
umtprd >> ${UMTPR_LOGS} 2>&1 & # since it's running in bg the stdout/stderr redirecction is constantly active, may brake unmounting so logging here to /dev/null
fi
sleep 1
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/g2/UDC
echo "Boot!" >> "${LOGS}"
echo "Handheld type is ${CONSOLE_VARIANT}" >> "${LOGS}"