Skip to content

Instantly share code, notes, and snippets.

@newperson1746
Forked from b00t0x/build_RyzenAdj_macos.md
Last active February 11, 2024 14:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newperson1746/00cccb51aa2fe5e31e8e2f577bec3a88 to your computer and use it in GitHub Desktop.
Save newperson1746/00cccb51aa2fe5e31e8e2f577bec3a88 to your computer and use it in GitHub Desktop.
RyzenAdj for macOS

Description

How to build RyzenAdj for macOS (UPDATED through Ventura?)

Limitations

  • Monitoring functions like ./ryzenadj --info not working
    • adjustment only

Prerequisites

Environment

  • macOS Monterey 12.4
  • Xcode 13.4.1 (to build DirectHW)

Build

DirectHW

https://github.com/newperson1746/directhw It is possible that DirectHW is not even needed, because this new pciutils includes several other access methods RyzenAdj works with darwin2 (AppleACPIPlatformExpert) method, doesnt require DIrectHW

Download Artifacts from actions to get binaries

# using prebuilt binaries
mkdir -p /tmp/include/DirectHW
cp Artifacts/usr/local/include/DirectHW.h /tmp/include/DirectHW
cp Artifacts/libDirectHW.a /tmp/include
cp -r Artifacts/DirectHW.kext /path/to/EFI/OC/Kexts/
Build your own (Xcode required)
git clone <path-to-directhw-repo>
sed -i -e 's/Apple Development/-/' DirectHW/DirectHW.xcodeproj/project.pbxproj
make build
cp build/Release/libDirectHW.a /tmp/include
cp -r build/Release/DirectHW.kext /path/to/EFI/OC/Kexts/

pciutils

https://github.com/joevt/pciutils pciutils/pciutils#111 (comment) (documentation on new pciutils for darwin)

git clone <repo>
cd pciutils

sed -i -e 's/Frameworks/Frameworks -I\/tmp\/include/' Makefile
sed -i -e 's/usr\/local\/lib/tmp\/include/' lib/configure
make

mkdir -p /tmp/include/pci
cp lib/*.h /tmp/include/pci
cp lib/libpci.a /tmp/include

RyzenAdj

https://github.com/FlyGoat/RyzenAdj

git clone https://github.com/FlyGoat/RyzenAdj.git
cd RyzenAdj

# anywhere in CMakeLists.txt, but at top best, add 
set(CMAKE_VERBOSE_MAKEFILE ON)

sed -i -e 's/${INC_DIR}/\/tmp\/include/' CMakeLists.txt
sed -i -e 's/${OS_LINK_DIR}/\/tmp\/include/' CMakeLists.txt
# modify set(OS_LINK_LIBRARY pci/) to
set (OS_LINK_LIBRARY pci ZLIB::ZLIB)
 
# above that line, insert line
find_package(ZLIB REQUIRED)

mkdir build && cd build
cmake ..
make
# build will fail, copy and paste the final link command (starts with /Library/Developer.../cc) and append to it:
-framework IOKit

# now it will build

Pardon the horrible IOKit linking hack, using frameworks in CMake is dog shit

How to use

Preparation

  • Add DirectHW.kext to config.plist
  • Add debug=0x144 (or 0x44) boot-args to config.plist

Run manually

sudo ./ryzenadj --tctl-temp=70

Run at startup

sudo mkdir -p /usr/local/bin
sudo cp ./ryzenadj /usr/local/bin

sudo cp org.b00t0x.ryzenadj.plist /Library/LaunchDaemons/
sudo chmod 644 /Library/LaunchDaemons/org.b00t0x.ryzenadj.plist
sudo chown 0:0 /Library/LaunchDaemons/org.b00t0x.ryzenadj.plist
sudo launchctl load /Library/LaunchDaemons/org.b00t0x.ryzenadj.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.b00t0x.ryzenadj</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ryzenadj</string>
<string>--tctl-temp</string>
<string>75</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/ryzenadj.txt</string>
<key>StandardErrorPath</key>
<string>/tmp/ryzenadj.err</string>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment