Skip to content

Commit

Permalink
Merge pull request #13 from korewaChino/amd-gpu
Browse files Browse the repository at this point in the history
Ubuntu 21.04 Support
  • Loading branch information
T-vK authored Jul 19, 2021
2 parents b679f19 + 207c93b commit 89efff2
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ thirdparty
/LookingGlass
/utils/nvflash_linux
/VBiosFinder
*.asc
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fi
if [ $HAS_AMD_GPU = true ]; then
sudo $DISTRO_UTILS_DIR/amd-setup
fi
if [ $HAS_NVIDEA_GPU = true ]; then
if [ $HAS_NVIDIA_GPU = true ]; then
sudo $DISTRO_UTILS_DIR/nvidia-setup
fi
if [ $SUPPORTS_OPTIMUS = true ]; then
Expand Down
12 changes: 12 additions & 0 deletions utils/Ubuntu/21.04/amd-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}/../../.."
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
VM_FILES_DIR="${PROJECT_DIR}/vm-files"

source "$DISTRO_UTILS_DIR/kernel-param-utils"

# This script doesn't do anything yet.
35 changes: 35 additions & 0 deletions utils/Ubuntu/21.04/bumblebee-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}/../../.."
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
VM_FILES_DIR="${PROJECT_DIR}/vm-files"

source "$DISTRO_UTILS_DIR/kernel-param-utils"

echo "Disable Nouveau drivers"
addKernelParam "nouveau.modeset=0"
#sudo grep -qxsF 'blacklist nouveau' "/etc/modprobe.d/blacklist.conf" || echo "blacklist nouveau" | sudo tee -a "/etc/modprobe.d/blacklist.conf" > /dev/null
#sudo grep -qxsF 'exclude=xorg-x11*' "/etc/dnf/dnf.conf" || echo "exclude=xorg-x11*" | sudo tee -a "/etc/dnf/dnf.conf" > /dev/null
#sudo dnf remove xorg-x11-drv-nouveau -y

echo "Install third party repositories"
sudo add-apt-repository ppa:bumblebee/testing -y


echo "Install Bumblebee"
sudo apt install bumblebee bumblebee-nvidia -y

echo "Make Bumblebee available to the current user"
sudo gpasswd -a $(whoami) bumblebee

echo "Enable Bumblebee autostart"
sudo systemctl enable bumblebeed

echo "Block nvidia-fallback service"
sudo systemctl mask nvidia-fallback

echo "Start Bumblebee"
sudo systemctl start bumblebeed
18 changes: 18 additions & 0 deletions utils/Ubuntu/21.04/install-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

echo "Updating software..."
sudo apt upgrade -y
echo "Installing some useful tools..."
sudo apt install -y wget curl vim screen git crudini lshw msr-tools sysfsutils uml-utilities remmina samba spice-client-gtk genisoimage uuid
echo "Installing virtualization software..."
sudo apt install qemu-kvm qemu-utils qemu-efi ovmf qemu -y #@virtualization

#echo "Installing the Windows VirtIO Repository..."
#sudo wget https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo -O /etc/yum.repos.d/virtio-win.repo
echo "Installing virtio-modules"
sudo apt install virtio-modules -y
#echo "Upgrading to latest virtio-win..."
#sudo dnf --enablerepo=virtio-win-latest upgrade virtio-win -y
echo "Installing virt-viewer so you can connect to the VM for the windows installation"
sudo apt install -y virt-viewer
# /usr/share/virtio-win/virtio-win.iso
16 changes: 16 additions & 0 deletions utils/Ubuntu/21.04/intel-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}/../../.."
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
VM_FILES_DIR="${PROJECT_DIR}/vm-files"

source "$DISTRO_UTILS_DIR/kernel-param-utils"

