Skip to content

Instantly share code, notes, and snippets.

@Broceliande
Last active August 8, 2019 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Broceliande/cdcf4182afdfb81fd4ba943f1b7e009d to your computer and use it in GitHub Desktop.
Save Broceliande/cdcf4182afdfb81fd4ba943f1b7e009d to your computer and use it in GitHub Desktop.
hybrid-nvidia-patch.sh
#!/bin/bash
## implements poke-1,0 's patch for hybrid Intel/NVidia
## see poke topic about it @ https://batocera-linux.xorhub.com/forum/d/1851-batocera-linux-5-22-with-nvidia-legacy-drivers-390-xx/9
# tested on batocera 5.22 5.23 Acer Aspire vx15 with Nvidia GTX 1050TI gpu OPENGL String: 4.6.0 NVIDIA 418.74/4.6.0 NVIDIA 430.40
# tested on batocera 5.22 Acer NC-VN7-791G-70M4 (Acer V Nitro Series) OPENGL String: 4.6.0 NVIDIA 418.74
echo "Stopping ES..."
/etc/init.d/S31emulationstation stop
echo "Making boot writable."
mount -o remount,rw /boot
echo "Activating Nvidia driver"
sed -i -e "s/#nvidia-driver=true/nvidia-driver=true/g" /boot/batocera-boot.conf
echo "Writing NVidia Xconf..."
echo "Section \"Module\"
Load \"modesetting\"
EndSection
Section \"Device\"
Identifier \"nvidia\"
Driver \"nvidia\"
BusID \"1:0:0\"
Option \"AllowEmptyInitialConfiguration\"
EndSection" > /etc/X11/xorg.conf.d/99-nvidia.conf
echo "Configuring xinit overlay..."
cp /etc/X11/xinit/xinitrc /userdata/system/.xinitrc
sed -i -e "s/## CUSTOMISATIONS ###/## CUSTOMISATIONS ###\n## FORCE NVIDIA - HYBRID PATCH ###\nxrandr --setprovideroutputsource modesetting NVIDIA-0\nxrandr --auto/g" /userdata/system/.xinitrc
echo "Saving FS Overlay..."
/recalbox/scripts/recalbox-save-overlay.sh
echo "Reboot now"
reboot
@tcamargo
Copy link

tcamargo commented Jul 5, 2019

line 10: use batocera-settings
line 26: /userdata/system is the right home dir

@tcamargo
Copy link

tcamargo commented Jul 5, 2019

line 13: not necessary

@crcerror
Copy link

crcerror commented Jul 5, 2019

line 13 18
command would be:
batocera-settings /boot/batocera-boot.conf uncomment nvidia-driver

or in it's long form
batocera-settings /boot/batocera-boot.conf --command uncomment --key nvidia-driver

You can use return code
[[ $? -eq 0 ]] || { echo "error occoured!"; exit 1; }

@crcerror
Copy link

crcerror commented Jul 5, 2019

line 34
sh command is not needed - the files are already executable

Maybe some cosmetics and to make it more read and maintainable

cat > /etc/X11/xorg.conf.d/99-nvidia.conf <<_EOF_
Section "Module"
	Load "modesetting"
EndSection

Section "Device"
	Identifier "nvidia"
	Driver "nvidia"
	BusID "1:0:0"
	Option "AllowEmptyInitialConfiguration"
EndSection
_EOF_

@gameski
Copy link

gameski commented Aug 3, 2019

Hi Broceliande, poke from Batocera forum sad to inform you about my case of gpu-hybrid GT740m of Dell Vostro 5470:
I tried to use your script but not work for me.
But I had progress using instructions of poke and part of your procedure for Batocera 5.22.
This is the manualy steps that I used:

  1. mount -o remount,rw /boot
    nano /boot/batocera-boot.conf
    <remove the leading # from the nvidia-driver=true line>

  2. create 99-nvidia.conf in /etc/X11/xorg.conf.d/

Section "Module"
Load "modesetting"
EndSection

Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "9:0:0"
Option "AllowEmptyInitialConfiguration"
EndSection

  1. Edit xinitrc in /etc/X11/xinit/

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto

  1. Saving the changes

cd /recalbox/scripts/
./recalbox-save-overlay.sh

Reboot

@Broceliande
Copy link
Author

Hi gameski,
Thank you for your report.
Unfortunately this page was not up to date and stayed at a wip state...
I din't think the link would be published, my bad!
I just updated it.
The actual version works for both 5.22 / 5.23
That would be great if you can test it on your hw so that we can add your GT740m of Dell Vostro 5470 to the tested list
With enough feedback we may can add it in next batocera's version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment