#!/bin/bash board_info() { BOARD=`cat /proc/cpuinfo | grep Hardware | awk '{print $3}'` if [ "x$BOARD" == "xHardkernel" ]; then BOARD=`cat /proc/cpuinfo | grep Hardware | awk '{print $4}'` fi if [ `echo $BOARD | grep -c "ODROID-GO2"` -ge 1 ]; then BOARD="ODROID-GO2" fi if [ `echo $BOARD | grep -c "ODROID-C4"` -ge 1 ] || [ `echo $BOARD | grep -c "ODROID-HC4"` -ge 1 ]; then BOARD="ODROID-C4" fi if [ -z $BOARD ]; then BOARD=$(tr -d '\0' < /proc/device-tree/model | sed "s/Hardkernel //") fi case $BOARD in ODROID-U2/U3|ODROID-X|ODROID-X2) board="exynos4" ;; ODROID-C2) board="odroidc2" ;; ODROIDC) board="odroidc1" ;; ODROID-XU3|ODROID-XU) board="exynos5" ;; ODROID-N1) board="odroidn1" ;; ODROID-N2|ODROID-N2Plus) board="odroidn2" ;; ODROID-GO2) board="odroidgo2" ;; ODROID-GO3) board="odroidgo3" ;; ODROID-C4|ODROID-HC4) board="odroidc4" ;; *) board="not-supported" ;; esac } kernel_info() { KVERSION=`uname -r` KMAJOR=`echo $KVERSION | cut -d "." -f1` KMINOR=`echo $KVERSION | cut -d "." -f2` KARCH=`uname -m | sed "s/armv7l/armhf/" | sed "s/aarch64/arm64/"` } os_info() { LSB_RELEASE=`which lsb_release` if [ "x$LSB_RELEASE" == "x" ]; then OS_VERSION=`cat /etc/debian_version | cut -d "." -f1` else OS_VERSION=`lsb_release -r -s | cut -d "." -f1` fi if [ "x$OS_VERSION" == "xtesting" ] || [ "x$OS_VERSION" == "xbookworm/sid" ]; then OS_VERSION=12 fi } fix_ssh() { if [ `grep "^UseDNS no" /etc/ssh/sshd_config | wc -l` -lt 1 ]; then echo "UseDNS no" >> /etc/ssh/sshd_config service ssh restart fi } fix_blacklist() { # remove black listed modules for XU4 if [ -f /etc/modprobe.d/blacklist-ralink.conf ]; then mv /etc/modprobe.d/blacklist-ralink.conf{,.bak} fi } fix_pinning() { if [ ! -f /etc/apt/preferences.d/meveric-backports-pin-100 ]; then echo "Package: * Pin: release o=ODROID Debian Repository,c=backports Pin-Priority: 100" > /etc/apt/preferences.d/meveric-backports-pin-100 fi if [ ! -f /etc/apt/preferences.d/deb-multimedia-pin-99 ]; then echo "Package: * Pin: origin *.deb-multimedia.org Pin-Priority: 99" > /etc/apt/preferences.d/deb-multimedia-pin-99 else sed -i "s/release o=Unofficial Multimedia Packages/origin *.deb-multimedia.org/" /etc/apt/preferences.d/deb-multimedia-pin-99 fi } c1_fixes() { # messed up pulse audio configuration if [ "x$board" == "xodroidc1" ]; then sed -i "s/#load-module module-alsa-sink/load-module module-alsa-sink/" /etc/pulse/default.pa sed -i "s/#load-module module-alsa-source device=hw:1,0/load-module module-alsa-source device=hw:0,0/" /etc/pulse/default.pa # moonlight support moonlight_fixes # fix boot.ini # make sure the bootargs stand alone (needed for "patch" to work correctly) LINE=`cat /boot/boot.ini | grep -n "setenv bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE-1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE-1))a\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE-2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE-1))a\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE-3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE-1))a\\\n" /boot/boot.ini fi LINE=`cat /boot/boot.ini | grep -n "setenv bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE+1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE+1))i\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE+2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE+2))i\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE+3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE+3))i\\\n" /boot/boot.ini fi fi } moonlight_fixes() { # moonlight support if [ `grep "##### MOONLIGHT FIXES #####" /etc/rc.local | wc -l` -lt 1 ]; then sed -i "s?^exit 0?##### MOONLIGHT FIXES #####\n\nchmod 666 /sys/class/graphics/fb0/blank\nchmod 666 /sys/class/graphics/fb1/blank\nchmod 666 /dev/amstream_hevc\nchmod 666 /dev/amvideo\necho 16 > \/sys\/module\/amvdec_h265\/parameters\/dynamic_buf_num_margin\n\n##### MOONLIGHT FIXES END #####\n\nexit 0?" /etc/rc.local else if [ `grep "echo 16 > /sys/module/amvdec_h265/parameters/dynamic_buf_num_margin" /etc/rc.local | wc -l` -lt 1 ]; then sed -i "/##### MOONLIGHT FIXES END #####/ichmod 666 /dev/amstream_hevc\nchmod 666 /dev/amvideo\necho 16 > \/sys\/module\/amvdec_h265\/parameters\/dynamic_buf_num_margin\n" /etc/rc.local fi fi } c2_fixes() { if [ "x$board" == "xodroidc2" ]; then # deb multimedia broken under Debian Jessie remove it! if [ $OS_VERSION -eq 8 ] && [ -f /etc/apt/sources.list.d/deb-multimedia.list ]; then rm /etc/apt/sources.list.d/deb-multimedia.list fi # copy c2 files cp /usr/local/share/setup-odroid/c2/usr/local/bin/* /usr/local/bin/ # make sure chvt is allowed for everyone [ -f /usr/bin/chvt ] && chmod +s /usr/bin/chvt # check if ALSA is already configured if [ ! -f /etc/asound.conf ]; then cp /usr/local/share/setup-odroid/c2/etc/asound.conf /etc/ fi # check if KODI Fix was already applied if [ `cat /etc/rc.local | grep "##### KODI FIXES #####" | wc -l` -ge 1 ]; then # Check if new options for Kernel already exist if [ `cat /etc/rc.local | grep "chmod 755 /sys/kernel/debug" | wc -l` -lt 1 ]; then sed -i "s/##### KODI FIXES END #####/chmod 755 \/sys\/kernel\/debug\nchmod 666 \/sys\/kernel\/debug\/aml_reg\/paddr\n\n##### KODI FIXES END #####/" /etc/rc.local fi fi # moonlight support moonlight_fixes # GPIO Mem if [ ! -f /etc/udev/rules.d/85-odroid_gpiomem ]; then cp /usr/local/share/setup-odroid/c2/etc/udev/rules.d/85-odroid_gpiomem /etc/udev/rules.d/ fi # fix boot.ini # make sure the bootargs stand alone (needed for "patch" to work correctly) LINE=`cat /boot/boot.ini | grep -n "setenv bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE-1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE-1))a\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE-2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE-1))a\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE-3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE-1))a\\\n" /boot/boot.ini fi LINE=`cat /boot/boot.ini | grep -n "setenv bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE+1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE+1))i\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE+2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE+2))i\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE+3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE+3))i\\\n" /boot/boot.ini fi # fix rootwait sed -i "s/rootwait rw/rootwait ro/" /boot/boot.ini # very old fixes if [ `grep "fsck.fix=yes" /boot/boot.ini | wc -l` -ge 1 ]; then sed -i "s/fsck.fix=yes/fsck.repair=yes/" /boot/boot.ini fi if [ `grep "net.ifnames=0" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/fsck.repair=yes/fsck.repair=yes net.ifnames=0/" /boot/boot.ini fi # IO-Scheduler if [ `grep "elevator=noop" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0\"/elevator=noop net.ifnames=0\"/" /boot/boot.ini fi # disable HotPlug Detection (always HDMI on) if [ `grep "disablehpd=\\\${hpd}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0\"/disablehpd=\${hpd} net.ifnames=0\"/" /boot/boot.ini fi # CEC support if [ `grep "# CEC support" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/# Boot Arguments/# Boot Arguments\n\n# CEC support\nsetenv cec \"cecf\"/" /boot/boot.ini sed -i "s/no_console_suspend/no_console_suspend hdmitx=\${cec}/" /boot/boot.ini fi # console blank if [ `grep "consoleblank=0" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/setenv condev \"/setenv condev \"consoleblank=0 /" /boot/boot.ini fi # custom resolution if [ `grep "if test \"\\\${m}\" = \"custombuilt\"; then setenv cmode \"modeline=\\\${modeline}\"; fi" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/# Boot Arguments/# Boot Arguments\nif test \"\${m}\" = \"custombuilt\"; then setenv cmode \"modeline=\${modeline}\"; fi/" /boot/boot.ini fi if [ `grep "disablehpd=\\\${hpd} \\\${cmode}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/disablehpd=\${hpd}/disablehpd=\${hpd} \${cmode}/" /boot/boot.ini fi # new CPU modes if [ `grep "max_freq=\\\${max_freq} maxcpus=\\\${maxcpus}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0/max_freq=\${max_freq} maxcpus=\${maxcpus} net.ifnames=0/" /boot/boot.ini fi # monitor on/off if [ `grep "monitor_onoff=\\\${monitor_onoff}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0/monitor_onoff=\${monitor_onoff} net.ifnames=0/" /boot/boot.ini fi # forcergb if [ `grep "\\\${forcergb}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/hdmitx=\${cec}/hdmitx=\${cec} \${forcergb}/" /boot/boot.ini fi # fix typo sed -i "s/improves the video playback whoever it breaks KVM/improves the video playback however it breaks KVM/" /boot/boot.ini # UHS support if [ `grep "disableuhs=\\\${disableuhs}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0/disableuhs=\${disableuhs} net.ifnames=0/" /boot/boot.ini fi # MMC Remove if [ `grep "mmc_removable=\\\${mmc_removable}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0/mmc_removable=\${mmc_removable} net.ifnames=0/" /boot/boot.ini fi # USB Multicam if [ `grep "usbmulticam=\\\${usbmulticam}" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/net.ifnames=0/usbmulticam=\${usbmulticam} net.ifnames=0/" /boot/boot.ini fi # ODROID-VU7 Touchscreen if [ `grep -c "Disable/Enable ODROID-VU7 Touchscreen" /boot/boot.ini` -lt 1 ]; then sed -i "s/net.ifnames=0/\${hid_quirks} net.ifnames=0/" /boot/boot.ini fi # c2_init.sh fixes UPDATE_INITRAMFS=0 # remove 1366x768 from c2_init.sh if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "1366x768p60" | wc -l` -ge 1 ]; then line=`cat -n /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "1366x768p60" | awk '{print $1}'` sed -i "$line,$(($line+3))d" /etc/initramfs-tools/scripts/local-top/c2_init.sh UPDATE_INITRAMFS=1 fi # add new c2 resolutions if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "2560x1080p60hz" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20160526 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "3440x1440p60hz" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20160703 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "1600x1200p60hz" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20160802 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep " ! \-f \\\$DISP_MODE " | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20160827 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "custombuilt" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20160903 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "[[ -f \\\$DISP_MODE ]] || exit 0" | wc -l` -ge 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20160908 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "\\\*cvbs\\\*|480i\\\*|576i\\\*|1080i\\\*)" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20161021 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "480x800" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20161228 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi if [ `cat /etc/initramfs-tools/scripts/local-top/c2_init.sh | grep "480x320" | wc -l` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ < /usr/local/share/setup-odroid/fixes/C2/c2_init.sh.diff.20180116 cleanup_c2_init.sh UPDATE_INITRAMFS=1 fi # update initramfs if [ $UPDATE_INITRAMFS -eq 1 ]; then update-initramfs -c -u -k all fi # remove UMPLOCK in xorg.conf if [ -f /etc/X11/xorg.conf ] && [ `cat /etc/X11/xorg.conf | grep " Option \"UMP_LOCK\" \"true\"" | wc -l` -ge 1 ]; then sed -i "s/ Option \"UMP_LOCK\" \"true\"/ Option \"UMP_LOCK\" \"false\"/" /etc/X11/xorg.conf fi fi } n1_fixes() { if [ "x$board" == "xodroidn1" ]; then [ -f /etc/udev/rules.d/50-hevc-rk3399.rules ] || cp /usr/local/share/setup-odroid/n1/etc/udev/rules.d/50-hevc-rk3399.rules /etc/udev/rules.d/50-hevc-rk3399.rules [ -f /etc/udev/rules.d/50-vpu-rk3399.rules ] || cp /usr/local/share/setup-odroid/n1/etc/udev/rules.d/50-vpu-rk3399.rules /etc/udev/rules.d/50-vpu-rk3399.rules [ -f /etc/udev/rules.d/50-mali.rules ] || cp /usr/local/share/setup-odroid/n1/etc/udev/rules.d/50-mali.rules /etc/udev/rules.d/50-mali.rules # fix boot.ini # make sure the bootargs stand alone (needed for "patch" to work correctly) LINE=`cat /boot/boot.ini | grep -n "# Set the kernel bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE-1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE-1))a\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE-2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE-1))a\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE-3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE-1))a\\\n" /boot/boot.ini fi LINE=`cat /boot/boot.ini | grep -n "setenv bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE+1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE+1))i\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE+2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE+2))i\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE+3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE+3))i\\\n" /boot/boot.ini fi # make sure the bootrootfs stand alone (needed for "patch" to work correctly) LINE=`cat /boot/boot.ini | grep -n "# Kernel cmdline rootfs and misc" | cut -d ":" -f1` if [ `sed -n "$(($LINE-1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE-1))a\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE-2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE-1))a\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE-3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE-1))a\\\n" /boot/boot.ini fi LINE=`cat /boot/boot.ini | grep -n "setenv bootrootfs" | cut -d ":" -f1` if [ `sed -n "$(($LINE+1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE+1))i\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE+2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE+2))i\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE+3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE+3))i\\\n" /boot/boot.ini fi fi } n2_fixes() { if [ $board == "odroidn2" ]; then # fix boot.ini # make sure the bootargs stand alone (needed for "patch" to work correctly) LINE=`cat /boot/boot.ini | grep -n "# Boot Args" | cut -d ":" -f1` if [ `sed -n "$(($LINE-1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE-1))a\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE-2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE-1))a\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE-3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE-1))a\\\n" /boot/boot.ini fi LINE=`cat /boot/boot.ini | grep -n "setenv bootargs" | cut -d ":" -f1` if [ `sed -n "$(($LINE+1))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # three lines needed sed -i "$(($LINE+1))i\\\n\n" /boot/boot.ini elif [ `sed -n "$(($LINE+2))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then # two lines needed sed -i "$(($LINE+2))i\\\n" /boot/boot.ini elif [ `sed -n "$(($LINE+3))p" /boot/boot.ini | grep -c "^$"` -lt 1 ]; then sed -i "$(($LINE+3))i\\\n" /boot/boot.ini fi # fix HDMI + Analog output on Pulseaudio if [ -f /etc/pulse/default.pa ]; then if [ `grep -c "load-module module-combine sink_name=hdmi_analog slaves=hdmi_output,analog_output" /etc/pulse/default.pa` -lt 1 ]; then sed -i "/### Automatically restore the volume of streams and devices/i ### Load analog device\nload-module module-alsa-sink device=\"hw:0,1\" sink_name=analog_output\nload-module module-alsa-sink device=\"hw:0,0\" sink_name=hdmi_output\nload-module module-combine sink_name=hdmi_analog slaves=hdmi_output,analog_output\n" /etc/pulse/default.pa fi fi fi # cleanup mess: if [ $board != "odroidn2" ]; then if [ -f /etc/pulse/default.pa ]; then sed -i "/### Load analog device/d" /etc/pulse/default.pa sed -i "/load-module module-alsa-sink device=\"hw:0,1\" sink_name=analog_output/d" /etc/pulse/default.pa sed -i "/load-module module-alsa-sink device=\"hw:0,0\" sink_name=hdmi_output/d" /etc/pulse/default.pa sed -i "/load-module module-combine sink_name=hdmi_analog slaves=hdmi_output,analog_output/d" /etc/pulse/default.pa fi fi } cleanup_c2_init.sh() { # cleanup /etc/initramfs-tools/scripts/local-top/ [ -f /etc/initramfs-tools/scripts/local-top/c2_init.sh.orig ] && rm /etc/initramfs-tools/scripts/local-top/c2_init.sh.orig [ -f /etc/initramfs-tools/scripts/local-top/c2_init.sh.rej ] && rm /etc/initramfs-tools/scripts/local-top/c2_init.sh.rej } cleanup_c1_init.sh() { # cleanup /etc/initramfs-tools/scripts/local-top/ [ -f /etc/initramfs-tools/scripts/local-top/c1_init.sh.orig ] && rm /etc/initramfs-tools/scripts/local-top/c1_init.sh.orig [ -f /etc/initramfs-tools/scripts/local-top/c1_init.sh.rej ] && rm /etc/initramfs-tools/scripts/local-top/c1_init.sh.rej } new_cpu_control() { if [ `grep "/usr/local/sbin/set-cpu" /etc/rc.local | wc -l` -ge 1 ]; then sed -i "s?/usr/local/sbin/set-cpu??" /etc/rc.local fi if [ -f /etc/systemd/system/cpu_governor.service* ]; then rm /etc/systemd/system/cpu_governor.service* fi update-rc.d cpu_governor defaults } fix_user_groups() { if [ `groups $USER | grep tty | wc -l` -lt 1 ]; then adduser $USER tty fi } update_boot() { # XU3 if [ "x$board" == "xexynos5" ]; then if [ `grep -c "HDMI / DVI Mode Selection" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p0 -N < boot/XU3/boot-20160119.diff [ -f /boot/boot.ini.rej ] && rm /boot/boot.ini.rej fi if [ `grep -c "1024x600 without monitor data using generic information (ODROID VU7+)" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p0 -N < boot/XU3/boot-20160419.diff [ -f /boot/boot.ini.rej ] && rm /boot/boot.ini.rej fi if [ `grep -c "HDMI CEC Configuration" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p0 -N < boot/XU3/boot-20160825.diff [ -f /boot/boot.ini.rej ] && rm /boot/boot.ini.rej fi if [ `grep -c "DRAM Frequency" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p0 -N < boot/XU3/boot-20170322.diff [ -f /boot/boot.ini.rej ] && rm /boot/boot.ini.rej fi # check for net.ifnames=0 if [ `grep "net.ifnames=0" /boot/boot.ini | wc -l` -lt 1 ]; then sed -i "s/fsck.repair=yes\"/fsck.repair=yes net.ifnames=0\"/" /boot/boot.ini fi # fix hud_quirks sed -i "s/hud_quirks/hid_quirks/" /boot/boot.ini fi # C2 if [ "x$board" == "xodroidc2" ]; then if [ `grep "setenv hpd" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160506.diff fi if [ `grep "# Meson Timer" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160525.diff fi if [ `grep "# Server Mode (aka. No Graphics)" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160526.diff patch -d /boot -p1 -N < boot/C2/boot-20160528.diff patch -d /boot -p1 -N < boot/C2/boot-20160608.diff elif [ `grep "then fdt rm /reserved-memory; fdt rm /aocec; fdt rm /mali@d00c0000; fi" /boot/boot.ini | wc -l` -ge 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160528.diff patch -d /boot -p1 -N < boot/C2/boot-20160608.diff elif [ `grep "then fdt rm /meson-fb; fdt rm /amhdmitx; fdt rm /picdec; fdt rm /ppmgr; fi" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160608.diff fi if [ `grep "setenv m \"3440x1440p60hz\"" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160703.diff fi if [ `grep "setenv m \"1600x1200p60hz\"" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160802.diff fi if [ `grep "# Custom modeline!" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160903.diff fi if [ `grep "# CPU Frequency / Cores control" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160911.diff fi if [ `grep "# Force HDMI to use RGB colorspace regardless of TV request" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20160926.diff fi if [ `grep "then setenv cec \"\\\${cec},forcergb\";" /boot/boot.ini | wc -l` -ge 1 ]; then patch -f /boot/boot.ini -p0 -N < boot/C2/boot-20160930.diff fi if [ `grep "# setent m \"480x800p60hz\"" /boot/boot.ini | wc -l` -ge 1 ]; then sed -i "s/# setent m \"480x800p60hz\"/# setenv m \"480x800p60hz\"/" /boot/boot.ini fi if [ `grep "setenv m \"480x800p60hz\"" /boot/boot.ini | wc -l` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20161228.diff fi if [ `grep -c "disableuhs" /boot/boot.ini` -lt 2 ] || [ `grep -c "mmc_removable" /boot/boot.ini` -lt 2 ] || [ `grep -c "usbmulticam" /boot/boot.ini` -lt 2 ]; then patch -d /boot -p1 -N < boot/C2/boot-20170120.diff fi if [ `grep -c "cec0" /boot/boot.ini` -ge 1 ]; then patch -d /boot -p1 -N < boot/C2/boot-20170709.diff fi if [ `grep -c "# Disable/Enable ODROID-VU7 Touchscreen" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/vu7.diff fi if [ `grep -c "# Auto Detection of Monitor settings based on your Screen information" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/edid_auto_detect.diff fi if [ `grep -c "setenv m \"480x320p60hz\"" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C2/480x320p60hz.diff fi fi # C1 if [ "x$board" == "xodroidc1" ]; then if [ `grep -c "monitor_onoff" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C1/boot-20160825.diff sed -i "s/\${enabledac}\"/\${enabledac} monitor_onoff=\${monitor_onoff}\"/" /boot/boot.ini fi if [ `grep -c "max_freq" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C1/boot-20161125.diff sed -i "s/monitor_onoff=\${monitor_onoff}\"/monitor_onoff=\${monitor_onoff} max_freq=\${max_freq}\"/" /boot/boot.ini fi if [ `grep -c "480x800p60hz" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C1/boot-20161210.diff fi if [ `grep -c "480x800" /etc/initramfs-tools/scripts/local-top/c1_init.sh` -lt 1 ]; then patch -p1 -d /etc/initramfs-tools/scripts/local-top/ -N < fixes/C1/c1_init.sh.diff.20161210 cleanup_c1_init.sh update-initramfs -c -u -k all fi if [ `grep -c "disable_vu7" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/C1/boot-20170227.diff sed -i "s/max_freq=\${max_freq}\"/max_freq=\${max_freq} \${hid_quirks}\"/" /boot/boot.ini fi if [ `grep -c "fsck.repair=yes" /boot/boot.ini` -lt 1 ]; then sed -i "s/no_console_suspend/no_console_suspend fsck.repair=yes/" /boot/boot.ini fi fi # N1 if [ "x$board" == "xodroidn1" ]; then # fix SD boot sed -i "s/load mmc 0/load mmc \$\{bootdev\}/" /boot/boot.ini # fix rootwait rw -> rootwait ro sed -i "s/rootwait rw/rootwait ro/" /boot/boot.ini # option to disable VU7 if [ `grep -c "disable_vu7" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/N1/boot-20180301.diff sed -i "s/\${bootrootfs}/\${bootrootfs} disable_vu7=\${disable_vu7}/" /boot/boot.ini fi fi # N2 if [ "x$board" == "xodroidn2" ]; then # enable cvbs if adc detects it if [ `grep -c "cvbscable" /boot/boot.ini` -lt 1 ]; then sed -i "s/\${disablehpd}/\${disablehpd} cvbscable=\${cvbscable}/" /boot/boot.ini fi # add overscan percentage if [ `grep -c "overscan" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/N2/overscan.diff sed -i "s/\${disablehpd}/\${disablehpd} overscan=\${overscan}/" /boot/boot.ini fi # add option to 2Ghz if [ `grep -c "setenv max_freq_a73 \"2004\"" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/N2/2GHz.diff fi # add support for hdmi auto detect if [ `grep -c "display_autodetect" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/N2/display_autodetect.diff sed -i "s/\${disablehpd}/\${disablehpd} \${cmode}/" /boot/boot.ini fi # add support for ODROID-VU7 if [ `grep -c "# Hardkernel ODROID-VU7 support" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/N2/VU7-support.diff sed -i "s/\${disablehpd}/\${disablehpd} \${hid_quirks}/" /boot/boot.ini fi # add support for 480x272p60hz if [ `grep -c "480x272p60hz" /boot/boot.ini` -lt 1 ]; then patch -d /boot -p1 -N < boot/N2/480x272p60hz.diff fi # fix mounting of rootfs (should be ro at boot) if [ `grep -c "rootwait rw" /boot/boot.ini` -gt 0 ]; then sed -i "s/rootwait rw/rootwait ro/" /boot/boot.ini fi # set board to "odroidn2" if [ `grep -c "setenv board \"odroidn2\"" /boot/boot.ini` -lt 1 ]; then sed -i "/ODROIDN2-UBOOT-CONFIG/a\\\nsetenv board \"odroidn2\"" /boot/boot.ini fi # add support for monitor output on/off if [ `grep -c "# Monitor output" /boot/boot.ini` -lt 1 ]; then sed -i "/setenv display_autodetect \"true\"/a\\\n# Monitor output\n# Controls if HDMI PHY should output anything to the monitor\nsetenv monitor_onoff \"false\"" /boot/boot.ini sed -i "s/\${disablehpd}/\${disablehpd} monitor_onoff=\${monitor_onoff}/" /boot/boot.ini fi # boot-logo? if [ `grep -c "logo=osd0,loaded" /boot/boot.ini` -lt 1 ]; then sed -i "s/\${disablehpd}/\${disablehpd} logo=osd0,loaded/" /boot/boot.ini fi # disable console blank if [ `grep -c "consoleblank=0" /boot/boot.ini` -lt 1 ]; then sed -i "s/\${disablehpd}/\${disablehpd} consoleblank=0/" /boot/boot.ini fi # add support for SDR/HDR if [ `grep -c "# SDR/HDR Configuration" /boot/boot.ini` -lt 1 ]; then sed -i "/setenv monitor_onoff \"false\"/a\\\n# SDR/HDR Configuration\n# This forces SDR or HDR modes\n# valid options are: sdr hdr auto\nsetenv sdrmode \"auto\"" /boot/boot.ini sed -i "s/\${disablehpd}/\${disablehpd} sdrmode=\${sdrmode}/" /boot/boot.ini fi # add CEC support if [ `grep -c "# Enable/Disable CEC" /boot/boot.ini` -lt 1 ]; then sed -i "/setenv sdrmode \"auto\"/a\\\n# Enable/Disable CEC\nsetenv cec \"true\"" /boot/boot.ini fi if [ `grep -c "# CEC Support" /boot/boot.ini` -lt 1 ]; then sed -i "/# VU7 Settings/i# CEC Support\nif test \"\${cec}\" = \"true\"; then setenv cec_enable \"hdmitx=cec3f\"; fi\n" /boot/boot.ini sed -i "s/\${disablehpd}/\${disablehpd} \${cec_enable}/" /boot/boot.ini fi # add Wake-On-LAN support if [ `grep -c "# Wake-On-Lan support (0=disable, 1=enable)" /boot/boot.ini` -lt 1 ]; then sed -i "/setenv cec \"true\"/a\\\n# Wake-On-Lan support (0=disable, 1=enable)\nsetenv enable_wol \"0\"" /boot/boot.ini sed -i "s/\${disablehpd}/\${disablehpd} enable_wol=\${enable_wol}/" /boot/boot.ini fi # new CPU speeds # first cleanup old entries: # the line above the first line should be gone if [ `grep -c "# max cpu frequency for big core, A73 in MHz unit" /boot/boot.ini` -ge 1 ]; then line=$(($(grep -n "# max cpu frequency for big core, A73 in MHz unit" /boot/boot.ini | cut -d ":" -f1)-1)) sed -i "${line}d" /boot/boot.ini sed -i "/# max cpu frequency for big core, A73 in MHz unit/d" /boot/boot.ini sed -i "/setenv max_freq_a73/d" /boot/boot.ini sed -i "/# max cpu frequency for little core, A53 in MHz unit/d" /boot/boot.ini # remove the line after the last line line=$(($(grep -n "setenv max_freq_a53" /boot/boot.ini | tail -n1 | cut -d ":" -f1)+1)) sed -i "${line}d" /boot/boot.ini sed -i "/setenv max_freq_a53/d" /boot/boot.ini # add new values if [ `grep -c "# Maximum CPU frequency of ARM A73" /boot/boot.ini` -lt 1 ]; then sed -i "/# max cpu-cores/i# Maximum CPU frequency of ARM A73\n# N2: 500/667/1000/1200/1398/1512/1608/1704/1800 (Stock)/1908/2004\n# N2 Plus: 500/667/1000/1200/1398/1512/1608/1704/1800/1908/2016/2100/2208 (Stock)/2304/2400\n# setenv max_freq_a73 \"1800\"\n\n# Maximum CPU frequency of ARM A53\n# N2: 100/250/500/667/1000/1200/1398/1512/1608/1704/1896 (Stock)/1992\n# N2 Plus: 500/667/1000/1200/1398/1512/1608/1704/1800/1908 (Stock)/2016\n# setenv max_freq_a53 \"1896\"\n\n" /boot/boot.ini fi fi # ODROID N2+ support if [ `grep -c "if test \"\\\${variant}\" = \"n2_plus\"; then" /boot/boot.ini` -lt 1 ]; then # use .* in case someone manually switched to n2_plus sed -i "s/fatload mmc \${devno}:1 \${dtb_loadaddr}.*/if test \"\${variant}\" = \"n2_plus\"; then\n\tfatload mmc \${devno}:1 \${dtb_loadaddr} meson64_odroidn2_plus.dtb\n# acts as fallback\nelse\n\tfatload mmc \${devno}:1 \${dtb_loadaddr} meson64_odroidn2.dtb\nfi/" /boot/boot.ini fi # Overlay support if [ `grep -c "# Device Tree Overlay" /boot/boot.ini` -lt 1 ]; then sed -i "/setenv enable_wol \"0\"/a\\\n\# Device Tree Overlay\n# Overlay profiles\n# default = \"spi0 i2c0 i2c1 uart0\"\n# hktft32 = \"hktft32\" // 3.2\" TFT from HardKernel\n# hktft35 = \"hktft35\" // 3.5\" TFT from HardKernel\n# custom // load your own set of overlays -> use overlay_custom to specify\nsetenv overlay_resize \"16384\"\nsetenv overlay_profile \"default\"\nsetenv overlay_custom \"i2c0 i2c1\"\n" /boot/boot.ini sed -i "/if test \"\${disable_vu7}\" = \"false\"; then setenv hid_quirks \"usbhid.quirks=0x0eef:0x0005:0x0004\"; fi/a\\\n# Define which overlays to use\nif test \"\${overlay_profile}\" = \"default\"; then setenv overlays \"spi0 i2c0 i2c1 uart0\"; fi\nif test \"\${overlay_profile}\" = \"hktft32\"; then setenv overlays \"hktft32\"; fi\nif test \"\${overlay_profile}\" = \"hktft35\"; then setenv overlays \"hktft35\"; fi\nif test \"\${overlay_profile}\" = \"custom\"; then setenv overlays \"\${overlay_custom}\"; fi\n" /boot/boot.ini sed -i "/setenv dtb_loadaddr \"0x1000000\"/asetenv dtbo_addr_r \"0x11000000\"" /boot/boot.ini sed -i "/fdt addr \${dtb_loadaddr}/a\\\nif test \"x\${overlays}\" != \"x\"; then\n\tfdt resize \${overlay_resize}\n\tfor overlay in \${overlays}; do\n\t\tfatload mmc \${devno}:1 \${dtbo_addr_r} overlays/\${board}/\${overlay}.dtbo && fdt apply \${dtbo_addr_r}\n\tdone\nfi\n" /boot/boot.ini fi # fix overlay typos if [ `grep -c 'hktft32 = "hktft32" // 3.5\" TFT from HardKernel' /boot/boot.ini` -ge 1 ]; then sed -i "s?hktft32 = \"hktft32\" // 3.5\" TFT from HardKernel?hktft35 = \"hktft35\" // 3.5\" TFT from HardKernel?" /boot/boot.ini fi if [ `grep -c 'if test "x{overlays}"' /boot/boot.ini` -ge 1 ]; then sed -i 's/if test "x{overlays}"/if test "x${overlays}"/' /boot/boot.ini fi fi # C4 if [ "x$board" == "xodroidc4" ]; then # set board to "odroidc4" if [ `grep -c "setenv board \"odroidc4\"" /boot/boot.ini` -lt 1 ]; then sed -i "/ODROIDC4-UBOOT-CONFIG/a\\\nsetenv board \"odroidc4\"" /boot/boot.ini fi # fix mounting of rootfs (should be ro at boot) if [ `grep -c "rootwait rw" /boot/boot.ini` -gt 0 ]; then sed -i "s/rootwait rw/rootwait ro/" /boot/boot.ini fi # cleanup if [ `grep -c "max_freq_a73=\${max_freq_a73}" /boot/boot.ini` -ge 1 ]; then sed -i "s/max_freq_a73=\${max_freq_a73} //" /boot/boot.ini fi # add Wake-On-LAN support if [ `grep -c "# Wake-On-Lan support (0=disable, 1=enable)" /boot/boot.ini` -lt 1 ]; then sed -i "/### Normal HDMI Monitors/i# Wake-On-Lan support (0=disable, 1=enable)\nsetenv enable_wol \"0\"\n" /boot/boot.ini sed -i "s/sdrmode=\${sdrmode}/sdrmode=\${sdrmode} enable_wol=\${enable_wol}/" /boot/boot.ini fi # new CPU speeds # first cleanup old entries: # the line above the first line should be gone if [ `grep -c "# max cpu frequency for little core, A55 in MHz unit" /boot/boot.ini` -ge 1 ]; then line=$(($(grep -n "# max cpu frequency for little core, A55 in MHz unit" /boot/boot.ini | cut -d ":" -f1)-1)) sed -i "${line}d" /boot/boot.ini sed -i "/# max cpu frequency for little core, A55 in MHz unit/d" /boot/boot.ini sed -i "/setenv max_freq_a55/d" /boot/boot.ini if [ `grep -c "Maximum CPU frequency" /boot/boot.ini` -lt 1 ]; then sed -i "/# max cpu-cores/i# Maximum CPU frequency\n# 100/250/500/667/1000/1200/1404/1500/1608/1704/1800/1908 (stock)/2016/2100\n# max_freq_a55=1908\n" /boot/boot.ini fi fi # Overlay support if [ `grep -c "# Device Tree Overlay" /boot/boot.ini` -lt 1 ]; then sed -i "/setenv enable_wol \"0\"/a\\\n\# Device Tree Overlay\n# Overlay profiles\n# default = \"spi0 i2c0 i2c1 uart0\"\n# hktft32 = \"hktft32\" // 3.2\" TFT from HardKernel\n# hktft35 = \"hktft35\" // 3.5\" TFT from HardKernel\n# custom // load your own set of overlays -> use overlay_custom to specify\nsetenv overlay_resize \"16384\"\nsetenv overlay_profile \"default\"\nsetenv overlay_custom \"i2c0 i2c1\"\n" /boot/boot.ini sed -i "/if test \"\${disable_vu7}\" = \"false\"; then setenv hid_quirks \"usbhid.quirks=0x0eef:0x0005:0x0004\"; fi/a\\\n# Define which overlays to use\nif test \"\${overlay_profile}\" = \"default\"; then setenv overlays \"spi0 i2c0 i2c1 uart0\"; fi\nif test \"\${overlay_profile}\" = \"hktft32\"; then setenv overlays \"hktft32\"; fi\nif test \"\${overlay_profile}\" = \"hktft35\"; then setenv overlays \"hktft35\"; fi\nif test \"\${overlay_profile}\" = \"custom\"; then setenv overlays \"\${overlay_custom}\"; fi\n" /boot/boot.ini sed -i "/setenv dtb_loadaddr \"0x1000000\"/asetenv dtbo_addr_r \"0x11000000\"" /boot/boot.ini sed -i "/fdt addr \${dtb_loadaddr}/a\\\nif test \"x\${overlays}\" != \"x\"; then\n\tfdt resize \${overlay_resize}\n\tfor overlay in \${overlays}; do\n\t\tfatload mmc \${devno}:1 \${dtbo_addr_r} overlays/\${board}/\${overlay}.dtbo && fdt apply \${dtbo_addr_r}\n\tdone\nfi\n" /boot/boot.ini fi # fix overlay typos if [ `grep -c 'hktft32 = "hktft32" // 3.5\" TFT from HardKernel' /boot/boot.ini` -ge 1 ]; then sed -i "s?hktft32 = \"hktft32\" // 3.5\" TFT from HardKernel?hktft35 = \"hktft35\" // 3.5\" TFT from HardKernel?" /boot/boot.ini fi if [ `grep -c 'if test "x{overlays}"' /boot/boot.ini` -ge 1 ]; then sed -i 's/if test "x{overlays}"/if test "x${overlays}"/' /boot/boot.ini fi # ODROID HC4 support if [ `grep -c "if test \"x\\\${variant}\" != \"x\"; then" /boot/boot.ini` -lt 1 ]; then # use .* in case someone manually switched to hc4 sed -i "s/fatload mmc \${devno}:1 \${dtb_loadaddr}.*/if test \"x\${variant}\" != \"x\"; then\n\tfatload mmc \${devno}:1 \${dtb_loadaddr} meson64_odroid\${variant}.dtb\n# acts as fallback\nelse\n\tfatload mmc \${devno}:1 \${dtb_loadaddr} meson64_odroidc4.dtb\nfi/" /boot/boot.ini fi fi # GO2/GO3 if [ "x$board" == "xodroidgo2" ] || [ "x$board" == "xodroidgo3" ]; then # fix mounting of rootfs (should be ro at boot) if [ `grep -c "rootwait rw" /boot/boot.ini` -gt 0 ]; then sed -i "s/rootwait rw/rootwait ro/" /boot/boot.ini; fi # output console to ttyFIQ0 if [ `grep -c "console=/dev/ttyFIQ0" /boot/boot.ini` -lt 1 ]; then sed -i "s/fbcon=rotate:3/fbcon=rotate:3 console=\/dev\/ttyFIQ0/" /boot/boot.ini; fi # console always on if [ `grep -c "consoleblank=0" /boot/boot.ini` -lt 1 ]; then sed -i "s/fbcon=rotate:3/fbcon=rotate:3 consoleblank=0/" /boot/boot.ini; fi # use UUID instead of /dev/mmcblk0p2 if [ `grep -c "root=/dev/mmcblk0p2" /boot/boot.ini` -gt 0 ]; then sed -i "s/root=\/dev\/mmcblk0p2/root=UUID=\'e139ce78-9841-40fe-8823-96a304a09859\'/" /boot/boot.ini; fi # re-enable uInitrd support if [ `grep -c "uInitrd" /boot/boot.ini` -lt 1 ]; then sed -i "/load mmc 1:1 \${loadaddr} Image/aload mmc 1:1 \${initrd_loadaddr} uInitrd" /boot/boot.ini; fi if [ `grep -c "booti \${loadaddr} \${initrd_loadaddr} \${dtb_loadaddr}" /boot/boot.ini` -lt 1 ]; then sed -i "s/booti \${loadaddr} - \${dtb_loadaddr}/booti \${loadaddr} \${initrd_loadaddr} \${dtb_loadaddr}/" /boot/boot.ini; fi # support for ODROID Go Advance v1.1 if [ `grep -c "rk3326-odroidgo2-linux-v11.dtb" /boot/boot.ini` -lt 1 ]; then sed -i "s/load mmc 1:1 \${dtb_loadaddr} rk3326-odroidgo2-linux.dtb/\nif test \${hwrev} = 'v11'; then\nload mmc 1:1 \${dtb_loadaddr} rk3326-odroidgo2-linux-v11.dtb\nelse\nload mmc 1:1 \${dtb_loadaddr} rk3326-odroidgo2-linux.dtb\nfi/" /boot/boot.ini; fi # support for ODROID GO3 if [ `grep -c "rk3326-odroidgo3-linux.dtb" /boot/boot.ini` -lt 1 ]; then sed -i "s/rk3326-odroidgo2-linux-v11.dtb/rk3326-odroidgo2-linux-v11.dtb\nelif test \${hwrev} = 'v10-go3'; then\nload mmc 1:1 \${dtb_loadaddr} rk3326-odroidgo3-linux.dtb/" /boot/boot.ini fi # undocumented change from ODROIDGO2-UBOOT-CONFIG to odroidgoa-uboot-config in boot.ini if [ `grep -c ODROIDGO2-UBOOT-CONFIG /boot/boot.ini` -ge 1 ]; then sed -i "s/ODROIDGO2-UBOOT-CONFIG/odroidgoa-uboot-config/" /boot/boot.ini fi fi } fix_youtube() { if [ -d /home/$USER/.kodi/addons/plugin.video.youtube ]; then cd Kodi unzip -qqo plugin.video.youtube-*.zip if [ "x`find plugin.video.youtube -type f -exec md5sum {} \; | sort -k 34 | md5sum`" != "x`find /home/$USER/.kodi/addons/plugin.video.youtube -type f -exec md5sum {} \; | sort -k 34 | md5sum`" ]; then rm -rf /home/$USER/.kodi/addons/plugin.video.youtube rm -rf /home/$USER/.kodi/userdata/addon_data/plugin.video.youtube mv plugin.video.youtube /home/$USER/.kodi/addons/ chown -R $USER:$USER /home/$USER/.kodi/addons/plugin.video.youtube fi cd .. elif [ -d /home/$USER/.xbmc/addons/plugin.video.youtube ]; then cd Kodi unzip -qqo plugin.video.youtube-*.zip if [ "x`find plugin.video.youtube -type f -exec md5sum {} \; | sort -k 34 | md5sum`" != "x`find /home/$USER/.xbmc/addons/plugin.video.youtube -type f -exec md5sum {} \; | sort -k 34 | md5sum`" ]; then rm -rf /home/$USER/.xbmc/addons/plugin.video.youtube rm -rf /home/$USER/.xbmc/userdata/addon_data/plugin.video.youtube mv plugin.video.youtube /home/$USER/.xbmc/addons/ chown -R $USER:$USER /home/$USER/.xbmc/addons/plugin.video.youtube fi fi } add_user_to_groups() { # GPIO Mem if [ `groups $USER | grep -c "sys"` -lt 1 ]; then adduser $USER sys || true fi } fix_cups() { # disable old parallel ports Kernel modules if [ -f /etc/modules-load.d/cups-filters.conf ]; then sed -i "s/^lp/#lp/" /etc/modules-load.d/cups-filters.conf sed -i "s/^ppdev/#ppdev/" /etc/modules-load.d/cups-filters.conf sed -i "s/^parport_pc/#parport_pc/" /etc/modules-load.d/cups-filters.conf fi } fix_jessie_apt() { # Jessie is now LTS support only and some repos need to be adjusted . /etc/os-release if [ ! -z $VERSION_ID ] && [ $VERSION_ID -eq 8 ]; then # jessie-backports is "outdated" and need to ignore "valid-until" parameter if [ ! -f /etc/apt/apt.conf.d/99-no-valid-until ]; then cp "/usr/local/share/setup-odroid/apt/99-no-valid-until" /etc/apt/apt.conf.d/ fi # jessie-update / jessie-proposed-updates repository no longer exists sed -i "/jessie-updates/d" /etc/apt/sources.list sed -i "/jessie-proposed-updates/d" /etc/apt/sources.list # jessie-backports now on archive sed -i "s?http://ftp.debian.org/debian jessie-backports?/http://archive.debian.org/debian jessie-backports?" /etc/apt/sources.list fi } general_fixes() { # allow root login on UART console if [ -f /etc/securetty ] && [ `grep -c "ttySAC1" /etc/securetty` -lt 1 ]; then echo "# ODROID ttySAC0 ttySAC1 ttySAC2 ttySAC3" >> /etc/securetty fi if [ "x`cat /proc/cpuinfo | grep Hardware | awk '{print $3}'`" == "xODROID-XU3" ]; then if [ ! -f /etc/modprobe.d/blacklist-odroid.conf ] || [ `grep -c "ads7846" /etc/modprobe.d/blacklist-odroid.conf` -lt 1 ]; then echo "blacklist ads7846" >> /etc/modprobe.d/blacklist-odroid.conf fi fi # make sure initramfs-tools hook for uInitrd is present if [ ! -f /etc/initramfs-tools/hooks/uInitrd ]; then cp /usr/local/share/setup-odroid/fixes/General/uInitrd /etc/initramfs-tools/hooks/uInitrd fi # issue was related to a changed boot.ini header # if [ $board == "odroidgo2" ] || [ $board == "odroidgo3" ]; then # # returns enx wlanx back to eth0 and wlan0 # if [ ! -L /etc/udev/rules.d/80-net-setup-link.rules ]; then # ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules # fi # fi # update post- and pre-installation Kernel scripts if [ -f /etc/kernel/preinst.d/remove-old-on-upgrade ] && [ `du -b /etc/kernel/preinst.d/remove-old-on-upgrade | awk '{print $1}'` -gt 1000 ]; then cp -f /usr/local/share/setup-odroid/fixes/General/remove-old-on-upgrade /etc/kernel/preinst.d/remove-old-on-upgrade fi if [ -f /etc/kernel/postinst.d/copy_dtb ] && [ `du -b /etc/kernel/postinst.d/copy_dtb | awk '{print $1}'` -gt 1000 ]; then cp -f /usr/local/share/setup-odroid/fixes/General/copy_dtb /etc/kernel/postinst.d/copy_dtb fi } copy_overlays() { rsync -p /usr/local/share/setup-odroid/fixes/General/copy-overlays /etc/kernel/postinst.d/ } patch_config_ini() { if [ `grep -c "bootlabel=" /boot/config.ini` -lt 1 ]; then sed -i '1 i\; Set bootlable for petitboot (where supported)\n; bootlabel="Debian Bullseye"\n' /boot/config.ini fi if [ `grep -c "Rootdelay:" /boot/config.ini` -lt 1 ]; then echo " ; Rootdelay: ; rootdelay defines how long the Kernel should wait before continue booting ; This may be required if the Kernel/Initramfs is waiting for a attached USB device to be ready ; rootdelay will wait for X seconds before continuing the boot process ; rootdelay=60" >> /boot/config.ini fi if [ `grep -c "Extra bootargs:" /boot/config.ini` -lt 1 ]; then echo " ; Extra bootargs: ; Here you can define your own bootargs in case something is missing ; extraargs=apparmor=1 security=apparmor" >> /boot/config.ini fi } update_flash_kernel() { rsync -rp /usr/local/share/setup-odroid/flash-kernel /etc/ # trigger rebuild of flash-kernel flash-kernel } missing_firmware() { rsync -rp /usr/local/share/setup-odroid/firmware /lib/ } alsa_config() { if [ -d /var/lib/alsa/ ] && [ ! -f /var/lib/alsa/asoun.state ]; then rsync -p /usr/local/share/setup-odroid/alsa/asound.state /var/lib/alsa/ fi # TODO: may cause issues when using HiFi Shield if [ "$board" == "odroidc2" ]; then rsync -p /usr/local/share/setup-odroid/alsa/odroidc2/asound.conf /etc/asound.conf fi if [ "$board" == "odroidc4" ] || [ "$board" == "odroidn2" ]; then rsync -p /usr/local/share/setup-odroid/alsa/odroidc4/asound.conf /etc/asound.conf fi } initramfs_timeout() { if [ `grep -c "slumber=30" /usr/share/initramfs-tools/scripts/local` -ge 1 ]; then sed -i "s/slumber=30/slumber=60/" /usr/share/initramfs-tools/scripts/local update-initramfs -u -k all fi } all() { # user specific fixes users=`awk -F: '($3>=1000)&&($1!="nobody"){print $1}' /etc/passwd` for USER in $users do fix_user_groups # fix_youtube add_user_to_groups done # global fixes fix_ssh fix_blacklist fix_pinning new_cpu_control } old() { # fixes for old Kernel c1_fixes c2_fixes n1_fixes n2_fixes update_boot fix_cups general_fixes fix_jessie_apt } new() { # Kernel 5.10+ copy_overlays patch_config_ini update_flash_kernel missing_firmware alsa_config initramfs_timeout } board_info kernel_info cd /usr/local/share/setup-odroid/ all if [ $KMAJOR -ge 5 ]; then new else old fi