ayufan-rock64 / linux-build

Rock64 Linux build scripts, tools and instructions
MIT License
563 stars 100 forks source link

Errors on openmediavault boot in rock64_fix_performance.sh #405

Open fredericschulz opened 5 years ago

fredericschulz commented 5 years ago

I just installed the stretch-openmediavault-rock64-0.9.14-1159-armhf.img.xz image on my Rock64. On boot I get an error via email telling me

`/usr/local/sbin/rock64_fix_performance.sh: line 10: continue: only meaningful in a `for', `while', or `until' loop
/usr/local/sbin/rock64_fix_performance.sh: line 13: /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor: No such file or directory`

This is the code from the the script:

#!/bin/bash

# Taken from: https://forum.armbian.com/index.php?/topic/3953-preview-generate-omv-images-for-sbc-with-armbian/#comment-34596
# with some additions to better deal with UAS incapable USB-to-SATA bridges.

export PATH=/usr/sbin:/usr/bin:/sbin:/bin

Tweak_CPUFreq_Governor() {
    if [ ! -d $1 ]; then
        continue
    fi

    echo ondemand > $1/cpufreq/scaling_governor

    sleep 0.1

    if [ -d $1/cpufreq/ondemand ]; then
        echo 1 >$1/cpufreq/ondemand/io_is_busy
        echo 25 >$1/cpufreq/ondemand/up_threshold
        echo 10 >$1/cpufreq/ondemand/sampling_down_factor
    fi
}

Tweak_DevFreq_Governor() {
    if [ -d "$1" ]; then
        echo performance > "$1/governor"
    fi
}

SMP_Affinity() {
    for irq in $(awk -F":" "/$1/ {print \$1}" </proc/interrupts); do
        echo "$2" >/proc/irq/$irq/smp_affinity
    done
}

Enable_RPS_and_tweak_IRQ_Affinity() {
    for i in 1 2 3 ; do
        SMP_Affinity ahci 2 # pcie-sata-bridge
        SMP_Affinity 0000:01: 2 # pcie-device
        SMP_Affinity ehci 2
        SMP_Affinity ohci 2
        SMP_Affinity xhci 4
        SMP_Affinity eth0 8
    done
    echo ff >/sys/class/net/eth0/queues/rx-0/rps_cpus
    echo 32768 >/proc/sys/net/core/rps_sock_flow_entries
    echo 32768 >/sys/class/net/eth0/queues/rx-0/rps_flow_cnt
}

Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu0 # rock64 and rockpro64
Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu4 # rockpro64
Tweak_DevFreq_Governor /sys/class/devfreq/ff9a0000.gpu # rockpro64
Tweak_DevFreq_Governor /sys/class/devfreq/ff300000.gpu # rock64
Tweak_DevFreq_Governor /sys/class/devfreq/dmc # rock64 and rockpro64

Enable_RPS_and_tweak_IRQ_Affinity

exit 0

The first error is thrown because of


if [ ! -d $1 ]; then
    continue
fi

If I got it right the if statement checks if a directory given by the first command line argument does not exist. For me apparrently it does not. So the script trys to "continue" which doesnt work. As the Tweak_CPUFreq_Governor is called later on it checks if it is a rock64 or rockpro64 by checking for a file. I guess in the if statement the script is supposed to exit the Tweak_CPUFreq_Governor function if the file is not found? I replaced the continue with a return and got no error anymore.

tanus10 commented 5 years ago

I have the same problem for months. I am not familiar with the script. Is this, changing continue to return, a reasonable fix?

SebastianHanz commented 4 years ago

Hi guys, the solution is very simple. That script is able to tweak the CPUGovernors of the Rock64 AND the RockPro64 too. Easy way to fix that is to uncomment the function calls that are only used for RockPro64:

nano /usr/local/sbin/rock64_fix_performance.sh

then scroll down with arrows and uncomment like this if you use Rock64:

` Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu0 # rock64 and rockpro64

Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu4 # rockpro64

Tweak_DevFreq_Governor /sys/class/devfreq/ff9a0000.gpu # rockpro64

Tweak_DevFreq_Governor /sys/class/devfreq/ff300000.gpu # rock64 Tweak_DevFreq_Governor /sys/class/devfreq/dmc # rock64 and rockpro64 ` In my case, there are no more emails because of that error

tanus10 commented 4 years ago
Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu0 # rock64 and rockpro64
#Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu4 # rockpro64
#Tweak_DevFreq_Governor /sys/class/devfreq/ff9a0000.gpu # rockpro64
Tweak_DevFreq_Governor /sys/class/devfreq/ff300000.gpu # rock64
Tweak_DevFreq_Governor /sys/class/devfreq/dmc # rock64 and rockpro64

(In case for the Rock64 owner, almost at the end of the file) you mean like this?

SebastianHanz commented 4 years ago
Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu0 # rock64 and rockpro64
#Tweak_CPUFreq_Governor /sys/devices/system/cpu/cpu4 # rockpro64
#Tweak_DevFreq_Governor /sys/class/devfreq/ff9a0000.gpu # rockpro64
Tweak_DevFreq_Governor /sys/class/devfreq/ff300000.gpu # rock64
Tweak_DevFreq_Governor /sys/class/devfreq/dmc # rock64 and rockpro64

(In case for the Rock64 owner, almost at the end of the file) you mean like this?

Exactly