mirror of https://github.com/sm64pc/sm64pc.git
Merge pull request #364 from jmcerrejon/feature/rpi4-support-and-refactor
Raspberry 4 support. Refactor code.
This commit is contained in:
commit
55a0426cdd
74
pisetup.sh
74
pisetup.sh
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Super Mario 64 PC on Raspberry Pi
|
# Super Mario 64 PC on Raspberry Pi
|
||||||
# Find latest updates and code on https://www.github.com/sm64pc/sm64pc
|
# Find latest updates and code on https://www.github.com/sm64pc/sm64ex
|
||||||
|
# NOTE: If you clone the repo, source must be copied in ~/src/sm64pc/sm64ex/
|
||||||
# ToDo: Test on more Pi models with fresh Raspbian and allow existing src folders to be updated.
|
# ToDo: Test on more Pi models with fresh Raspbian and allow existing src folders to be updated.
|
||||||
#
|
#
|
||||||
clear
|
clear
|
||||||
|
@ -11,11 +12,11 @@ lowmem=0
|
||||||
pi=0
|
pi=0
|
||||||
pimodel=$(uname -m 2>/dev/null || echo unknown)
|
pimodel=$(uname -m 2>/dev/null || echo unknown)
|
||||||
pitype=$(tr -d '\0' < /sys/firmware/devicetree/base/model)
|
pitype=$(tr -d '\0' < /sys/firmware/devicetree/base/model)
|
||||||
|
repo_url="https://github.com/sm64pc/sm64ex"
|
||||||
|
|
||||||
if [[ $pimodel =~ "armv6" ]]
|
if [[ $pimodel =~ "armv6" ]]
|
||||||
then
|
then
|
||||||
echo ""
|
echo -e "\nRaspberry Pi Model 1/0(W) detected (LOWMEM)"
|
||||||
echo "Raspberry Pi Model 1/0(W) detected (LOWMEM)"
|
|
||||||
echo "Warning: Additional steps may be required to safely compile and maximize performance"
|
echo "Warning: Additional steps may be required to safely compile and maximize performance"
|
||||||
pi=1;
|
pi=1;
|
||||||
lowmem=1;
|
lowmem=1;
|
||||||
|
@ -24,16 +25,14 @@ fi
|
||||||
|
|
||||||
if [[ $pimodel =~ "armv7" ]]
|
if [[ $pimodel =~ "armv7" ]]
|
||||||
then
|
then
|
||||||
echo
|
echo -e "\nRaspberry Pi Model 2/3/4 detected (32bit)"
|
||||||
echo "Raspberry Pi Model 2/3 detected (32bit)"
|
|
||||||
pi=2;
|
pi=2;
|
||||||
lowmem=0;
|
lowmem=0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $pimodel =~ "aarch64" && $pitype =~ "4" ]]
|
if [[ $pimodel =~ "aarch64" && $pitype =~ "4" ]]
|
||||||
then
|
then
|
||||||
echo
|
echo -e "\nRaspberry Pi Model 4 (64 bits) detected"
|
||||||
echo "Raspberry Pi Model 4 detected"
|
|
||||||
echo "Audio errors reported"
|
echo "Audio errors reported"
|
||||||
echo "Fixing audio config, reboot after compilation completes to activate"
|
echo "Fixing audio config, reboot after compilation completes to activate"
|
||||||
sudo sed -i 's/load-module module-udev-detect/load-module module-udev-detect tsched=0/' /etc/pulse/default.pa
|
sudo sed -i 's/load-module module-udev-detect/load-module module-udev-detect tsched=0/' /etc/pulse/default.pa
|
||||||
|
@ -51,14 +50,14 @@ then
|
||||||
echo "Further steps may be required and software / driver compatibility is not guaranteed."
|
echo "Further steps may be required and software / driver compatibility is not guaranteed."
|
||||||
read -p "Continue setup & compilation (Y/N): " exp
|
read -p "Continue setup & compilation (Y/N): " exp
|
||||||
|
|
||||||
if [[ $exp =~ "Y" ]]
|
if [[ $exp =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Please report any problems encountered to https://github.com/sm64pc/sm64pc issue tracker."
|
echo "Please report any problems encountered to ${repo_url} issue tracker."
|
||||||
echo ""
|
echo ""
|
||||||
sleep 7
|
sleep 7
|
||||||
fi
|
fi
|
||||||
|
@ -79,7 +78,7 @@ if [[ $inxinf =~ "not found" ]]
|
||||||
then
|
then
|
||||||
echo "Error: inxi not installed. Installing..."
|
echo "Error: inxi not installed. Installing..."
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install inxi
|
sudo apt-get install -y inxi
|
||||||
inxi=$(inxi -Gx)
|
inxi=$(inxi -Gx)
|
||||||
|
|
||||||
if [[ $inxinf =~ "not found" ]]
|
if [[ $inxinf =~ "not found" ]]
|
||||||
|
@ -130,7 +129,7 @@ fixmem=$(cat /boot/cmdline.txt | grep cma=128M)
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Fix mem? (Y/N): " fixmem
|
read -p "Fix mem? (Y/N): " fixmem
|
||||||
|
|
||||||
if [[ $fixmem =~ "Y" ]]
|
if [[ $fixmem =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
sudo sh -c "echo 'gpu_mem=48' >> /boot/config.txt"
|
sudo sh -c "echo 'gpu_mem=48' >> /boot/config.txt"
|
||||||
sudo sh -c "echo 'cma=128M' >> /boot/cmdline.txt"
|
sudo sh -c "echo 'cma=128M' >> /boot/cmdline.txt"
|
||||||
|
@ -146,12 +145,12 @@ fixmem=$(cat /boot/cmdline.txt | grep cma=128M)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $fixmem =~ "Y" || $vc4add =~ "vc4" ]]
|
if [[ $fixmem =~ [Yy] || $vc4add =~ "vc4" ]]
|
||||||
then
|
then
|
||||||
clear
|
clear
|
||||||
echo "System configuration has changed!"
|
echo "System configuration has changed!"
|
||||||
read -p "Reboot to enable changes? (Y/N): " fixstart
|
read -p "Reboot to enable changes? (Y/N): " fixstart
|
||||||
if [[ $fixstart =~ "Y" ]]
|
if [[ $fixstart =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Rebooting RasPi in 4 seconds! Press Control-C to cancel."
|
echo "Rebooting RasPi in 4 seconds! Press Control-C to cancel."
|
||||||
|
@ -170,11 +169,11 @@ echo "Step 1. Installing latest dependencies"
|
||||||
echo "Allow installation & checking of Super Mario 64 compile dependencies?"
|
echo "Allow installation & checking of Super Mario 64 compile dependencies?"
|
||||||
read -p "Install? (Y/N): " instdep
|
read -p "Install? (Y/N): " instdep
|
||||||
|
|
||||||
if [[ $instdep =~ "Y" ]]
|
if [[ $instdep =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt install build-essential git python3 libaudiofile-dev libglew-dev libsdl2-dev
|
sudo apt install -y build-essential git python3 libaudiofile-dev libglew-dev libsdl2-dev
|
||||||
sync
|
sync
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -193,14 +192,14 @@ echo ""
|
||||||
echo "Warning: Compile could take up to an hour on older Raspberry Pi models"
|
echo "Warning: Compile could take up to an hour on older Raspberry Pi models"
|
||||||
read -p "Proceed? (Y/N): " sdlcomp
|
read -p "Proceed? (Y/N): " sdlcomp
|
||||||
|
|
||||||
if [[ $sdlcomp =~ "Y" ]]
|
if [[ $sdlcomp =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Installing dependencies for SDL2 compilation"
|
echo "Installing dependencies for SDL2 compilation"
|
||||||
|
|
||||||
sudo sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
|
sudo sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
|
||||||
sudo apt build-dep libsdl2
|
sudo apt build-dep libsdl2
|
||||||
sudo apt install libdrm-dev libgbm-dev
|
sudo apt install -y libdrm-dev libgbm-dev
|
||||||
sync
|
sync
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -234,10 +233,10 @@ clear
|
||||||
echo "Super Mario 64 RPi preparation & downloader"
|
echo "Super Mario 64 RPi preparation & downloader"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Checking in current directory and"
|
echo "Checking in current directory and"
|
||||||
echo "checking in "$HOME"/src/sm64pi/sm64pc/ for existing Super Mario 64 PC files"
|
echo "checking in "$HOME"/src/sm64pc/sm64ex/ for existing Super Mario 64 PC files"
|
||||||
echo ""
|
echo ""
|
||||||
sm64dircur=$(ls ./Makefile)
|
sm64dircur=$(ls ./Makefile)
|
||||||
sm64dir=$(ls $HOME/src/sm64pi/sm64pc/Makefile)
|
sm64dir=$(ls $HOME/src/sm64pc/sm64ex/Makefile)
|
||||||
|
|
||||||
if [[ $sm64dircur =~ "Makefile" ]] #If current directory has a makefile
|
if [[ $sm64dircur =~ "Makefile" ]] #If current directory has a makefile
|
||||||
then
|
then
|
||||||
|
@ -257,7 +256,7 @@ then
|
||||||
curdir=1
|
curdir=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else #Do a fresh compile in HOME/src/sm64pi/sm64pc/
|
else #Do a fresh compile in HOME/src/sm64pc/sm64ex/
|
||||||
sm64dir=0;
|
sm64dir=0;
|
||||||
curdir=0;
|
curdir=0;
|
||||||
fi
|
fi
|
||||||
|
@ -265,25 +264,25 @@ fi
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ $sm64git =~ "Y" || $sm64dir == 0 || $curdir == 0 ]] #If user wants to redownload or NOT git-zip execution
|
if [[ $sm64git =~ [Yy] || $sm64dir == 0 || $curdir == 0 ]] #If user wants to redownload or NOT git-zip execution
|
||||||
then
|
then
|
||||||
echo "Step 2. Super Mario 64 PC-Port will now be downloaded from github"
|
echo "Step 2. Super Mario 64 PC-Port will now be downloaded from github"
|
||||||
echo "Current folder will NOT be compiled."
|
echo "Current folder will NOT be compiled."
|
||||||
read -p "Proceed? (Y/N): " gitins
|
read -p "Proceed? (Y/N): " gitins
|
||||||
|
|
||||||
if [[ $gitins =~ "Y" ]]
|
if [[ $gitins =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Creating directory "$HOME"/src/sm64pi"
|
echo "Creating directory "$HOME"/src/sm64pc"
|
||||||
mkdir $HOME/src/
|
mkdir $HOME/src/
|
||||||
cd $HOME/src/
|
cd $HOME/src/
|
||||||
mkdir $HOME/src/sm64pi
|
mkdir $HOME/src/sm64pc
|
||||||
cd $HOME/src/sm64pi
|
cd $HOME/src/sm64pc
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Downloading latest Super Mario 64 PC-port code"
|
echo "Downloading latest Super Mario 64 PC-port code"
|
||||||
git clone https://github.com/sm64pc/sm64pc
|
git clone ${repo_url}
|
||||||
cd $HOME/src/sm64pi/sm64pc/
|
cd $HOME/src/sm64pc/sm64ex/
|
||||||
echo "Download complete"
|
echo "Download complete"
|
||||||
echo ""
|
echo ""
|
||||||
sleep 2
|
sleep 2
|
||||||
|
@ -303,14 +302,14 @@ if [[ $curdir == 1 ]]
|
||||||
then
|
then
|
||||||
echo "Assets will be extracted from "$PWD" "
|
echo "Assets will be extracted from "$PWD" "
|
||||||
else
|
else
|
||||||
echo "Assets will be extracted from $HOME/src/sm64pi/sm64pc/baserom.(us/eu/jp).z64 "
|
echo "Assets will be extracted from $HOME/src/sm64pc/sm64ex/baserom.(us/eu/jp).z64 "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $curdir == 1 ]]
|
if [[ $curdir == 1 ]]
|
||||||
then
|
then
|
||||||
sm64z64=$(find ./* | grep baserom) #See if current directory is prepped
|
sm64z64=$(find ./* | grep baserom) #See if current directory is prepped
|
||||||
else
|
else
|
||||||
sm64z64=$(find $HOME/src/sm64pi/sm64pc/* | grep baserom) #see if fresh compile directory is prepped
|
sm64z64=$(find $HOME/src/sm64pc/sm64ex/* | grep baserom) #see if fresh compile directory is prepped
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $sm64z64 =~ "baserom" ]]
|
if [[ $sm64z64 =~ "baserom" ]]
|
||||||
|
@ -332,7 +331,7 @@ echo $PWD
|
||||||
echo ""
|
echo ""
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo $HOME/src/sm64pi/sm64pc/
|
echo $HOME/src/sm64pc/sm64ex/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
|
@ -348,7 +347,7 @@ echo ""
|
||||||
|
|
||||||
if [[ $curdir != 1 ]] # If we're not compiling from a git zip / random directory
|
if [[ $curdir != 1 ]] # If we're not compiling from a git zip / random directory
|
||||||
then
|
then
|
||||||
cd $HOME/src/sm64pi/sm64pc/
|
cd $HOME/src/sm64pc/sm64ex/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Beginning Super Mario 64 RasPi compilation!"
|
echo "Beginning Super Mario 64 RasPi compilation!"
|
||||||
|
@ -358,7 +357,12 @@ echo "At least 300MB of free storage AND RAM is recommended"
|
||||||
echo ""
|
echo ""
|
||||||
make clean
|
make clean
|
||||||
sync
|
sync
|
||||||
|
if [[ $pimodel =~ "armv6" ]]
|
||||||
|
then
|
||||||
make TARGET_RPI=1
|
make TARGET_RPI=1
|
||||||
|
else
|
||||||
|
make TARGET_RPI=1 -j4
|
||||||
|
fi
|
||||||
sync
|
sync
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,7 +373,7 @@ if [[ $curdir == 1 ]]
|
||||||
then
|
then
|
||||||
sm64done=$(find ./build/*/* | grep .arm)
|
sm64done=$(find ./build/*/* | grep .arm)
|
||||||
else
|
else
|
||||||
sm64done=$(find $HOME/src/sm64pi/sm64pc/build/*/* | grep .arm)
|
sm64done=$(find $HOME/src/sm64pc/sm64ex/build/*/* | grep .arm)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
@ -382,7 +386,7 @@ if [[ $curdir == 1 ]]
|
||||||
then
|
then
|
||||||
$sm64loc=$(ls ./build/*pc/*.arm)
|
$sm64loc=$(ls ./build/*pc/*.arm)
|
||||||
else
|
else
|
||||||
$sm64loc=$(ls $HOME/src/sm64pi/sm64pc/build/*pc/*.arm)
|
$sm64loc=$(ls $HOME/src/sm64pc/sm64ex/build/*pc/*.arm)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $sm64loc
|
echo $sm64loc
|
||||||
|
@ -391,7 +395,7 @@ echo ""
|
||||||
echo "Execute compiled Super Mario 64 RasPi?"
|
echo "Execute compiled Super Mario 64 RasPi?"
|
||||||
read -p "Run game (Y/N): " sm64run
|
read -p "Run game (Y/N): " sm64run
|
||||||
|
|
||||||
if [[ $sm64run =~ "Y" ]]
|
if [[ $sm64run =~ [Yy] ]]
|
||||||
then
|
then
|
||||||
cd
|
cd
|
||||||
chmod +x $sm64loc
|
chmod +x $sm64loc
|
||||||
|
@ -402,7 +406,7 @@ fi
|
||||||
else
|
else
|
||||||
echo "Cannot find compiled sm64*.arm binary..."
|
echo "Cannot find compiled sm64*.arm binary..."
|
||||||
echo "Please note of any errors during compilation process and report them to"
|
echo "Please note of any errors during compilation process and report them to"
|
||||||
echo "https://github.com/sm64pc/sm64pc"
|
echo "${repo_url}"
|
||||||
sleep 5
|
sleep 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue