mirror of
https://github.com/MiyooCFW/buildroot.git
synced 2025-09-27 22:24:19 +03:00
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:
@@ -633,6 +633,7 @@ else
|
||||
mount /dev/mmcblk0p4 "${HOME}" -o rw,sync,exec 2>&1 | tee -a ${LOG_TEMP}
|
||||
CHANGE_FS_P4=true
|
||||
elif test "${P4_FS_TYPE}" == "BTRFS"; then
|
||||
modprobe btrfs 2>&1 | tee -a "${LOGS}"
|
||||
mkfs.btrfs -r "${ROMS}"/backup/"${HOME}" -L "${P4_LABEL}" -v -f /dev/mmcblk0p4 2>&1 | tee -a ${LOG_TEMP}
|
||||
btrfsck /dev/mmcblk0p4 2>&1 | tee -a ${LOG_TEMP} # does not repair FS, just check integrity as it is dengarous to do so
|
||||
mount /dev/mmcblk0p4 "${HOME}" -o commit=5,flushoncommit,noatime,nodiratime,exec 2>&1 | tee -a ${LOG_TEMP}
|
||||
@@ -727,6 +728,7 @@ if $CHANGE_FS_P5; then
|
||||
echo "\033[0;31mExtracting archive ${ROMS} from ${HOME}/backup${ROMS} failed with rsync exit code ${EXIT_CODE}\033[0m" | tee -a ${LOG}
|
||||
fi
|
||||
elif test "${P5_FS_TYPE}" == "BTRFS"; then
|
||||
modprobe btrfs 2>&1 | tee -a "${LOGS}"
|
||||
mkfs.btrfs -r "${HOME}"/backup"${ROMS}" -v -f -L ${P5_LABEL} /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
|
||||
sleep 2
|
||||
btrfsck /dev/mmcblk0p5 2>&1 | tee -a ${LOG} # does not repair FS, just check integrity as it is dengarous to do so
|
||||
@@ -760,6 +762,21 @@ if $CHANGE_FS_P5; then
|
||||
cat /etc/inittab >> ${LOG}
|
||||
fi
|
||||
|
||||
## Correct inittab & check if btrfs module needed for p4/p5
|
||||
if ($CHANGE_FS_P4 || $CHANGE_FS_P5); then
|
||||
echo "Correcting inittab for btrfs module loading" >> ${LOG}
|
||||
mount -o remount,rw / /
|
||||
if test "${P4_FS_TYPE}" != "BTRFS" && test "${P5_FS_TYPE}" != "BTRFS" ; then
|
||||
sed -i 's|^::sysinit:/sbin/modprobe btrfs|#&|' /etc/inittab
|
||||
modprobe -r btrfs 2>&1 | tee -a "${LOGS}"
|
||||
else
|
||||
sed -i 's|^#::sysinit:/sbin/modprobe btrfs|::sysinit:/sbin/modprobe btrfs|' /etc/inittab
|
||||
modprobe btrfs 2>&1 | tee -a "${LOGS}"
|
||||
fi
|
||||
mount -o remount,ro / /
|
||||
cat /etc/inittab >> ${LOG}
|
||||
fi
|
||||
|
||||
# Expand_ROMS_Partition-prompt for the p5 (ROMS) partition if requested
|
||||
echo "Expand ${P5_LABEL} FileSystem procedure" >> ${LOG}
|
||||
RESIZE_COMMENCED=false
|
||||
|
||||
@@ -8,12 +8,16 @@ st_exec_func(){
|
||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||
killall umtprd umtprd-debug
|
||||
/mnt/apps/usb-mtd/remove.sh g2
|
||||
modprobe -r g_serial
|
||||
modprobe usb_f_hid
|
||||
modprobe evdev
|
||||
modprobe uinput
|
||||
mount none /sys/kernel/config -t configfs
|
||||
gadget-hid
|
||||
st_exec_func "\
|
||||
echo -e \"\e[32m\n\n\n\n\n\n Starting USB-HID mode\e[0m\n\n\n\"; \
|
||||
sleep 1; \
|
||||
python /mnt/apps/usb-hid/usb-hid.py"
|
||||
|
||||
gadget-vid-pid-remove 0x1d6b:0x0104
|
||||
modprobe -r usb_f_hid
|
||||
modprobe -r evdev
|
||||
modprobe -r uinput
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
#!/bin/busybox sh
|
||||
echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||
sleep 2
|
||||
|
||||
modprobe evdev
|
||||
modprobe joydev
|
||||
modprobe analog
|
||||
modprobe xpad
|
||||
modprobe atkbd
|
||||
modprobe uinput
|
||||
modprobe psmouse
|
||||
modprobe synaptics_usb
|
||||
modprobe mousedev
|
||||
modprobe usbhid
|
||||
modprobe hid-generic
|
||||
modprobe hid
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/busybox sh
|
||||
|
||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||
modprobe -r g_serial
|
||||
modprobe usb_f_fs
|
||||
killall umtprd umtprd-debug
|
||||
/mnt/apps/usb-mtd/remove.sh g2
|
||||
mount none /sys/kernel/config -t configfs
|
||||
|
||||
@@ -5,9 +5,9 @@ MAC_HOST="12:34:56:78:9a:bd"
|
||||
MAC_DEV="12:34:56:78:9a:bc"
|
||||
|
||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||
modprobe -r g_serial
|
||||
killall umtprd umtprd-debug
|
||||
/mnt/apps/usb-mtd/remove.sh g2
|
||||
modprobe usb_f_rndis
|
||||
sleep 1
|
||||
|
||||
mount none /sys/kernel/config -t configfs
|
||||
|
||||
@@ -1,4 +1,31 @@
|
||||
#!/bin/busybox sh
|
||||
|
||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||
|
||||
killall umtprd umtprd-debug
|
||||
modprobe g_serial
|
||||
/mnt/apps/usb-mtd/remove.sh g2
|
||||
mount none /sys/kernel/config -t configfs
|
||||
|
||||
mkdir /sys/kernel/config/usb_gadget/g2
|
||||
cd /sys/kernel/config/usb_gadget/g2
|
||||
|
||||
mkdir configs/c.1
|
||||
mkdir functions/acm.usb0
|
||||
mkdir strings/0x409
|
||||
mkdir configs/c.1/strings/0x409
|
||||
|
||||
echo 0x0104 > idProduct # Produkt: CDC ACM (Serial)
|
||||
echo 0x1D6B > idVendor # Producent: Linux Foundation
|
||||
|
||||
echo "Miyoo Handheld" > strings/0x409/manufacturer
|
||||
echo "Miyoo CFW 2.0" > strings/0x409/product
|
||||
echo "deadbeef12345678" > strings/0x409/serialnumber
|
||||
|
||||
echo "Conf 1" > configs/c.1/strings/0x409/configuration
|
||||
echo 120 > configs/c.1/MaxPower
|
||||
|
||||
ln -s functions/acm.usb0 configs/c.1
|
||||
|
||||
sleep 1
|
||||
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/g2/UDC
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user