diff --git a/board/miyoo/boot/firstboot b/board/miyoo/boot/firstboot index ff1c13ec..e348a851 100644 --- a/board/miyoo/boot/firstboot +++ b/board/miyoo/boot/firstboot @@ -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} @@ -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 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 - fi + fi mount -o remount,ro / / cat /etc/inittab >> ${LOG} 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} 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 @@ -756,6 +758,21 @@ if $CHANGE_FS_P5; then elif test "${P5_FS_TYPE}" == "EXT4"; then sed -i "s|\(::sysinit:/bin/mount /dev/mmcblk0p5\).*|\1 "${ROMS}" -o rw,noatime|" /etc/inittab 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 / / cat /etc/inittab >> ${LOG} fi diff --git a/board/miyoo/main/apps/usb-hid/usb-hid.sh b/board/miyoo/main/apps/usb-hid/usb-hid.sh index 1772d202..56c40856 100755 --- a/board/miyoo/main/apps/usb-hid/usb-hid.sh +++ b/board/miyoo/main/apps/usb-hid/usb-hid.sh @@ -5,15 +5,19 @@ st_error_func(){ st_exec_func(){ st -k -e "/bin/sh" "-c" "${1}" } - 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 - mount none /sys/kernel/config -t configfs - gadget-hid - 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 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 \ No newline at end of file +gadget-vid-pid-remove 0x1d6b:0x0104 +modprobe -r usb_f_hid +modprobe -r evdev +modprobe -r uinput diff --git a/board/miyoo/main/apps/usb-host/usb-host.sh b/board/miyoo/main/apps/usb-host/usb-host.sh index c487fece..2a142d20 100755 --- a/board/miyoo/main/apps/usb-host/usb-host.sh +++ b/board/miyoo/main/apps/usb-host/usb-host.sh @@ -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 \ No newline at end of file diff --git a/board/miyoo/main/apps/usb-mtd/usb-mtd.sh b/board/miyoo/main/apps/usb-mtd/usb-mtd.sh index 165ad934..c3636164 100755 --- a/board/miyoo/main/apps/usb-mtd/usb-mtd.sh +++ b/board/miyoo/main/apps/usb-mtd/usb-mtd.sh @@ -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 diff --git a/board/miyoo/main/apps/usb-network/usb-network.sh b/board/miyoo/main/apps/usb-network/usb-network.sh index f5ef1ab0..b5fdfa87 100755 --- a/board/miyoo/main/apps/usb-network/usb-network.sh +++ b/board/miyoo/main/apps/usb-network/usb-network.sh @@ -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 diff --git a/board/miyoo/main/apps/usb-serial-console/usb-serial.sh b/board/miyoo/main/apps/usb-serial-console/usb-serial.sh index 4587e3ab..e5ff1f2b 100755 --- a/board/miyoo/main/apps/usb-serial-console/usb-serial.sh +++ b/board/miyoo/main/apps/usb-serial-console/usb-serial.sh @@ -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 + diff --git a/board/miyoo/rootfs/etc/inittab b/board/miyoo/rootfs/etc/inittab index 6d3df75a..a4558fac 100644 --- a/board/miyoo/rootfs/etc/inittab +++ b/board/miyoo/rootfs/etc/inittab @@ -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 diff --git a/board/miyoo/rootfs/etc/main b/board/miyoo/rootfs/etc/main index 12cc511c..94285733 100755 --- a/board/miyoo/rootfs/etc/main +++ b/board/miyoo/rootfs/etc/main @@ -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}"