wareck il y a 2 ans
commit
3eb9b9dfb0
9 fichiers modifiés avec 582 ajouts et 0 suppressions
  1. 299 0
      README.MD
  2. BIN
      V56V1PPT
  3. BIN
      amdflash
  4. 198 0
      amdgpu-clocks
  5. 16 0
      amdgpu-clocks.service
  6. 14 0
      amdgpu-custom-states.card1
  7. BIN
      amdmemtweak
  8. 10 0
      oc.sh
  9. 45 0
      setPPT.sh

+ 299 - 0
README.MD

@@ -0,0 +1,299 @@
+## GUIDE-amdgpu-mining-Ubuntu-Server-LTS-18.04.5--04/2021-UPDATED
+Guide to set all up for amdgpu's mining in Ubuntu Server LTS environnement; with Vega10 exemple (RX Vega 56 Pulse) files that you can easily adapt to your config/username!   
+
+I spent a lot of times in learning, trickering, testing, improving tools and configs to write this guide for beginners level understanding.   
+If it's ok for you (i'm sure it will be..:)..) please consider donation, it would be very appreciated!   
+```sh
+BTC: 3DMFX97J1iz65xJRwyiMNNFFWr9qgn4PP3
+LTC: MBeEPQctvNGnFFFsMuJxbLwKMqUBUNHhsN
+ETH: 0x2A2Ae71baE7EefFB21B3430e488a55f555cb9430
+XMR: 86sXqcNXaq3UBG9oMAfst1fXRLicKWE6QKzecf7eooiCa6iQkBC4SUFKkS8zJ1nCSkCEUGUncgYHG8csZead83wu9LeZAZB
+```
+![alt text](https://i.postimg.cc/Hnbv7yKG/Capture-d-cran-du-2020-06-28-19-08-25.png)
+
+## Install 
+#### Burn it on USB Key then boot and follow the installer instructions.  
+**[Ubuntu 18.04.5 LTS ISO](https://releases.ubuntu.com/18.04/ubuntu-18.04.5-live-server-amd64.iso)** 
+
+1- Preferred Boot USB mode : UEFI  
+2-Choose "Boot and install wit HWE Kernel"  
+3-Install Disc:   
+-a Install Ubuntu Server LTS using "entire disc" (only if dedicated disc)  
+Install Ubuntu Server with Ext4 Partition or XFS (fast I/O Capability) and auto-swap creation (file).  
+-b Choose to create custom install on an existing partitions disc  
+UEFI and Legacy creation will differ refer: **[Install Ubuntu 18.04 UEFI/Legacy mode](https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/how-to-install-ubuntu-18-04-lts-bionic-beaver-on-uefi-and-legacy-bios-system.html)**  
+Also feel free to enable openssh deamon install for remote control of your RIG, see further for config...   
+4-Wait install process & update finish and reboot to new environnement  
+
+## Ubuntu Config
+Sudoers file, enable NOPASSWD for user, all commands
+```sh
+sudo visudo
+```
+Replace: 
+```sh
+%sudo ALL=(ALL:ALL) ALL
+```
+to 
+```sh
+%sudo ALL=(ALL:ALL) NOPASSWD: ALL
+```
+Locales fix, adapt to your localisation
+```sh
+sudo ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
+sudo locale-gen fr_FR fr_FR.UTF-8
+timedatectl set-local-rtc 1
+sudo dpkg-reconfigure locales
+sudo apt install libnuma-dev
+```
+### AMD tweaks, fall back to ethX network interface naming
+Edit the grub configuration file:
+```sh
+sudo nano /etc/default/grub
+```
+Replace GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX lines
+```sh
+GRUB_CMDLINE_LINUX_DEFAULT="text amdgpu.ppfeaturemask=0xffffffff amdgpu.vm_fragment_size=9"
+GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
+```
+amdgpu.ppfeaturemask=0xffffffff kernel boot option allows control of GPU power states (GPU / VRAM clocks and voltages)
+
+Update grub configuration
+```sh
+sudo update-grub && sudo update-grub2 && sudo update-initramfs -u -k all
+```
+### Network Configuration:
+Edit network configuration file:
+```sh
+ls /etc/netplan/
+```
+Replace enpXsX to eth0 in *.yamllibnuma-dev
+```sh
+sudo nano /etc/netplan/*.yaml
+```
+EDIT *.yaml as below, also you can check how to config netplan.[Read more here](https://documentation.online.net/fr/dedicated-server/network/network-configuration-with-netplan)
+```sh
+network:
+    ethernets:
+        eth0:
+            dhcp4: true
+    version: 2
+```
+Apply Config:
+```sh
+sudo netplan apply && sudo reboot
+```
+
+### Install AMDGPU Driver + OpenCL
+Download amdgpu-drivers with rocm-libs, on 04/21 >=20.40 recommended due to "large alloc memory" possibility!
+```sh
+sudo dpkg --add-architecture i386
+sudo apt install wget gnupg2
+wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
+echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/debian/ ubuntu main' | sudo tee /etc/apt/sources.list.d/rocm.list
+sudo apt update
+sudo apt install rocm-smi-lib4.2.0
+wget https://drivers.amd.com/drivers/linux/amdgpu-pro-20.40-1147287-ubuntu-18.04.tar.xz --referer https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-20-40
+tar -Jxvf amdgpu-pro-20.40-1147287-ubuntu-18.04.tar.xz
+cd amdgpu-pro-20.40-1147287-ubuntu-18.04
+./amdgpu-pro-install -y --opencl=pal,legacy,rocm --headless 
+```
+Add yourself to the video group
+```sh
+sudo usermod -aG video $LOGNAME
+```
+### Upgrade and install tools (usefull only; no deep shits!)
+```sh
+sudo apt update && sudo apt upgrade
+sudo apt install build-essential cmake git libuv1-dev libssl-dev libhwloc-dev libmicrohttpd-dev lm-sensors htop opencl-amdgpu-pro-dev opencl-amdgpu-pro ocl-icd-opencl-dev clinfo
+sudo reboot
+```
+## RainbowMiner Installation
+RainbowMiner is for me, the best multipool mining manager ever coded; feel free to install or choose to mine without!
+[More Here](https://github.com/RainbowMiner/RainbowMiner)
+```sh
+sudo apt-get update
+git clone https://github.com/rainbowminer/RainbowMiner
+cd RainbowMiner
+chmod +x *.sh
+sudo ./install.sh
+./start.sh ### Will start RainbowMiner; insure all is ready for it!
+```
+### SSH Remote Control
+If you didn't check openssh installation during Ubuntu install:
+```sh
+sudo apt-get update
+sudo apt-get install openssh-server
+```
+You are ready to log into your remote machine type on another computer to access:
+```sh
+ssh username@public_IP 
+```
+I Recommend to change port in /etc/ssh/sshd_config to something like "2009" or other! then add "-p portnumber"  
+
+If you do not know the IP address, you can quickly identify it through the terminal by typing the command:
+```sh
+ip a
+```
+If you want to improve security and ssh config (non standard port, or encrypt access) see: [SSH Security](https://anansewaa.com/quick-tips-to-harden-ssh-on-ubuntu/)
+
+### Use [Tmux](http://manpages.ubuntu.com/manpages/xenial/man1/tmux.1.html) 
+Terminal multiplexer to prevent mining activities to be stopped when SSH session is closed, you find full config file in my tools, just copy to home folder as .tmux.conf
+
+For exemple: if your SSH session number 0 ends and you want to get back existing Tmux session when reconnecting
+```sh
+tmux attach -t 0
+```
+#### Autostart Miners
+Create a script using tmux to start miners (this is an exemple for 2 sessions in parallel)
+```sh
+#!/bin/sh
+tmux new-session -d -s Session1
+tmux new-session -d -s Session2
+tmux send-keys -t Session1 "cd ~/teamredminer-v0.8.4-linux && sudo ./start_eth.sh" C-m
+tmux send-keys -t Session2 "cd RainbowMiner && ./start.sh" C-m
+```
+Make it executable
+```sh
+chmod +x *.sh
+```
+Use Crontab to execute autostart script
+```sh
+crontab -e
+```
+Then add full path to your script
+EDIT: you can edit your /etc/crontab as root (sudo) to run as specific user, not as root. Very important for RainbowMiner !!!
+
+## Tools
+Here is my ultimate collection of tools to Overclock and Mine over Linux. Download and make it able to run.
+```sh
+git clone https://github.com/ArSd-g/anytech-mining
+cd anytech-mining
+chmod +x *.sh && chmod +x amd*
+```
+#### Atiflash
+Ati flash allow you to dump, save and flash bios on AMD cards, you will find them here:[TechpowerUp](https://www.techpowerup.com/vgabios)
+```sh
+chmod +x amdflash
+sudo cp amdflash /usr/bin
+sudo amdflash -h
+```
+Save Bios
+```sh
+sudo ./amdflash -s 0 CARD-NAME.rom ##Not Working? Use -f flag to force"
+```
+Flash Bios
+```sh
+sudo ./amdflash -p 0 CARD-NAME.rom ##Not Working? Use "-f" flag to force"
+```
+#### HugePages
+Set recommended nbr of hugepages to 4096 per numa node.
+```sh
+sudo nano /proc/sys/vm/nr_hugepages
+```
+## Overclocking
+- Write Power Play Table, in this exemple for GPU number 1 write the content of V56V1PPT (Ethash-Algo Vega56-Pulse-P2-1000Mhz-850Mv/Mem-950Mhz-850Mv).!!reset on every reboot!!
+```sh
+sudo ./setPPT.sh 1 V56V1PPT
+```
+- Install amdgpu-clocks to overclock GPU and select P-States; Simply place the script in /usr/bin/amdgpu-clocks:
+```sh
+sudo cp amdgpu-clocks /usr/bin/
+```
+Then copy exemple to or save/edit: 
+```sh
+cp amdgpu-custom-states.card1 /etc/default/
+```
+If you want your GPU to be overclocked at boot time; place 'amdgpu-clocks.service' in systemd services, remember to edit it to work with your paths/files:
+```sh
+cp amdgpu-clocks.service /lib/systemd/system/
+sudo systemctl enable --now amdgpu-clocks
+sudo reboot
+```
+After reboot check if Overclocking service is ok by:
+```sh
+sudo systemctl status amdgpu-clocks
+```
+#### AMD Memory Tweak
+```sh
+sudo cp amdmemtweak /usr/bin
+```
+Apply memory strap on AMD Cards to improve hashrates, This is a 'Stock-Bios-Vega56-Pulse-Hynix-Memory' exemple on GPU 0 and 1 for ETHASH:
+```sh
+sudo ./amdmemtweak --i 0,1 --cl 20 --ras 23 --rcdrd 15 --rcdwr 11 --rc 36 --rp 13 --rrds 3 --rrdl 5 --rtp 6 --faw 12 --cwl 7 --wtrs 4 --wtrl 9 --wr 13 --rfc 248 --REF 65535
+```
+#### Monitor GPU 
+In this exemple it will monitor GPU number 1 and print infos checking every 5s
+```sh
+sudo ./moniterGPU.sh 5 1
+```
+## Process Explained
+Here is an exemple of my 'amdgpu-clocks.service' and 'oc.sh' and how things work on my machine:
+NOTE: As you can see above tools don't use the same way to detect GPU's GPU-1 with 'amdgpuclocks' reading is GPU-0 with amdmemtweak, so beware!
+
+1-System-D calls 'oc.sh' script at every boot which will:  
+    a-Write PPT to Linux GPU PPT (make sure that all required files are in the directory you are working in)  
+    b-Apply AMD-Memory Timings Straps  
+    
+2-System-D calls amdgpu-clocks script which will applied: 'amdgpu-custom-states.card1, amdgpu-custom-states.card2...    
+
+/oc.sh
+```sh
+#!/bin/bash
+sudo ./setPPT.sh 1 V56V3PPT
+sudo ./setPPT.sh 2 V56V3PPT
+sudo ./setPPT.sh 3 V56V3PPT
+sudo ./amdmemtweak --i 0,1 --cl 20 --ras 23 --rcdrd 15 --rcdwr 11 --rc 36 --rp 13 --rrds 3 --rrdl 5 --rtp 6 --faw 12 --cwl 7 --wtrs 4 --wtrl 9 --wr 13 --rfc 248 --REF 65535
+```
+/lib/systemd/system/amdgpu-clocks.service
+```sh
+GNU nano 4.8
+[Unit]
+Description=Set custom amdgpu clocks & voltages
+After=multi-user.target rc-local.service systemd-user-sessions.service
+
+[Service]
+Type=oneshot
+WorkingDirectory=/home/username/RainbowMiner
+ExecStart=/home/username/RainbowMiner/oc.sh
+RemainAfterExit=yes
+ExecStart=/usr/bin/amdgpu-clocks
+ExecStop=/usr/bin/amdgpu-clocks restore
+ExecReload=/usr/bin/amdgpu-clocks
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target
+```
+
+### You are READY!
+Take a deep breath and get ready to configure RainbowMiner
+
+I hope this guide was clear and precise, feel free to contact me for suggestions, questions, corrections or just to say thanks!
+
+### Donate:
+```sh
+BTC: 3DMFX97J1iz65xJRwyiMNNFFWr9qgn4PP3
+LTC: MBeEPQctvNGnFFFsMuJxbLwKMqUBUNHhsN
+ETH: 0x2A2Ae71baE7EefFB21B3430e488a55f555cb9430
+XMR: 86sXqcNXaq3UBG9oMAfst1fXRLicKWE6QKzecf7eooiCa6iQkBC4SUFKkS8zJ1nCSkCEUGUncgYHG8csZead83wu9LeZAZB
+```
+
+### SRCs
+Special thanks for they awesome job and wonderfull tools and guides to:
+- **https://github.com/xmrminer01102018/VegaToolsNConfigs**
+- **https://github.com/RainbowMiner/RainbowMiner**
+- **https://github.com/czombos/AMDGPU-XMR-ETH-Mining-Ubuntu**
+- **https://github.com/patrickschur/amdvbflash**
+
+### Links&Docs
+- **https://releases.ubuntu.com**
+- **https://documentation.online.net/fr/dedicated-server/network/network-configuration-with-netplan**
+- **https://help.ubuntu.com/community/AMDGPU-Driver**
+- **https://wiki.ubuntu.com/Kernel/LTSEnablementStack**
+- **https://www.amd.com/en/support/kb/release-notes/rn-rad-lin-19-50-unified**
+- **https://www.cyberciti.biz/tips/linux-swap-space.html**
+- **https://xmrig.com/docs/miner/hugepages**
+- **https://anansewaa.com/quick-tips-to-harden-ssh-on-ubuntu/**
+- **https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/how-to-install-ubuntu-18-04-lts-bionic-beaver-on-uefi-and-legacy-bios-system.html**
+- **https://www.techpowerup.com**

BIN
V56V1PPT


BIN
amdflash


+ 198 - 0
amdgpu-clocks

@@ -0,0 +1,198 @@
+#!/bin/bash
+
+USER_STATES_PATH=${USER_STATES_PATH:-/etc/default/amdgpu-custom-state}
+SYS_PPFMASK=/sys/module/amdgpu/parameters/ppfeaturemask
+[ ! -r ${SYS_PPFMASK} ] && echo "Can't access ${SYS_PPFMASK}" && exit 2
+
+if [ "$1" == "restore" ]; then
+  RESTORE=true
+fi
+
+function check_ppfeaturemask() {
+  CURRENT_HEX_MASK=$(printf '%#x' "$(( $(cat ${SYS_PPFMASK}) ))")
+  # 0x4000 or 14th bit is one indicating if OverDrive has been enabled
+  OVERDRIVE_MASK=$(printf '%#x' "$(( CURRENT_HEX_MASK & 0x4000 ))")
+  [ "${OVERDRIVE_MASK}" == "0x4000" ] && return 0
+  WANTED_MASK=$(printf '%#x' "$(( CURRENT_HEX_MASK | 0x4000 ))")
+  echo -n "In order to set custom amdgpu power states, enable OverDrive by "
+  echo -n "booting the machine with amdgpu.ppfeaturemask=${WANTED_MASK} "
+  echo    "kernel option" && exit 2
+}
+
+function fill_sclks() {
+  if [ -z "${3}" ]; then     # Vega20 and later ASICs
+    echo "  SCLK state ${1}: ${2}"
+    SCLK[${1}]="s ${1} ${2%*M[Hh]z}"
+  else                       # Vega10 and previous ASICs
+    echo "  SCLK state ${1}: ${2}, ${3}"
+    SCLK[${1}]="s ${1} ${2%*M[Hh]z} ${3%*mV}"
+  fi
+}
+
+function fill_mclks() {
+  if [ -z "${3}" ]; then     # Vega20 and later ASICs
+    echo "  MCLK state ${1}: ${2}"
+    MCLK[${1}]="m ${1} ${2%*M[Hh]z}"
+  else                       # Vega10 and previous ASICs
+    echo "  MCLK state ${1}: ${2}, ${3}"
+    MCLK[${1}]="m ${1} ${2%*M[Hh]z} ${3%*mV}"
+  fi
+}
+
+function fill_vddccurve() {
+  echo "  VDDC Curve state $1: ${2}, ${4}"
+  VDDC_CURVE[${1}]="vc ${1} ${2%*M[Hh]z} ${4%*mV}"
+}
+
+function parse_states() {
+  mapfile -t STATE_LINES < $1
+  for LNNO in "${!STATE_LINES[@]}"; do
+    LINE="${STATE_LINES[$LNNO]}"
+    case ${LINE} in
+      "OD_SCLK:")
+        state_fill_func=fill_sclks ;;
+      "OD_MCLK:")
+        state_fill_func=fill_mclks ;;
+      "OD_VDDC_CURVE:")
+        state_fill_func=fill_vddccurve ;;
+      "VDDC_CURVE_SCLK["[012]"]: "*)
+        ;; # Just ignoring these for now
+      "VDDC_CURVE_VOLT["[012]"]: "*)
+        ;; # Just ignoring these for now
+      "OD_RANGE:")
+        echo "  Maximum clocks & voltages:";;
+      "SCLK: "*)
+        echo "    SCLK clock ${LINE##* }"
+        MAX_SCLK=${LINE##* }
+        MAX_SCLK=${MAX_SCLK%*M[Hh]z}
+        ;;
+      "MCLK: "*)
+        echo "    MCLK clock ${LINE##* }"
+        MAX_MCLK=${LINE##* }
+        MAX_MCLK=${MAX_MCLK%*M[Hh]z}
+        ;;
+      "VDDC: "*)
+        echo "    VDDC voltage ${LINE##* }"
+        MAX_VDDC=${LINE##* }
+        MAX_VDDC=${MAX_VDDC%*mV}
+        ;;
+      [0-9]": "*)
+        $state_fill_func ${LINE%%:*} ${LINE#* }
+        ;;
+      "FORCE_SCLK: "[0-9]*)
+        echo "  Force SCLK state to ${LINE#* }"
+        FORCE_SCLK=${LINE#* }
+        ;;
+      "FORCE_MCLK: "[0-9]*)
+        echo "  Force MCLK state to ${LINE#* }"
+        FORCE_MCLK=${LINE#* }
+        ;;
+      "FORCE_POWER_CAP: "[0-9]*)
+        MICROWATTS=${LINE#* }
+        echo "  Force power cap to ${MICROWATTS%*000000}W"
+        FORCE_POWER_CAP=${LINE#* }
+        ;;
+      "FORCE_PERF_LEVEL: "[a-z]*)
+        echo "  Force performance level to ${LINE#* }"
+        FORCE_LEVEL=${LINE#* }
+        ;;
+      "FORCE_POWER_PROFILE: "[0-9]*)
+        echo "  Force power profile to ${LINE#* }"
+        FORCE_PROFILE=${LINE#* }
+        ;;
+      "#"*) ;;
+      "") ;;
+      *)
+        let "LINE_NUMBER = ${LNNO} + 1"
+        echo "  Unexpected value in ${1}:${LINE_NUMBER}"
+        exit 2
+        ;;
+    esac
+  done
+  if [ "$1" == "${SYS_PP_OD_CLK}" ]; then
+    POWER_LIMIT=$(cat $PWR_CAP_FILE)
+    echo "  Curent power cap: ${POWER_LIMIT%*000000}W"
+  fi
+}
+
+function set_custom_states() {
+  if [ "${FORCE_LEVEL}" ]; then
+    echo ${FORCE_LEVEL} > ${PWR_LEVEL}
+  fi
+  if [ "${FORCE_PROFILE}" ]; then
+    echo ${FORCE_PROFILE} > ${PWR_PROFILE}
+  fi
+  for CSTATE in "${SCLK[@]}"; do
+    echo ${CSTATE} > ${SYS_PP_OD_CLK}
+  done
+  for MSTATE in "${MCLK[@]}"; do
+    echo ${MSTATE} > ${SYS_PP_OD_CLK}
+  done
+  for VDDC_CURVE_STATE in "${VDDC_CURVE[@]}"; do
+    echo ${VDDC_CURVE_STATE} > ${SYS_PP_OD_CLK}
+  done
+  echo 'c' > ${SYS_PP_OD_CLK}
+  if [ "${FORCE_SCLK}" ]; then
+    echo ${FORCE_SCLK} > ${SYS_DPM_SCLK}
+  fi
+  if [ "${FORCE_MCLK}" ]; then
+    echo ${FORCE_MCLK} > ${SYS_DPM_MCLK}
+  fi
+  if [ "${FORCE_POWER_CAP}" ]; then
+    echo ${FORCE_POWER_CAP} > ${PWR_CAP_FILE}
+  fi
+}
+
+function backup_states() {
+  if [ ! -r ${BACKUP_STATE_FILE} ]; then
+    cp ${SYS_PP_OD_CLK} ${BACKUP_STATE_FILE}
+    if [ "${PWR_LEVEL}" == "manual" ]; then
+      echo "FORCE_POWER_PROFILE: 0" >> ${BACKUP_STATE_FILE}
+    fi
+    echo "FORCE_PERF_LEVEL: $(cat ${PWR_LEVEL})" >> ${BACKUP_STATE_FILE}
+    echo "FORCE_POWER_CAP: $(cat ${PWR_CAP_FILE})" >> ${BACKUP_STATE_FILE}
+    echo "Writen initial backup states to ${BACKUP_STATE_FILE}"
+  else
+    echo "Won't write initial state to ${BACKUP_STATE_FILE}, it already exists."
+  fi
+}
+
+function restore_states() {
+  if [ -f ${BACKUP_STATE_FILE} ]; then
+    echo "Restoring all states to the initial defaults from ${BACKUP_STATE_FILE}"
+    USER_STATE_FILE=${BACKUP_STATE_FILE}
+  else
+    echo "Cant't access initial defaults at ${BACKUP_STATE_FILE}, aborting."
+    exit 2
+  fi
+}
+
+check_ppfeaturemask
+
+for USER_STATE_FILE in $(ls -1 ${USER_STATES_PATH}*.card*); do
+  BACKUP_STATE_FILE=/tmp/${USER_STATE_FILE##*/}.initial
+  SYS_PP_OD_CLK=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_od_clk_voltage
+  PWR_LEVEL=/sys/class/drm/${USER_STATE_FILE##*.}/device/power_dpm_force_performance_level
+  PWR_PROFILE=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_power_profile_mode
+  SYS_DPM_SCLK=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_dpm_sclk
+  SYS_DPM_MCLK=/sys/class/drm/${USER_STATE_FILE##*.}/device/pp_dpm_mclk
+  HWMON_PATH=/sys/class/drm/${USER_STATE_FILE##*.}/device/hwmon
+  HWMON_ID=$(ls -1 /sys/class/drm/${USER_STATE_FILE##*.}/device/hwmon)
+  PWR_CAP_FILE=/sys/class/drm/${USER_STATE_FILE##*.}/device/hwmon/${HWMON_ID}/power1_cap
+  if [ -f ${SYS_PP_OD_CLK} ]; then
+    if [ "${RESTORE}" == "true" ]; then
+      restore_states
+    else
+      backup_states
+    fi
+    echo "Detecting the state values at ${SYS_PP_OD_CLK}:"
+    parse_states ${SYS_PP_OD_CLK}
+    echo "Verifying user state values at ${USER_STATE_FILE}:"
+    parse_states ${USER_STATE_FILE}
+    echo "Committing custom states to ${SYS_PP_OD_CLK}:"
+    set_custom_states
+    echo "  Done"
+  else
+    echo "WARNING: ${SYS_PP_OD_CLK} does not exist, skipping!"
+  fi
+done

+ 16 - 0
amdgpu-clocks.service

@@ -0,0 +1,16 @@
+[Unit]
+Description=Set custom amdgpu clocks & voltages
+After=multi-user.target rc-local.service systemd-user-sessions.service
+
+[Service]
+Type=oneshot
+WorkingDirectory=/home/username/RainbowMiner
+ExecStart=/home/username/RainbowMiner/oc.sh
+RemainAfterExit=yes
+ExecStart=/usr/bin/amdgpu-clocks
+ExecStop=/usr/bin/amdgpu-clocks restore
+ExecReload=/usr/bin/amdgpu-clocks
+StandardOutput=syslog
+
+[Install]
+WantedBy=multi-user.target

+ 14 - 0
amdgpu-custom-states.card1

@@ -0,0 +1,14 @@
+# Set custom GPU states 6 & 7:
+OD_SCLK:
+2:       1000MHz         850mV
+# Set custom memory states 1 & 2:
+OD_MCLK:
+3:       950MHz         850mV
+# Only allow SCLK states 5, 6 & 7:
+FORCE_SCLK: 2
+# Force fixed memory state:
+FORCE_MCLK: 3
+# Force power limit (in micro watts):
+FORCE_POWER_CAP: 160000000
+# In order to allow FORCE_SCLK & FORCE_MCLK:
+FORCE_PERF_LEVEL: manual

BIN
amdmemtweak


+ 10 - 0
oc.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+sudo ./setPPT.sh 1 V56V1PPT
+#sudo ./setPPT.sh 2 V56V1PPT
+#sudo ./setPPT.sh 3 V56V1PPT
+#sudo ./setPPT.sh 4 V56V3PPT
+#Hynix
+sudo ./amdmemtweak --cl 20 --ras 23 --rcdrd 15 --rcdwr 11 --rc 36 --rp 13 --rrds 3 --rrdl 5 --rtp 6 --faw 12 --cwl 7 --wtrs 4 --wtrl 9 --wr 13 --rfc 248 --REF 65535
+#Samsung
+#sudo ./amdmemtweak --i 2 --RAS 26 --RCDRD 12 --RCDWR 6 --RC 38 --RP 12 --REF 15600 --RRDL 4
+

+ 45 - 0
setPPT.sh

@@ -0,0 +1,45 @@
+#!/bin/bash
+
+#BSD 3-Clause License
+#
+#Copyright (c) 2018, xmrminer01102018
+#All rights reserved.
+#
+#Redistribution and use in source and binary forms, with or without
+#modification, are permitted provided that the following conditions are met:
+#
+#* Redistributions of source code must retain the above copyright notice, this
+#  list of conditions and the following disclaimer.
+#
+#* Redistributions in binary form must reproduce the above copyright notice,
+#  this list of conditions and the following disclaimer in the documentation
+#  and/or other materials provided with the distribution.
+#
+#* Neither the name of the copyright holder nor the names of its
+#  contributors may be used to endorse or promote products derived from
+#  this software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+#FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+#DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+#SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+#OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+
+if [ $# != 2 ];
+then
+  echo "$0 gpunumber PPTFile"
+  echo "Example: For 1 gpu at slot 0"
+  echo "$0 0 PPTFile1"
+  exit;
+fi
+
+MSG="cat $2 > /sys/class/drm/card$1/device/pp_table"
+echo $MSG
+cat $2 > /sys/class/drm/card$1/device/pp_table