From fcacbaf97444ec9f32d00e49f38385bb4e0f751c Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Fri, 8 Apr 2016 16:36:56 +0300 Subject: [PATCH] Rework external applications into plugins --- common.sh | 118 +++-------------------------- compile.sh | 2 +- configuration.sh | 9 +-- debootstrap-ng.sh | 4 +- extras/mt7601.sh | 79 +++++++++++++++++++ extras/rtl8192cu.sh | 31 ++++++++ extras/usb-redirector.sh | 42 ++++++++++ main.sh | 11 +-- scripts/sunxi-temp/sunxi_tp_temp.c | 4 +- 9 files changed, 168 insertions(+), 132 deletions(-) create mode 100644 extras/mt7601.sh create mode 100644 extras/rtl8192cu.sh create mode 100644 extras/usb-redirector.sh diff --git a/common.sh b/common.sh index ea93e43dc..d56897408 100644 --- a/common.sh +++ b/common.sh @@ -260,133 +260,35 @@ compile_kernel (){ } -install_external_applications (){ +install_external_applications () +{ #-------------------------------------------------------------------------------------------------------------------------------- # Install external applications example #-------------------------------------------------------------------------------------------------------------------------------- -IFS='.' read -a array <<< "$VER" -# USB redirector broken for old kernels -if (( "${array[0]}" == "4" )) && (( "${array[1]}" >= "1" )); then - display_alert "Installing external applications" "USB redirector" "info" - if [[ $ARCH == *64* ]]; then ARCHITECTURE=arm64; else ARCHITECTURE=arm; fi - # USB redirector tools http://www.incentivespro.com - cd $SOURCES - wget -q http://www.incentivespro.com/usb-redirector-linux-arm-eabi.tar.gz - tar xfz usb-redirector-linux-arm-eabi.tar.gz - rm usb-redirector-linux-arm-eabi.tar.gz - cd $SOURCES/usb-redirector-linux-arm-eabi/files/modules/src/tusbd - # patch to work with newer kernels - sed -e "s/f_dentry/f_path.dentry/g" -i usbdcdev.c - make -j1 ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" KERNELDIR=$SOURCES/$LINUXSOURCEDIR/ >> $DEST/debug/install.log - # configure USB redirector - sed -e 's/%INSTALLDIR_TAG%/\/usr\/local/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 - sed -e 's/%PIDFILE_TAG%/\/var\/run\/usbsrvd.pid/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd - sed -e 's/%STUBNAME_TAG%/tusbd/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 - sed -e 's/%DAEMONNAME_TAG%/usbsrvd/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd - chmod +x $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd - # copy to root - cp $SOURCES/usb-redirector-linux-arm-eabi/files/usb* $CACHEDIR/sdcard/usr/local/bin/ - cp $SOURCES/usb-redirector-linux-arm-eabi/files/modules/src/tusbd/tusbd.ko $CACHEDIR/sdcard/usr/local/bin/ - cp $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd $CACHEDIR/sdcard/etc/init.d/ - # not started by default ----- update.rc rc.usbsrvd defaults - # chroot $CACHEDIR/sdcard /bin/bash -c "update-rc.d rc.usbsrvd defaults -fi +display_alert "Installing extra applications and drivers" "customize-image.sh" "info" -# some aditional stuff. Some driver as example -if [[ -n "$MISC3_DIR" ]]; then - display_alert "Installing external applications" "RT8192 driver" "info" - # https://github.com/pvaret/rtl8192cu-fixes - cd $SOURCES/$MISC3_DIR - #git checkout 0ea77e747df7d7e47e02638a2ee82ad3d1563199 - make ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" clean >/dev/null 2>&1 - (make ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" KSRC=$SOURCES/$LINUXSOURCEDIR/ >/dev/null 2>&1) - cp *.ko $CACHEDIR/sdcard/lib/modules/$VER-$LINUXFAMILY/kernel/net/wireless/ - depmod -b $CACHEDIR/sdcard/ $VER-$LINUXFAMILY - #cp blacklist*.conf $CACHEDIR/sdcard/etc/modprobe.d/ -fi - -# MISC4 = NOTRO DRIVERS / special handling +for plugin in $SRC/lib/extras/*.sh; do + source $plugin +done # MISC5 = sunxi display control if [[ -n "$MISC5_DIR" && $BRANCH != "next" && $LINUXSOURCEDIR == *sunxi* ]]; then cd "$SOURCES/$MISC5_DIR" cp "$SOURCES/$LINUXSOURCEDIR/include/video/sunxi_disp_ioctl.h" . - make clean >/dev/null 2>&1 - (make ARCH=$ARCHITECTURE CC="${CROSS_COMPILE}gcc" KSRC="$SOURCES/$LINUXSOURCEDIR/" >/dev/null) + make clean >/dev/null + make ARCH=$ARCHITECTURE CC="${CROSS_COMPILE}gcc" KSRC="$SOURCES/$LINUXSOURCEDIR/" >> $DEST/debug/compilation.log 2>&1 install -m 755 a10disp "$CACHEDIR/sdcard/usr/local/bin" fi + # MISC5 = sunxi display control / compile it for sun8i just in case sun7i stuff gets ported to sun8i and we're able to use it if [[ -n "$MISC5_DIR" && $BRANCH != "next" && $LINUXSOURCEDIR == *sun8i* ]]; then cd "$SOURCES/$MISC5_DIR" wget -q "https://raw.githubusercontent.com/linux-sunxi/linux-sunxi/sunxi-3.4/include/video/sunxi_disp_ioctl.h" make clean >/dev/null 2>&1 - (make ARCH=$ARCHITECTURE CC="${CROSS_COMPILE}gcc" KSRC="$SOURCES/$LINUXSOURCEDIR/" >/dev/null) + make ARCH=$ARCHITECTURE CC="${CROSS_COMPILE}gcc" KSRC="$SOURCES/$LINUXSOURCEDIR/" >> $DEST/debug/compilation.log 2>&1 install -m 755 a10disp "$CACHEDIR/sdcard/usr/local/bin" fi -# MT7601U -if [[ -n "$MISC6_DIR" && $BRANCH != "next" ]]; then - display_alert "Installing external applications" "MT7601U - driver" "info" - cd $SOURCES/$MISC6_DIR - cat >> fix_build.patch << _EOF_ -diff --git a/src/dkms.conf b/src/dkms.conf -new file mode 100644 -index 0000000..7563b5a ---- /dev/null -+++ b/src/dkms.conf -@@ -0,0 +1,8 @@ -+PACKAGE_NAME="mt7601-sta-dkms" -+PACKAGE_VERSION="3.0.0.4" -+CLEAN="make clean" -+BUILT_MODULE_NAME[0]="mt7601Usta" -+BUILT_MODULE_LOCATION[0]="./os/linux/" -+DEST_MODULE_LOCATION[0]="/kernel/drivers/net/wireless" -+AUTOINSTALL=yes -+MAKE[0]="make -j4 KERNELVER=\$kernelver" -diff --git a/src/include/os/rt_linux.h b/src/include/os/rt_linux.h -index 3726b9e..b8be886 100755 ---- a/src/include/os/rt_linux.h -+++ b/src/include/os/rt_linux.h -@@ -279,7 +279,7 @@ typedef struct file* RTMP_OS_FD; - - typedef struct _OS_FS_INFO_ - { --#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) -+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0) - uid_t fsuid; - gid_t fsgid; - #else -diff --git a/src/os/linux/rt_linux.c b/src/os/linux/rt_linux.c -index 1b6a631..c336611 100755 ---- a/src/os/linux/rt_linux.c -+++ b/src/os/linux/rt_linux.c -@@ -51,7 +51,7 @@ - #define RT_CONFIG_IF_OPMODE_ON_STA(__OpMode) - #endif - --ULONG RTDebugLevel = RT_DEBUG_TRACE; -+ULONG RTDebugLevel = 0; - ULONG RTDebugFunc = 0; - - #ifdef OS_ABL_FUNC_SUPPORT -_EOF_ - - patch -f -s -p1 -r - /dev/null - cd src - make -s ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" clean >/dev/null 2>&1 - (make -s -j4 ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" LINUX_SRC=$SOURCES/$LINUXSOURCEDIR/ >/dev/null 2>&1) - cp os/linux/*.ko $CACHEDIR/sdcard/lib/modules/$VER-$LINUXFAMILY/kernel/net/wireless/ - mkdir -p $CACHEDIR/sdcard/etc/Wireless/RT2870STA - cp RT2870STA.dat $CACHEDIR/sdcard/etc/Wireless/RT2870STA/ - depmod -b $CACHEDIR/sdcard/ $VER-$LINUXFAMILY - make -s clean 1>&2 2>/dev/null - cd .. - mkdir -p $CACHEDIR/sdcard/usr/src/ - cp -R src $CACHEDIR/sdcard/usr/src/mt7601-3.0.0.4 - # TODO: Set the module to build automatically via dkms in the future here - -fi - # h3disp/sun8i-corekeeper.sh for sun8i/3.4.x if [ "${LINUXFAMILY}" = "sun8i" -a "${BRANCH}" = "default" ]; then install -m 755 "$SRC/lib/scripts/h3disp" "$CACHEDIR/sdcard/usr/local/bin" diff --git a/compile.sh b/compile.sh index 3c41d2b29..f581783b0 100755 --- a/compile.sh +++ b/compile.sh @@ -27,7 +27,7 @@ CONSOLE_CHAR="UTF-8" # advanced KERNEL_KEEP_CONFIG="no" # overwrite kernel config before compilation -EXTERNAL="yes" # compile extra drivers` +EXTERNAL="yes" # install extra applications and drivers FORCE_CHECKOUT="yes" # ignore manual changes to source BUILD_ALL="no" # cycle through selected boards and make images diff --git a/configuration.sh b/configuration.sh index 208b0107d..45d98a381 100644 --- a/configuration.sh +++ b/configuration.sh @@ -43,16 +43,8 @@ EXIT_PATCHING_ERROR="" # exit patching if failed SERIALCON="ttyS0" MISC1="https://github.com/linux-sunxi/sunxi-tools.git" # Allwinner fex compiler / decompiler MISC1_DIR="sunxi-tools" # local directory -MISC2="" # Reserved -MISC2_DIR="" # local directory -MISC3="https://github.com/dz0ny/rt8192cu" # Realtek drivers -MISC3_DIR="rt8192cu" # local directory -MISC4="" -MISC4_DIR="" MISC5="https://github.com/hglm/a10disp/" # Display changer for Allwinner MISC5_DIR="sunxi-display-changer" # local directory -MISC6="https://github.com/porjo/mt7601/" # Display changer for Allwinner -MISC6_DIR="mt7601" # local directory CACHEDIR=$DEST/cache # board configurations @@ -634,6 +626,7 @@ esac [[ -z $CPUMIN && ($LINUXFAMILY == udoo || $LINUXFAMILY == neo ) ]] && CPUMIN="392000" && CPUMAX="996000" && GOVERNOR="interactive" [[ -z $GOVERNOR ]] && GOVERNOR="ondemand" +if [[ $ARCH == *64* ]]; then ARCHITECTURE=arm64; else ARCHITECTURE=arm; fi # Essential packages PACKAGE_LIST="automake bash-completion bc bridge-utils build-essential cmake cpufrequtils \ diff --git a/debootstrap-ng.sh b/debootstrap-ng.sh index e67bb26a7..da39db8b8 100644 --- a/debootstrap-ng.sh +++ b/debootstrap-ng.sh @@ -80,9 +80,7 @@ debootstrap_ng() fi # install additional applications - if [[ $EXTERNAL == yes ]]; then - install_external_applications - fi + [[ $EXTERNAL == yes ]] && install_external_applications # stage: user customization script # NOTE: installing too many packages may fill tmpfs mount diff --git a/extras/mt7601.sh b/extras/mt7601.sh new file mode 100644 index 000000000..705ca6cea --- /dev/null +++ b/extras/mt7601.sh @@ -0,0 +1,79 @@ +# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. +# +# This file is a part of tool chain https://github.com/igorpecovnik/lib +# + +install_mt7601() +{ + local plugin_repo="https://github.com/porjo/mt7601/" + local plugin_dir="mt7601" + + fetch_from_github "$plugin_repo" "$plugin_dir" + + cd $SOURCES/$plugin_dir + cat >> fix_build.patch << _EOF_ +diff --git a/src/dkms.conf b/src/dkms.conf +new file mode 100644 +index 0000000..7563b5a +--- /dev/null ++++ b/src/dkms.conf +@@ -0,0 +1,8 @@ ++PACKAGE_NAME="mt7601-sta-dkms" ++PACKAGE_VERSION="3.0.0.4" ++CLEAN="make clean" ++BUILT_MODULE_NAME[0]="mt7601Usta" ++BUILT_MODULE_LOCATION[0]="./os/linux/" ++DEST_MODULE_LOCATION[0]="/kernel/drivers/net/wireless" ++AUTOINSTALL=yes ++MAKE[0]="make -j4 KERNELVER=\$kernelver" +diff --git a/src/include/os/rt_linux.h b/src/include/os/rt_linux.h +index 3726b9e..b8be886 100755 +--- a/src/include/os/rt_linux.h ++++ b/src/include/os/rt_linux.h +@@ -279,7 +279,7 @@ typedef struct file* RTMP_OS_FD; + + typedef struct _OS_FS_INFO_ + { +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0) + uid_t fsuid; + gid_t fsgid; + #else +diff --git a/src/os/linux/rt_linux.c b/src/os/linux/rt_linux.c +index 1b6a631..c336611 100755 +--- a/src/os/linux/rt_linux.c ++++ b/src/os/linux/rt_linux.c +@@ -51,7 +51,7 @@ + #define RT_CONFIG_IF_OPMODE_ON_STA(__OpMode) + #endif + +-ULONG RTDebugLevel = RT_DEBUG_TRACE; ++ULONG RTDebugLevel = 0; + ULONG RTDebugFunc = 0; + + #ifdef OS_ABL_FUNC_SUPPORT +_EOF_ + + patch -f -s -p1 -r - /dev/null + cd src + make -s ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" clean >> $DEST/debug/compilation.log 2>&1 + make -s -j4 ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" LINUX_SRC=$SOURCES/$LINUXSOURCEDIR/ >> $DEST/debug/compilation.log 2>&1 + cp os/linux/*.ko $CACHEDIR/sdcard/lib/modules/$VER-$LINUXFAMILY/kernel/net/wireless/ + mkdir -p $CACHEDIR/sdcard/etc/Wireless/RT2870STA + cp RT2870STA.dat $CACHEDIR/sdcard/etc/Wireless/RT2870STA/ + depmod -b $CACHEDIR/sdcard/ $VER-$LINUXFAMILY + make -s clean >/dev/null + cd .. + mkdir -p $CACHEDIR/sdcard/usr/src/ + cp -R src $CACHEDIR/sdcard/usr/src/mt7601-3.0.0.4 + # TODO: Set the module to build automatically via dkms in the future here +} + +if [[ $BRANCH == default ]]; then + display_alert "Installing additional driver" "MT7601U" "info" + install_mt7601 +fi diff --git a/extras/rtl8192cu.sh b/extras/rtl8192cu.sh new file mode 100644 index 000000000..e2a9bd530 --- /dev/null +++ b/extras/rtl8192cu.sh @@ -0,0 +1,31 @@ +# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. +# +# This file is a part of tool chain https://github.com/igorpecovnik/lib +# + +# NOTE: NEeds gcc5 specific fixes like other wireless drivers + +install_rtl8192cu() +{ + local plugin_repo="https://github.com/dz0ny/rt8192cu" + # https://github.com/pvaret/rtl8192cu-fixes + local plugin_dir="rt8192cu" + + fetch_from_github "$plugin_repo" "$plugin_dir" + cd $SOURCES/$plugin_dir + #git checkout 0ea77e747df7d7e47e02638a2ee82ad3d1563199 + make ARCH=$ARCHITECTURE CROSS_COMPILE="${CROSS_COMPILE//ccache}" clean >> $DEST/debug/compilation.log + make ARCH=$ARCHITECTURE CROSS_COMPILE="${CROSS_COMPILE//ccache}" KSRC=$SOURCES/$LINUXSOURCEDIR/ >> $DEST/debug/compilation.log + cp *.ko $CACHEDIR/sdcard/lib/modules/$VER-$LINUXFAMILY/kernel/net/wireless/ + depmod -b $CACHEDIR/sdcard/ $VER-$LINUXFAMILY + #cp blacklist*.conf $CACHEDIR/sdcard/etc/modprobe.d/ +} + +if [[ $BRANCH == default ]]; then + display_alert "Installing additional driver" "RT8192" "info" + install_rtl8192cu +fi diff --git a/extras/usb-redirector.sh b/extras/usb-redirector.sh new file mode 100644 index 000000000..922a511af --- /dev/null +++ b/extras/usb-redirector.sh @@ -0,0 +1,42 @@ +# Copyright (c) 2015 Igor Pecovnik, igor.pecovnik@gma**.com +# +# This file is licensed under the terms of the GNU General Public +# License version 2. This program is licensed "as is" without any +# warranty of any kind, whether express or implied. +# +# This file is a part of tool chain https://github.com/igorpecovnik/lib +# + +# USB redirector tools http://www.incentivespro.com + +install_usb_redirector() +{ + cd $SOURCES + wget -q http://www.incentivespro.com/usb-redirector-linux-arm-eabi.tar.gz + tar xfz usb-redirector-linux-arm-eabi.tar.gz + rm usb-redirector-linux-arm-eabi.tar.gz + cd $SOURCES/usb-redirector-linux-arm-eabi/files/modules/src/tusbd + # patch to work with newer kernels + sed -e "s/f_dentry/f_path.dentry/g" -i usbdcdev.c + if [[ $ARCH == *64* ]]; then ARCHITECTURE=arm64; else ARCHITECTURE=arm; fi + make -j1 ARCH=$ARCHITECTURE CROSS_COMPILE="$CROSS_COMPILE" KERNELDIR=$SOURCES/$LINUXSOURCEDIR/ >> $DEST/debug/install.log 2>&1 + # configure USB redirector + sed -e 's/%INSTALLDIR_TAG%/\/usr\/local/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 + sed -e 's/%PIDFILE_TAG%/\/var\/run\/usbsrvd.pid/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd + sed -e 's/%STUBNAME_TAG%/tusbd/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 + sed -e 's/%DAEMONNAME_TAG%/usbsrvd/g' $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd1 > $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd + chmod +x $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd + # copy to root + cp $SOURCES/usb-redirector-linux-arm-eabi/files/usb* $CACHEDIR/sdcard/usr/local/bin/ + cp $SOURCES/usb-redirector-linux-arm-eabi/files/modules/src/tusbd/tusbd.ko $CACHEDIR/sdcard/usr/local/bin/ + cp $SOURCES/usb-redirector-linux-arm-eabi/files/rc.usbsrvd $CACHEDIR/sdcard/etc/init.d/ + # not started by default ----- update.rc rc.usbsrvd defaults + # chroot $CACHEDIR/sdcard /bin/bash -c "update-rc.d rc.usbsrvd defaults +} + +IFS='.' read -a array <<< "$VER" +# USB redirector is broken for old kernels +if (( "${array[0]}" == "4" )) && (( "${array[1]}" >= "1" )); then + display_alert "Installing additional application" "USB redirector" "info" + install_usb_redirector +fi diff --git a/main.sh b/main.sh index 43e978c86..34bb78391 100644 --- a/main.sh +++ b/main.sh @@ -180,9 +180,6 @@ fi if [ "$BRANCH" == "" ]; then echo "ERROR: You have to choose one branch"; exit; fi -# don't compile external modules on mainline -if [ "$BRANCH" != "default" ]; then EXTERNAL="no"; fi - # back to normal unset IFS @@ -250,11 +247,7 @@ fetch_from_github "$LINUXKERNEL" "$LINUXSOURCE" "$KERNELBRANCH" "yes" LINUXSOURCEDIR=$LINUXSOURCE/$GITHUBSUBDIR if [[ -n "$MISC1" ]]; then fetch_from_github "$MISC1" "$MISC1_DIR"; fi -if [[ -n "$MISC2" ]]; then fetch_from_github "$MISC2" "$MISC2_DIR"; fi -if [[ -n "$MISC3" ]]; then fetch_from_github "$MISC3" "$MISC3_DIR"; fi -if [[ -n "$MISC4" ]]; then fetch_from_github "$MISC4" "$MISC4_DIR"; fi if [[ -n "$MISC5" ]]; then fetch_from_github "$MISC5" "$MISC5_DIR"; fi -if [[ -n "$MISC6" ]]; then fetch_from_github "$MISC6" "$MISC6_DIR"; fi # compile sunxi tools if [[ $LINUXFAMILY == sun*i ]]; then @@ -310,9 +303,7 @@ if [[ $KERNEL_ONLY != yes ]]; then fi # install external applications - if [ "$EXTERNAL" = "yes" ]; then - install_external_applications - fi + [[ $EXTERNAL == yes ]] && install_external_applications # closing image closing_image diff --git a/scripts/sunxi-temp/sunxi_tp_temp.c b/scripts/sunxi-temp/sunxi_tp_temp.c index c185f70d8..1f1a6a024 100644 --- a/scripts/sunxi-temp/sunxi_tp_temp.c +++ b/scripts/sunxi-temp/sunxi_tp_temp.c @@ -13,7 +13,7 @@ //#define _debug ; -const SoCTempAdjustment = 1447 ; +const int SoCTempAdjustment = 1447 ; int main(int argc, char *argv[]) { @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) printf("r 0x01c25020: %08lx\n", mmio_read(0x01c25020)) ; #endif - printf("%0.1f\n",(float)(mmio_read(0x01c25020)-SoCTempAdjustment)/10); + printf("%0.1f\n",(float)(mmio_read(0x01c25020)-SoCTempAdjustment)/10.0); return 0;