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}
|
mount /dev/mmcblk0p4 "${HOME}" -o rw,sync,exec 2>&1 | tee -a ${LOG_TEMP}
|
||||||
CHANGE_FS_P4=true
|
CHANGE_FS_P4=true
|
||||||
elif test "${P4_FS_TYPE}" == "BTRFS"; then
|
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}
|
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
|
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}
|
mount /dev/mmcblk0p4 "${HOME}" -o commit=5,flushoncommit,noatime,nodiratime,exec 2>&1 | tee -a ${LOG_TEMP}
|
||||||
@@ -656,7 +657,7 @@ if ${CHANGE_FS_P4}; then
|
|||||||
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p4\).*|\1 "${HOME}" -o rw,sync,exec|" /etc/inittab
|
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p4\).*|\1 "${HOME}" -o rw,sync,exec|" /etc/inittab
|
||||||
elif test "${P4_FS_TYPE}" == "BTRFS" ; then
|
elif test "${P4_FS_TYPE}" == "BTRFS" ; then
|
||||||
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p4\).*|\1 "${HOME}" -o commit=5,flushoncommit,noatime,nodiratime,exec|" /etc/inittab
|
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p4\).*|\1 "${HOME}" -o commit=5,flushoncommit,noatime,nodiratime,exec|" /etc/inittab
|
||||||
fi
|
fi
|
||||||
mount -o remount,ro / /
|
mount -o remount,ro / /
|
||||||
cat /etc/inittab >> ${LOG}
|
cat /etc/inittab >> ${LOG}
|
||||||
fi
|
fi
|
||||||
@@ -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}
|
echo "\033[0;31mExtracting archive ${ROMS} from ${HOME}/backup${ROMS} failed with rsync exit code ${EXIT_CODE}\033[0m" | tee -a ${LOG}
|
||||||
fi
|
fi
|
||||||
elif test "${P5_FS_TYPE}" == "BTRFS"; then
|
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}
|
mkfs.btrfs -r "${HOME}"/backup"${ROMS}" -v -f -L ${P5_LABEL} /dev/mmcblk0p5 2>&1 | tee -a ${LOG}
|
||||||
sleep 2
|
sleep 2
|
||||||
btrfsck /dev/mmcblk0p5 2>&1 | tee -a ${LOG} # does not repair FS, just check integrity as it is dengarous to do so
|
btrfsck /dev/mmcblk0p5 2>&1 | tee -a ${LOG} # does not repair FS, just check integrity as it is dengarous to do so
|
||||||
@@ -756,6 +758,21 @@ if $CHANGE_FS_P5; then
|
|||||||
elif test "${P5_FS_TYPE}" == "EXT4"; then
|
elif test "${P5_FS_TYPE}" == "EXT4"; then
|
||||||
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p5\).*|\1 "${ROMS}" -o rw,noatime|" /etc/inittab
|
sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p5\).*|\1 "${ROMS}" -o rw,noatime|" /etc/inittab
|
||||||
fi
|
fi
|
||||||
|
mount -o remount,ro / /
|
||||||
|
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 / /
|
mount -o remount,ro / /
|
||||||
cat /etc/inittab >> ${LOG}
|
cat /etc/inittab >> ${LOG}
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -5,15 +5,19 @@ st_error_func(){
|
|||||||
st_exec_func(){
|
st_exec_func(){
|
||||||
st -k -e "/bin/sh" "-c" "${1}"
|
st -k -e "/bin/sh" "-c" "${1}"
|
||||||
}
|
}
|
||||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||||
killall umtprd umtprd-debug
|
killall umtprd umtprd-debug
|
||||||
/mnt/apps/usb-mtd/remove.sh g2
|
/mnt/apps/usb-mtd/remove.sh g2
|
||||||
modprobe -r g_serial
|
modprobe usb_f_hid
|
||||||
mount none /sys/kernel/config -t configfs
|
modprobe evdev
|
||||||
gadget-hid
|
modprobe uinput
|
||||||
st_exec_func "\
|
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\"; \
|
echo -e \"\e[32m\n\n\n\n\n\n Starting USB-HID mode\e[0m\n\n\n\"; \
|
||||||
sleep 1; \
|
sleep 1; \
|
||||||
python /mnt/apps/usb-hid/usb-hid.py"
|
python /mnt/apps/usb-hid/usb-hid.py"
|
||||||
|
gadget-vid-pid-remove 0x1d6b:0x0104
|
||||||
gadget-vid-pid-remove 0x1d6b:0x0104
|
modprobe -r usb_f_hid
|
||||||
|
modprobe -r evdev
|
||||||
|
modprobe -r uinput
|
||||||
|
|||||||
@@ -1,3 +1,16 @@
|
|||||||
#!/bin/busybox sh
|
#!/bin/busybox sh
|
||||||
echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||||
sleep 2
|
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
|
#!/bin/busybox sh
|
||||||
|
|
||||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
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
|
killall umtprd umtprd-debug
|
||||||
/mnt/apps/usb-mtd/remove.sh g2
|
/mnt/apps/usb-mtd/remove.sh g2
|
||||||
mount none /sys/kernel/config -t configfs
|
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"
|
MAC_DEV="12:34:56:78:9a:bc"
|
||||||
|
|
||||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||||
modprobe -r g_serial
|
|
||||||
killall umtprd umtprd-debug
|
killall umtprd umtprd-debug
|
||||||
/mnt/apps/usb-mtd/remove.sh g2
|
/mnt/apps/usb-mtd/remove.sh g2
|
||||||
|
modprobe usb_f_rndis
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
mount none /sys/kernel/config -t configfs
|
mount none /sys/kernel/config -t configfs
|
||||||
|
|||||||
@@ -1,4 +1,31 @@
|
|||||||
#!/bin/busybox sh
|
#!/bin/busybox sh
|
||||||
|
|
||||||
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
echo peripheral > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode
|
||||||
|
|
||||||
killall umtprd umtprd-debug
|
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/mkdir -p /dev/shm
|
||||||
::sysinit:/bin/mount -a
|
::sysinit:/bin/mount -a
|
||||||
::sysinit:/bin/hostname -F /etc/hostname
|
::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/mmcblk0p4 /mnt -o commit=5,flushoncommit,noatime,nodiratime,exec
|
||||||
::sysinit:/bin/mount /dev/mmcblk0p5 /roms -o rw,noatime
|
::sysinit:/bin/mount /dev/mmcblk0p5 /roms -o rw,noatime
|
||||||
::sysinit:/bin/mount /dev/mmcblk0p1 /boot -t vfat -o ro,exec,utf8
|
::sysinit:/bin/mount /dev/mmcblk0p1 /boot -t vfat -o ro,exec,utf8
|
||||||
|
|||||||
+42
-31
@@ -57,37 +57,6 @@ restore_temp_log_func(){
|
|||||||
|
|
||||||
# load kernel modules
|
# 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
|
# Load the expected one screen driver from here with modprobe
|
||||||
## automatically from rootfs/lib/modules/VERSION
|
## automatically from rootfs/lib/modules/VERSION
|
||||||
# The uEnv.txt is autogenerated by u-boot from HW which outputs
|
# The uEnv.txt is autogenerated by u-boot from HW which outputs
|
||||||
@@ -130,6 +99,13 @@ else
|
|||||||
fi
|
fi
|
||||||
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
|
# check if it's first boot and defer to the firstboot script if yes
|
||||||
if grep -sq FIRSTBOOT\=\1 "${HOME}/options.cfg"; then
|
if grep -sq FIRSTBOOT\=\1 "${HOME}/options.cfg"; then
|
||||||
test -r "${BOOTDIR}/firstboot.done" \
|
test -r "${BOOTDIR}/firstboot.done" \
|
||||||
@@ -185,6 +161,41 @@ else
|
|||||||
export CONSOLE_VARIANT="unknown"
|
export CONSOLE_VARIANT="unknown"
|
||||||
fi
|
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 "Boot!" >> "${LOGS}"
|
||||||
echo "Handheld type is ${CONSOLE_VARIANT}" >> "${LOGS}"
|
echo "Handheld type is ${CONSOLE_VARIANT}" >> "${LOGS}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user