2014-10-07 20:49:46 +02:00
#!/bin/bash
#
2015-12-02 20:33:32 +01:00
# 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
2014-10-07 20:49:46 +02:00
#
2015-12-18 12:22:42 +03:00
# Functions:
# compile_uboot
# compile_sunxi_tools
# compile_kernel
# install_external_applications
2015-12-25 20:04:33 +03:00
# write_uboot
2014-10-07 20:49:46 +02:00
2015-12-02 20:33:32 +01:00
compile_uboot ( ) {
2015-12-09 09:14:39 +01:00
#---------------------------------------------------------------------------------------------------------------------------------
2015-12-02 20:33:32 +01:00
# Compile uboot from sources
2015-12-09 09:14:39 +01:00
#---------------------------------------------------------------------------------------------------------------------------------
2016-03-05 21:26:01 +03:00
if [ [ ! -d " $SOURCES / $BOOTSOURCEDIR " ] ] ; then
exit_with_error "Error building u-boot: source directory does not exist" " $BOOTSOURCEDIR "
fi
2015-12-09 09:54:58 +01:00
local branch = " ${ BRANCH //default/ } "
[ [ -n " $branch " ] ] && branch = "-" $branch
2015-12-08 19:25:30 +01:00
display_alert "Compiling uboot. Please wait." " $VER " "info"
echo ` date +"%d.%m.%Y %H:%M:%S" ` $SOURCES /$BOOTSOURCEDIR /$BOOTCONFIG >> $DEST /debug/install.log
cd $SOURCES /$BOOTSOURCEDIR
2015-12-02 20:33:32 +01:00
make -s ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- clean >/dev/null 2>& 1
2015-12-09 09:14:39 +01:00
2015-12-02 20:33:32 +01:00
# there are two methods of compilation
if [ [ $BOOTCONFIG = = *config* ] ] ; then
2015-12-09 09:14:39 +01:00
2015-12-02 20:33:32 +01:00
make $CTHREADS $BOOTCONFIG CROSS_COMPILE = arm-linux-gnueabihf- >/dev/null 2>& 1
[ -f .config ] && sed -i 's/CONFIG_LOCALVERSION=""/CONFIG_LOCALVERSION="-armbian"/g' .config
2015-12-21 12:13:28 +01:00
[ -f .config ] && sed -i 's/CONFIG_LOCALVERSION_AUTO=.*/# CONFIG_LOCALVERSION_AUTO is not set/g' .config
[ -f $SOURCES /$BOOTSOURCEDIR /tools/logos/udoo.bmp ] && cp $SRC /lib/bin/armbian-u-boot.bmp $SOURCES /$BOOTSOURCEDIR /tools/logos/udoo.bmp
2015-12-02 20:33:32 +01:00
touch .scmversion
2015-12-09 09:14:39 +01:00
2016-01-08 19:50:53 +01:00
# special compilation for armada
[ [ $LINUXFAMILY = = "marvell" ] ] && local MAKEPARA = "u-boot.mmc"
2015-12-09 09:14:39 +01:00
# patch mainline uboot configuration to boot with old kernels
if [ [ $BRANCH = = "default" && $LINUXFAMILY = = sun*i ] ] ; then
2015-12-08 19:25:30 +01:00
if [ " $( cat $SOURCES /$BOOTSOURCEDIR /.config | grep CONFIG_ARMV7_BOOT_SEC_DEFAULT = y) " = = "" ] ; then
echo "CONFIG_ARMV7_BOOT_SEC_DEFAULT=y" >> $SOURCES /$BOOTSOURCEDIR /.config
echo "CONFIG_OLD_SUNXI_KERNEL_COMPAT=y" >> $SOURCES /$BOOTSOURCEDIR /.config
2015-12-02 20:33:32 +01:00
fi
fi
2015-12-09 09:14:39 +01:00
2016-01-08 19:50:53 +01:00
eval 'make $MAKEPARA $CTHREADS CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" 2>&1' \
2015-12-09 18:02:04 +03:00
${ PROGRESS_LOG_TO_FILE : + ' | tee -a $DEST/debug/compilation.log' } \
2016-03-07 18:29:48 +01:00
${ OUTPUT_DIALOG : + ' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." $TTY_Y $TTY_X' } \
2015-12-09 18:02:04 +03:00
${ OUTPUT_VERYSILENT : + ' >/dev/null 2>/dev/null' }
2015-12-09 09:14:39 +01:00
else
2016-01-08 19:50:53 +01:00
eval 'make $MAKEPARA $CTHREADS $BOOTCONFIG CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" 2>&1' \
2015-12-09 18:02:04 +03:00
${ PROGRESS_LOG_TO_FILE : + ' | tee -a $DEST/debug/compilation.log' } \
2016-03-07 18:29:48 +01:00
${ OUTPUT_DIALOG : + ' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." $TTY_Y $TTY_X' } \
2015-12-09 18:02:04 +03:00
${ OUTPUT_VERYSILENT : + ' >/dev/null 2>/dev/null' }
2015-12-09 09:54:58 +01:00
fi
2014-10-07 20:49:46 +02:00
2015-12-09 09:54:58 +01:00
# create .deb package
2014-10-07 20:49:46 +02:00
2015-12-09 09:54:58 +01:00
CHOOSEN_UBOOT = "linux-u-boot" $branch "-" $BOARD "_" $REVISION "_armhf"
UBOOT_PCK = "linux-u-boot-" $BOARD "" $branch
mkdir -p $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT $DEST /debs/$CHOOSEN_UBOOT /DEBIAN
2015-12-02 20:33:32 +01:00
# set up post install script
cat <<END > $DEST/debs/$CHOOSEN _UBOOT/DEBIAN/postinst
#!/bin/bash
set -e
if [ [ \$ DEVICE = = "" ] ] ; then DEVICE = "/dev/mmcblk0" ; fi
if [ [ \$ DPKG_MAINTSCRIPT_PACKAGE = = *cubox* ] ] ; then
( dd if = /usr/lib/$CHOOSEN_UBOOT /SPL of = \$ DEVICE bs = 512 seek = 2 status = noxfer ) > /dev/null 2>& 1
( dd if = /usr/lib/$CHOOSEN_UBOOT /u-boot.img of = \$ DEVICE bs = 1K seek = 42 status = noxfer ) > /dev/null 2>& 1
elif [ [ \$ DPKG_MAINTSCRIPT_PACKAGE = = *guitar* ] ] ; then
( dd if = /usr/lib/$CHOOSEN_UBOOT /bootloader.bin of = \$ DEVICE bs = 512 seek = 4097 conv = fsync ) > /dev/null 2>& 1
( dd if = /usr/lib/$CHOOSEN_UBOOT /u-boot-dtb.bin of = \$ DEVICE bs = 512 seek = 6144 conv = fsync ) > /dev/null 2>& 1
2015-12-09 09:54:58 +01:00
elif [ [ \$ DPKG_MAINTSCRIPT_PACKAGE = = *odroid* ] ] ; then
( dd if = /usr/lib/$CHOOSEN_UBOOT /bl1.bin.hardkernel of = \$ DEVICE seek = 1 conv = fsync ) > /dev/null 2>& 1
( dd if = /usr/lib/$CHOOSEN_UBOOT /bl2.bin.hardkernel of = \$ DEVICE seek = 31 conv = fsync ) > /dev/null 2>& 1
( dd if = /usr/lib/$CHOOSEN_UBOOT /u-boot.bin of = \$ DEVICE bs = 512 seek = 63 conv = fsync ) > /dev/null 2>& 1
( dd if = /usr/lib/$CHOOSEN_UBOOT /tzsw.bin.hardkernel of = \$ DEVICE seek = 719 conv = fsync ) > /dev/null 2>& 1
2015-12-10 11:41:14 +01:00
( dd if = /dev/zero of = \$ DEVICE seek = 1231 count = 32 bs = 512 conv = fsync ) > /dev/null 2>& 1
2015-12-02 20:33:32 +01:00
elif [ [ \$ DPKG_MAINTSCRIPT_PACKAGE = = *udoo* ] ] ; then
2015-12-20 19:28:35 +01:00
( dd if = /usr/lib/$CHOOSEN_UBOOT /SPL of = \$ DEVICE bs = 1k seek = 1 status = noxfer ) > /dev/null 2>& 1
( dd if = /usr/lib/$CHOOSEN_UBOOT /u-boot.img of = \$ DEVICE bs = 1K seek = 69 status = noxfer ) > /dev/null 2>& 1
2016-01-08 19:50:53 +01:00
elif [ [ \$ DPKG_MAINTSCRIPT_PACKAGE = = *armada* ] ] ; then
( dd if = /usr/lib/$CHOOSEN_UBOOT /u-boot.mmc of = \$ DEVICE bs = 512 seek = 1 status = noxfer ) > /dev/null 2>& 1
2015-12-02 20:33:32 +01:00
else
( dd if = /usr/lib/$CHOOSEN_UBOOT /u-boot-sunxi-with-spl.bin of = \$ DEVICE bs = 1024 seek = 8 status = noxfer ) > /dev/null 2>& 1
fi
exit 0
END
2015-12-09 09:54:58 +01:00
#
2014-10-07 20:49:46 +02:00
2015-12-02 20:33:32 +01:00
chmod 755 $DEST /debs/$CHOOSEN_UBOOT /DEBIAN/postinst
# set up control file
cat <<END > $DEST/debs/$CHOOSEN _UBOOT/DEBIAN/control
2015-12-09 09:54:58 +01:00
Package: linux-u-boot-$BOARD $branch
2015-12-02 20:33:32 +01:00
Version: $REVISION
Architecture: armhf
Maintainer: $MAINTAINER <$MAINTAINERMAIL >
Installed-Size: 1
Section: kernel
Priority: optional
2015-12-08 19:25:30 +01:00
Description: Uboot loader $VER
2015-12-02 20:33:32 +01:00
END
#
2014-10-07 20:49:46 +02:00
2015-12-09 09:54:58 +01:00
# copy proper uboot files to place
if [ [ $BOARD = = cubox-i* ] ] ; then
2015-12-20 19:28:35 +01:00
[ ! -f "SPL" ] || cp SPL u-boot.img $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
2015-12-09 09:54:58 +01:00
elif [ [ $BOARD = = guitar* ] ] ; then
[ ! -f "u-boot-dtb.bin" ] || cp u-boot-dtb.bin $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
[ ! -f " $SRC /lib/bin/s500-bootloader.bin " ] || cp $SRC /lib/bin/s500-bootloader.bin $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT /bootloader.bin
elif [ [ $BOARD = = odroid* ] ] ; then
2015-12-09 11:29:50 +01:00
[ ! -f "sd_fuse/hardkernel/bl1.bin.hardkernel" ] || cp sd_fuse/hardkernel/bl1.bin.hardkernel $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
[ ! -f "sd_fuse/hardkernel/bl2.bin.hardkernel" ] || cp sd_fuse/hardkernel/bl2.bin.hardkernel $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
[ ! -f "sd_fuse/hardkernel/tzsw.bin.hardkernel" ] || cp sd_fuse/hardkernel/tzsw.bin.hardkernel $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
2015-12-09 09:54:58 +01:00
[ ! -f "u-boot.bin" ] || cp u-boot.bin $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT /
elif [ [ $BOARD = = udoo* ] ] ; then
2015-12-20 19:28:35 +01:00
[ ! -f "u-boot.img" ] || cp SPL u-boot.img $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
2016-01-08 19:50:53 +01:00
elif [ [ $BOARD = = armada* ] ] ; then
[ ! -f "u-boot.mmc" ] || cp u-boot.mmc $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
2015-12-09 09:54:58 +01:00
else
[ ! -f "u-boot-sunxi-with-spl.bin" ] || cp u-boot-sunxi-with-spl.bin $DEST /debs/$CHOOSEN_UBOOT /usr/lib/$CHOOSEN_UBOOT
fi
2014-10-13 19:17:37 +02:00
2015-12-09 09:54:58 +01:00
cd $DEST /debs
display_alert "Target directory" " $DEST /debs/ " "info"
display_alert "Building deb" " $CHOOSEN_UBOOT .deb " "info"
dpkg -b $CHOOSEN_UBOOT >/dev/null 2>& 1
rm -rf $CHOOSEN_UBOOT
CHOOSEN_UBOOT = $CHOOSEN_UBOOT ".deb"
2014-10-24 18:56:18 +02:00
2015-12-09 09:54:58 +01:00
FILESIZE = $( wc -c $DEST /debs/$CHOOSEN_UBOOT | cut -f 1 -d ' ' )
2016-02-15 13:53:35 +03:00
if [ [ $FILESIZE -lt 50000 ] ] ; then
2015-12-09 09:54:58 +01:00
rm $DEST /debs/$CHOOSEN_UBOOT
2016-03-06 13:01:05 +03:00
exit_with_error "Building u-boot failed, check configuration"
2015-12-09 09:54:58 +01:00
fi
2014-10-07 20:49:46 +02:00
}
2015-12-02 20:33:32 +01:00
compile_sunxi_tools ( ) {
2015-12-09 08:51:19 +01:00
#---------------------------------------------------------------------------------------------------------------------------------
# https://github.com/linux-sunxi/sunxi-tools Tools to help hacking Allwinner devices
#---------------------------------------------------------------------------------------------------------------------------------
display_alert "Compiling sunxi tools" "@host & target" "info"
cd $SOURCES /$MISC1_DIR
make -s clean >/dev/null 2>& 1
2016-02-26 13:08:22 +01:00
rm -f sunxi-fexc sunxi-nand-part
2015-12-09 08:51:19 +01:00
make -s >/dev/null 2>& 1
cp fex2bin bin2fex /usr/local/bin/
2016-02-26 14:19:32 +01:00
# make -s clean >/dev/null 2>&1
# rm -f sunxi-fexc sunxi-nand-part meminfo sunxi-fel sunxi-pio 2>/dev/null
# make $CTHREADS 'sunxi-nand-part' CC=arm-linux-gnueabihf-gcc >> $DEST/debug/install.log 2>&1
# make $CTHREADS 'sunxi-fexc' CC=arm-linux-gnueabihf-gcc >> $DEST/debug/install.log 2>&1
# make $CTHREADS 'meminfo' CC=arm-linux-gnueabihf-gcc >> $DEST/debug/install.log 2>&1
2015-12-09 08:51:19 +01:00
2014-10-07 20:49:46 +02:00
}
2015-12-02 20:33:32 +01:00
compile_kernel ( ) {
2015-12-09 14:39:27 +01:00
#---------------------------------------------------------------------------------------------------------------------------------
2015-12-02 20:33:32 +01:00
# Compile kernel
2015-12-09 14:39:27 +01:00
#---------------------------------------------------------------------------------------------------------------------------------
2014-12-11 19:41:07 +01:00
2016-03-05 21:26:01 +03:00
if [ [ ! -d " $SOURCES / $LINUXSOURCEDIR " ] ] ; then
exit_with_error "Error building kernel: source directory does not exist" " $LINUXSOURCEDIR "
fi
2014-10-07 20:49:46 +02:00
2015-12-09 14:39:27 +01:00
local branch = " ${ BRANCH //default/ } "
[ [ -n " $branch " ] ] && branch = "-" $branch
# read kernel version to variable $VER
grab_version " $SOURCES / $LINUXSOURCEDIR "
2014-12-11 19:41:07 +01:00
2015-12-10 11:41:14 +01:00
display_alert " Compiling $BRANCH kernel " "@host" "info"
2015-12-09 14:39:27 +01:00
cd $SOURCES /$LINUXSOURCEDIR /
2014-12-11 19:41:07 +01:00
2015-12-09 14:39:27 +01:00
# adding custom firmware to kernel source
if [ [ -n " $FIRMWARE " ] ] ; then unzip -o $SRC /lib/$FIRMWARE -d $SOURCES /$LINUXSOURCEDIR /firmware; fi
2014-12-11 19:41:07 +01:00
2015-12-09 14:39:27 +01:00
# use proven config
2015-12-27 17:02:03 +03:00
if [ " $KERNEL_KEEP_CONFIG " != "yes" ] || [ ! -f $SOURCES /$LINUXSOURCEDIR /.config ] ; then
if [ -f $SRC /userpatches/$LINUXCONFIG .config ] ; then
display_alert "Using kernel config provided by user" " userpatches/ $LINUXCONFIG .config " "info"
cp $SRC /userpatches/$LINUXCONFIG .config $SOURCES /$LINUXSOURCEDIR /.config
else
2016-01-02 19:25:01 +03:00
display_alert "Using kernel config file" " lib/config/ $LINUXCONFIG .config " "info"
2015-12-27 17:02:03 +03:00
cp $SRC /lib/config/$LINUXCONFIG .config $SOURCES /$LINUXSOURCEDIR /.config
fi
2015-12-09 14:39:27 +01:00
fi
2014-12-11 19:41:07 +01:00
2015-12-09 14:39:27 +01:00
# hacks for banana family
if [ [ $LINUXFAMILY = = "banana" ] ] ; then
sed -i 's/CONFIG_GMAC_CLK_SYS=y/CONFIG_GMAC_CLK_SYS=y\nCONFIG_GMAC_FOR_BANANAPI=y/g' .config
fi
# hack for deb builder. To pack what's missing in headers pack.
cp $SRC /lib/patch/misc/headers-debian-byteshift.patch /tmp
2014-12-17 20:10:02 +01:00
2015-12-09 14:39:27 +01:00
export LOCALVERSION = "-" $LINUXFAMILY
2014-12-11 19:41:07 +01:00
2015-12-09 14:39:27 +01:00
# We can use multi threading here but not later since it's not working. This way of compilation is much faster.
if [ " $KERNEL_CONFIGURE " != "yes" ] ; then
if [ " $BRANCH " = "default" ] ; then
make $CTHREADS ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- silentoldconfig
else
make $CTHREADS ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- olddefconfig
fi
2015-12-08 17:09:13 +03:00
else
2015-12-09 14:39:27 +01:00
make $CTHREADS ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- oldconfig
make $CTHREADS ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- menuconfig
2015-12-08 17:09:13 +03:00
fi
2014-12-11 19:41:07 +01:00
2016-03-05 21:26:01 +03:00
eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" zImage modules 2>&1' \
${ PROGRESS_LOG_TO_FILE : + ' | tee -a $DEST/debug/compilation.log' } \
2016-03-07 18:29:48 +01:00
${ OUTPUT_DIALOG : + ' | dialog --backtitle "$backtitle" --progressbox "Compiling kernel..." $TTY_Y $TTY_X' } \
2016-03-05 21:26:01 +03:00
${ OUTPUT_VERYSILENT : + ' >/dev/null 2>/dev/null' }
2014-12-11 19:41:07 +01:00
2016-03-05 21:26:01 +03:00
if [ ${ PIPESTATUS [0] } -ne 0 ] || [ ! -f arch/arm/boot/zImage ] ; then
exit_with_error "Kernel was not built" "@host"
fi
eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" dtbs 2>&1' \
${ PROGRESS_LOG_TO_FILE : + ' | tee -a $DEST/debug/compilation.log' } \
2016-03-07 18:29:48 +01:00
${ OUTPUT_DIALOG : + ' | dialog --backtitle "$backtitle" --progressbox "Compiling Device Tree..." $TTY_Y $TTY_X' } \
2016-03-05 21:26:01 +03:00
${ OUTPUT_VERYSILENT : + ' >/dev/null 2>/dev/null' }
2014-12-11 19:41:07 +01:00
2016-03-05 21:26:01 +03:00
if [ ${ PIPESTATUS [0] } -ne 0 ] ; then
exit_with_error "DTBs were not build" "@host"
fi
2014-12-11 19:41:07 +01:00
2014-11-17 16:20:02 +01:00
2016-03-05 21:26:01 +03:00
# different packaging for 4.3+ // probably temporaly soution
KERNEL_PACKING = "deb-pkg"
IFS = '.' read -a array <<< " $VER "
if ( ( " ${ array [0] } " = = "4" ) ) && ( ( " ${ array [1] } " >= "3" ) ) ; then
KERNEL_PACKING = "bindeb-pkg"
fi
# make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
# produce deb packages: image, headers, firmware, libc
eval ' make -j1 $KERNEL_PACKING KDEB_PKGVERSION = $REVISION LOCALVERSION = "-" $LINUXFAMILY KBUILD_DEBARCH = armhf ARCH = arm DEBFULLNAME = " $MAINTAINER " \
DEBEMAIL = " $MAINTAINERMAIL " CROSS_COMPILE = " $CCACHE arm-linux-gnueabihf- " 2>& 1 ' \
${ PROGRESS_LOG_TO_FILE : + ' | tee -a $DEST/debug/compilation.log' } \
2016-03-07 18:29:48 +01:00
${ OUTPUT_DIALOG : + ' | dialog --backtitle "$backtitle" --progressbox "Creating kernel packages..." $TTY_Y $TTY_X' } \
2016-03-05 21:26:01 +03:00
${ OUTPUT_VERYSILENT : + ' >/dev/null 2>/dev/null' }
# we need a name
CHOOSEN_KERNEL = linux-image" $branch " -" $CONFIG_LOCALVERSION $LINUXFAMILY " _" $REVISION " _armhf.deb
cd ..
mv *.deb $DEST /debs/ || exit_with_error "Failed moving kernel DEBs"
2014-10-07 20:49:46 +02:00
}
install_external_applications ( ) {
2014-10-08 09:53:25 +02:00
#--------------------------------------------------------------------------------------------------------------------------------
2015-12-02 20:33:32 +01:00
# Install external applications example
2014-10-08 09:53:25 +02:00
#--------------------------------------------------------------------------------------------------------------------------------
2015-12-02 20:33:32 +01:00
display_alert "Installing external applications" "USB redirector" "info"
2014-10-07 20:49:46 +02:00
# USB redirector tools http://www.incentivespro.com
2015-12-02 20:33:32 +01:00
cd $SOURCES
wget -q http://www.incentivespro.com/usb-redirector-linux-arm-eabi.tar.gz
tar xfz usb-redirector-linux-arm-eabi.tar.gz
2014-10-07 20:49:46 +02:00
rm usb-redirector-linux-arm-eabi.tar.gz
2015-12-02 20:33:32 +01:00
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
2015-12-08 19:25:30 +01:00
make -j1 ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- KERNELDIR = $SOURCES /$LINUXSOURCEDIR / >> $DEST /debug/install.log
2014-10-07 20:49:46 +02:00
# configure USB redirector
2015-12-02 20:33:32 +01:00
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
2014-10-07 20:49:46 +02:00
# copy to root
2015-12-02 20:33:32 +01:00
cp $SOURCES /usb-redirector-linux-arm-eabi/files/usb* $DEST /cache/sdcard/usr/local/bin/
cp $SOURCES /usb-redirector-linux-arm-eabi/files/modules/src/tusbd/tusbd.ko $DEST /cache/sdcard/usr/local/bin/
cp $SOURCES /usb-redirector-linux-arm-eabi/files/rc.usbsrvd $DEST /cache/sdcard/etc/init.d/
2014-10-07 20:49:46 +02:00
# not started by default ----- update.rc rc.usbsrvd defaults
2015-12-02 20:33:32 +01:00
# chroot $DEST/cache/sdcard /bin/bash -c "update-rc.d rc.usbsrvd defaults"
2014-10-07 20:49:46 +02:00
# some aditional stuff. Some driver as example
if [ [ -n " $MISC3_DIR " ] ] ; then
2015-12-02 20:33:32 +01:00
display_alert "Installing external applications" "RT8192 driver" "info"
2014-10-07 20:49:46 +02:00
# https://github.com/pvaret/rtl8192cu-fixes
2015-12-02 20:33:32 +01:00
cd $SOURCES /$MISC3_DIR
#git checkout 0ea77e747df7d7e47e02638a2ee82ad3d1563199
make ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- clean >/dev/null 2>& 1
2015-12-08 19:25:30 +01:00
( make ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- KSRC = $SOURCES /$LINUXSOURCEDIR / >/dev/null 2>& 1)
2016-03-05 21:41:02 +02:00
cp *.ko $DEST /cache/sdcard/lib/modules/$VER -$LINUXFAMILY /kernel/net/wireless/
depmod -b $DEST /cache/sdcard/ $VER -$LINUXFAMILY
2015-12-02 20:33:32 +01:00
#cp blacklist*.conf $DEST/cache/sdcard/etc/modprobe.d/
fi
# MISC4 = NOTRO DRIVERS / special handling
2016-02-26 17:20:03 +01:00
# MISC5 = sunxi display control
2016-02-26 20:22:13 +01:00
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 = arm CC = arm-linux-gnueabihf-gcc KSRC = " $SOURCES / $LINUXSOURCEDIR / " >/dev/null 2>& 1)
install -m 755 a10disp " $DEST /cache/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"
2015-12-02 20:33:32 +01:00
make clean >/dev/null 2>& 1
2016-02-26 20:22:13 +01:00
( make ARCH = arm CC = arm-linux-gnueabihf-gcc KSRC = " $SOURCES / $LINUXSOURCEDIR / " >/dev/null 2>& 1)
install -m 755 a10disp " $DEST /cache/sdcard/usr/local/bin "
2014-10-07 20:49:46 +02:00
fi
2016-02-20 13:49:19 +02:00
# 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_
2016-02-21 16:26:43 +02:00
patch -f -s -p1 -r - <fix_build.patch >/dev/null
2016-02-20 13:49:19 +02:00
cd src
2016-02-23 17:58:12 +02:00
make -s ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- clean >/dev/null 2>& 1
( make -s -j4 ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf- LINUX_SRC = $SOURCES /$LINUXSOURCEDIR / >/dev/null 2>& 1)
2016-02-20 13:49:19 +02:00
cp os/linux/*.ko $DEST /cache/sdcard/lib/modules/$VER -$LINUXFAMILY /kernel/net/wireless/
mkdir -p $DEST /cache/sdcard/etc/Wireless/RT2870STA
cp RT2870STA.dat $DEST /cache/sdcard/etc/Wireless/RT2870STA/
depmod -b $DEST /cache/sdcard/ $VER -$LINUXFAMILY
2016-02-23 17:58:12 +02:00
make -s clean 1>& 2 2>/dev/null
2016-02-20 13:49:19 +02:00
cd ..
mkdir -p $DEST /cache/sdcard/usr/src/
cp -R src $DEST /cache/sdcard/usr/src/mt7601-3.0.0.4
# TODO: Set the module to build automatically via dkms in the future here
fi
2016-02-24 11:47:54 +01:00
# h3disp for sun8i/3.4.x
if [ " $BOARD " = "orangepiplus" -o " $BOARD " = "orangepih3" ] ; then
install -m 755 " $SRC /lib/scripts/h3disp " " $DEST /cache/sdcard/usr/local/bin "
fi
2014-10-07 20:49:46 +02:00
}
2015-12-25 20:04:33 +03:00
# write_uboot <loopdev>
#
# writes u-boot to loop device
# Parameters:
# loopdev: loop device with mounted rootfs image
write_uboot( )
{
LOOP = $1
display_alert "Writing bootloader" " $LOOP " "info"
dpkg -x $DEST "/debs/" $CHOOSEN_UBOOT /tmp/
CHOOSEN_UBOOT = " ${ CHOOSEN_UBOOT //.deb/ } "
if [ [ $BOARD = = *cubox* ] ] ; then
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /SPL of = $LOOP bs = 512 seek = 2 status = noxfer >/dev/null 2>& 1)
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /u-boot.img of = $LOOP bs = 1K seek = 42 status = noxfer >/dev/null 2>& 1)
2016-01-08 19:50:53 +01:00
elif [ [ $BOARD = = *armada* ] ] ; then
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /u-boot.mmc of = $LOOP bs = 512 seek = 1 status = noxfer >/dev/null 2>& 1)
2015-12-25 20:04:33 +03:00
elif [ [ $BOARD = = *udoo* ] ] ; then
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /SPL of = $LOOP bs = 1k seek = 1 status = noxfer >/dev/null 2>& 1)
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /u-boot.img of = $LOOP bs = 1k seek = 69 conv = fsync >/dev/null 2>& 1)
elif [ [ $BOARD = = *guitar* ] ] ; then
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /bootloader.bin of = $LOOP bs = 512 seek = 4097 conv = fsync > /dev/null 2>& 1)
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /u-boot-dtb.bin of = $LOOP bs = 512 seek = 6144 conv = fsync > /dev/null 2>& 1)
elif [ [ $BOARD = = *odroid* ] ] ; then
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /bl1.bin.hardkernel of = $LOOP seek = 1 conv = fsync ) > /dev/null 2>& 1
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /bl2.bin.hardkernel of = $LOOP seek = 31 conv = fsync ) > /dev/null 2>& 1
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /u-boot.bin of = $LOOP bs = 512 seek = 63 conv = fsync ) > /dev/null 2>& 1
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /tzsw.bin.hardkernel of = $LOOP seek = 719 conv = fsync ) > /dev/null 2>& 1
( dd if = /dev/zero of = $LOOP seek = 1231 count = 32 bs = 512 conv = fsync ) > /dev/null 2>& 1
else
( dd if = /tmp/usr/lib/" $CHOOSEN_UBOOT " /u-boot-sunxi-with-spl.bin of = $LOOP bs = 1024 seek = 8 status = noxfer >/dev/null 2>& 1)
fi
if [ $? -ne 0 ] ; then
2016-03-06 13:01:05 +03:00
exit_with_error "U-boot failed to install" "@host"
2015-12-25 20:04:33 +03:00
fi
rm -r /tmp/usr
sync
}