Skip to content

Instantly share code, notes, and snippets.

@darkxanter
Last active December 8, 2022 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darkxanter/2ff7e965035d268eb7b6c1423e059a59 to your computer and use it in GitHub Desktop.
Save darkxanter/2ff7e965035d268eb7b6c1423e059a59 to your computer and use it in GitHub Desktop.
orange pi pc fix voltage
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
if [ "$(id -u)" != "0" ]; then
echo "This script must be executed as root. Exiting" >&2
exit 1
fi
apt-get install git pkg-config libusb-dev libusb-1.0-0-dev build-essential
Path2ScriptBin="$(df | awk -F" " '/^\/dev\/mmcblk0p1/ {print $6}')"
if [ ! -f "${Path2ScriptBin}/script.bin" ]; then
echo "Can not find script.bin. Ensure boot partition is mounted" >&2
exit 1
fi
MyTmpFile="$(mktemp /tmp/${0##*/}.XXXXXX)"
bin2fex "${Path2ScriptBin}/script.bin" /tmp/script.fex
cat /tmp/script.fex | grep -v "^LV" | grep -v "^max_freq" | grep -v "^min_freq" | grep -v "^extremity_freq" >"${MyTmpFile}"
cp -p "${Path2ScriptBin}/script.bin" "${Path2ScriptBin}/script.bin.bak"
sed -i '/\[dvfs_table\]/a \
extremity_freq = 1296000000\
max_freq = 1200000000\
min_freq = 480000000\
LV_count = 7\
LV1_freq = 1296000000\
LV1_volt = 1320\
LV2_freq = 1200000000\
LV2_volt = 1240\
LV3_freq = 1104000000\
LV3_volt = 1180\
LV4_freq = 1008000000\
LV4_volt = 1140\
LV5_freq = 960000000\
LV5_volt = 1080\
LV6_freq = 816000000\
LV6_volt = 1020\
LV7_freq = 480000000\
LV7_volt = 980' "${MyTmpFile}"
fex2bin "${MyTmpFile}" "${Path2ScriptBin}/script.bin" >/dev/null
if [ $? -ne 0 ]; then
mv "${Path2ScriptBin}/script.bin.bak" "${Path2ScriptBin}/script.bin"
echo "Writing script.bin went wrong. Nothing changed" >&2
exit 1
fi
echo "Successfully repaired broken overvolting/overclocking settings. Reboot necessary for changes to take effect"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment