From acdf9c9d664d24c49dbd00b953bfbbfc9919fa1f Mon Sep 17 00:00:00 2001 From: Thomas Kaiser Date: Sat, 20 Feb 2016 14:33:17 +0100 Subject: [PATCH] Make OPi PC/One detection more reliable, less external calls, faster execution due to single dmesg call --- scripts/armhwinfo | 52 ++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/scripts/armhwinfo b/scripts/armhwinfo index 0aae7f670..c1924c87a 100644 --- a/scripts/armhwinfo +++ b/scripts/armhwinfo @@ -8,27 +8,29 @@ # Short-Description: Get some info about hardware for some ARM single board computers and set some basic things ### END INIT INFO -SERVER_IP=$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}') +TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX) +trap "rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15 +dmesg >"${TMPFILE}" +SERVER_IP=$(hostname -I) CORES=$(grep -c ^processor /proc/cpuinfo) -MEMTOTAL=$(awk 'BEGIN { printf "%.0f\n", '$(grep MemTotal /proc/meminfo | awk '{print $2}')'/1024/1024 }') -ARCH=$(lscpu | grep Architecture | awk '{print $2}') -RTC=$(dmesg | grep rtc0 | awk '{print $(NF)}') -HB_PCI=$(dmesg | grep '16c3:abcd') -HARDWARE=$(cat /proc/cpuinfo | grep Hardware | awk '{print $3}') -GMAC=$(dmesg | grep "sun6i_gmac")$(dmesg | grep "gmac0-") -LEDS=$(dmesg |grep "green:ph02:led1") -TERMINUS=$(lsusb | grep "1a40:0101") -SWITCH=$(dmesg | grep "BCM53125") -INTERUPT=$(cat /proc/interrupts | grep "eth0") +MEMTOTAL=$(( $(awk -F" " '/^MemTotal/ {print $2}' /sys/block/$i/queue/scheduler; @@ -54,22 +56,26 @@ if [ "$ARCH" = "armv7l" ]; then ID="Orange H3" if [ "$TERMINUS" != "" ]; then ID="Orange Pi+" - if [ "$MEMTOTAL" = 2 ]; then + if [ $MEMTOTAL -gt 1500 ]; then ID="Orange Pi+ 2" fi if [ "$GMAC" == "" ]; then if [ "$WIFI8189ES" != "" ]; then - ID="Orange Pi 2" + ID="Orange Pi 2" else ID="Orange Pi 2 mini" - fi + fi fi elif [ "$WIFI8189ES" != "" ]; then ID="Orange Pi Lite" - elif [ "$ORANGEPC" != "" ]; then + elif [ $MEMTOTAL -gt 600 ]; then ID="Orange Pi PC" + # redistribute USB irqs to dedicated cores + echo 2 >/proc/irq/$(awk -F":" '/usb2/ {print $1}' /proc/irq/$(awk -F":" '/usb3/ {print $1}' /proc/irq/$(awk -F":" '/usb4/ {print $1}' /proc/irq/$(cat /proc/interrupts | grep eth0 | cut -f 1 -d ":" | tr -d " ")/smp_affinity + echo 2 >/proc/irq/$(awk -F":" '/eth0/ {print $1}' > /var/run/machine.id +echo $ID >> /var/run/machine.id ;; stop|reload|restart|force-reload|status) echo -e "[\e[0;32m ok \x1B[0m] Stopping ARM hardware info ..."