#TODO: verify if that actually works:
echo "Allow using external monitor for notebooks that have the port wired to the dGPU directly"
sudo apt install -y intel-gpu-tools
sudo intel-virtual-output
#example usage: xrandr –output eDP1 –mode 1920×1080 –output HDMI1 –mode 1920×1080 –right-of eDP1
47 changes: 47 additions & 0 deletions utils/Ubuntu/21.04/kernel-param-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

GRUB_CFG_PATH=/etc/default/grub
VFIO_CFG_PATH=/etc/dracut.conf.d/vfio.conf

function addKernelParam() {
if ! sudo cat "$GRUB_CFG_PATH" | grep "GRUB_CMDLINE_LINUX=" | grep --quiet "$1"; then
sudo sed -i "s/^GRUB_CMDLINE_LINUX=\"/&$1 /" "$GRUB_CFG_PATH"
echo "addKernelParam: Added \"$1\" to GRUB_CMDLINE_LINUX in $GRUB_CFG_PATH"
else
echo "addKernelParam: No action required. \"$1\" already exists in GRUB_CMDLINE_LINUX of $GRUB_CFG_PATH"
fi
}
function removeKernelParam() {
if sudo cat "$GRUB_CFG_PATH" | grep "GRUB_CMDLINE_LINUX=" | grep --quiet "$1"; then
sudo sed -i "s/$1 //" "$GRUB_CFG_PATH"
echo "removeKernelParam: Removed \"$1\" from GRUB_CMDLINE_LINUX in $GRUB_CFG_PATH"
else
echo "removeKernelParam: No action required. \"$1\" is not set in GRUB_CMDLINE_LINUX of $GRUB_CFG_PATH"
fi
}
function applyKernelParamChanges() {
sudo sh -c 'grub2-mkconfig > /etc/grub2-efi.cfg'
}

function setGrubTimeout() {
sudo sed -i -r "s/^GRUB_TIMEOUT=[0-9]+/GRUB_TIMEOUT=$1 /" "$GRUB_CFG_PATH"
}

function addInitramfsDriver() {
driver="$1"
sudo touch "$VFIO_CFG_PATH"
if ! sudo cat "$VFIO_CFG_PATH" | grep --quiet "add_driver+="; then
echo 'add_driver+=" "' >> "$VFIO_CFG_PATH"
fi
if ! sudo cat "$VFIO_CFG_PATH" | grep "add_driver+=" | grep --quiet -P "( |\")$driver( |\")"; then
sudo sed -i "s/^add_driver+=\" \{0,1\}/&$driver /" "$VFIO_CFG_PATH"
echo "addDriverToInitramfs: Added \"$driver\" to add_driver in $VFIO_CFG_PATH"
else
echo "addDriverToInitramfs: No action required. \"$driver\" already exists in add_driver in $VFIO_CFG_PATH"
fi
}

function applyInitramfsChanges() {
sudo dracut -f --kver `uname -r`
#TODO: Find out if this needs to be executed again after every kernel update.
}
40 changes: 40 additions & 0 deletions utils/Ubuntu/21.04/looking-glass-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}/../../.."
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
VM_FILES_DIR="${PROJECT_DIR}/vm-files"

sudo apt install binutils binutils-multiarch-dev cmake texlive-fonts-recommended fonts-freefont-ttf libfontconfig-dev libegl-dev libspice-protocol-dev libsdl2-dev nettle-dev libx11-dev libxi-dev libxinerama-dev libxss-dev libwayland-dev wayland-protocols

LOOKING_GLASS_VERSION="B3"

# Build the (Linux) client application
git clone --single-branch --branch "${LOOKING_GLASS_VERSION}" --depth 1 --recursive https://github.com/gnif/LookingGlass.git
mkdir LookingGlass/client/build
cd LookingGlass/client/build
cmake ../
make

TMP_USER_NAME="$(logname)"
TMP_USER_ID="$(id -u "$TMP_USER_NAME")"
sudo bash -c "echo '#Type Path Mode UID GID Age Argument' > /etc/tmpfiles.d/10-looking-glass.conf"
sudo bash -c "echo 'f /dev/shm/looking-glass ${TMP_USER_ID} ${TMP_USER_NAME} kvm - ' >> /etc/tmpfiles.d/10-looking-glass.conf"

# Build the (Windows) host application
cd "${PROJECT_DIR}"
wget https://developer.nvidia.com/capture_sdk/downloads/v8.0.4/linux -O ./nvidea_capture_api.tgz
rm -rf ./Capture_Linux_v8.0.4
tar -xvzf ./nvidea_capture_api.tgz
rm ./nvidea_capture_api.tgz
rm -rf ./LookingGlass/Capture_Linux_v8.0.4
mv ./Capture_Linux_v8.0.4 ./LookingGlass/
cd LookingGlass
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=./host/toolchain-mingw64.cmake -DNVFBC_SDK='./Capture_Linux_v8.0.4' -DUSE_NVFBC=1 ./host
make

#wget "https://ci.appveyor.com/api/projects/rainers/visuald/artifacts/cv2pdb.exe?job=Environment%3A%20os%3DVisual%20Studio%202015%2C%20VS%3D14%2C%20APPVEYOR_BUILD_WORKER_IMAGE%3DVisual%20Studio%202015" -O "cv2pdb.exe"
#wine './cv2pdb.exe' './looking-glass-host.exe'
makensis './platform/Windows/installer.nsi'
41 changes: 41 additions & 0 deletions utils/Ubuntu/21.04/nvidia-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}/../../.."
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"
VM_FILES_DIR="${PROJECT_DIR}/vm-files"

source "$DISTRO_UTILS_DIR/kernel-param-utils"

echo "Disable Nouveau drivers"
addKernelParam "nouveau.modeset=0"
#sudo grep -qxsF 'blacklist nouveau' "/etc/modprobe.d/blacklist.conf" || echo "blacklist nouveau" | sudo tee -a "/etc/modprobe.d/blacklist.conf" > /dev/null
#sudo grep -qxsF 'exclude=xorg-x11*' "/etc/dnf/dnf.conf" || echo "exclude=xorg-x11*" | sudo tee -a "/etc/dnf/dnf.conf" > /dev/null
#sudo dnf remove xorg-x11-drv-nouveau -y

echo "Install third party repositories"
sudo add-apt-repository ppa:graphics-drivers/ppa -y

echo "Auto-install NVIDIA Drivers with ubuntu-drivers"
sudo ubuntu-drivers install -y

echo "Add Bumblebee repository"
sudo add-apt-repository ppa:bumblebee/testing -y


echo "Install Bumblebee"
sudo apt install bumblebee bumblebee-nvidia primus -y

echo "Make Bumblebee available to the current user"
sudo usermod -aG bumblebee $(whoami)

echo "Enable Bumblebee autostart"
sudo systemctl enable bumblebeed

echo "Block nvidia-fallback service"
sudo systemctl mask nvidia-fallback

echo "Start Bumblebee"
sudo systemctl start bumblebeed
22 changes: 22 additions & 0 deletions utils/Ubuntu/21.04/vbios-finder-installer
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

git clone https://github.com/coderobe/VBiosFinder.git
cd VBiosFinder

sudo apt install ruby ruby-rubygems ruby-bundler ruby-dev p7zip innoextract upx -y

wget https://github.com/LongSoft/UEFITool/releases/download/A58/UEFIExtract_NE_A58_linux_x86_64.zip -O ./UEFIExtract.zip
unzip ./UEFIExtract.zip -d ./3rdparty/

git clone https://github.com/awilliam/rom-parser.git
cd rom-parser

bundle install --path=vendor/bundle
gem install bundler:1.17.3

make
cp ./rom-fixer ../3rdparty/
cp ./rom-parser ../3rdparty/
cd ..

bundle install --path=vendor/bundle

0 comments on commit 89efff2

Please sign in to comment.