[Solved] Xorg can't interact with Nvidia GPU on old gaming laptop

EDIT2: I managed to sneak some extra time to try the nvidia-modeset solution found in Thread 82201. It worked.

Still working on getting Firefox working in Kiosk mode but Xorg starts with a terminal window now. nvidia-modeset was the solution. Marking as solved.




Forgive me if this belongs under "system hardware," I wasn't sure which to put it under. I expect to do more tweaking with X than the Nvidia drivers so I went with "Display Servers."

I'm installing FreeBSD on an old Asus RoG gaming laptop. It has an Intel i7-4700HQ CPU and Nvidia GeForce GTX 765m GPU. I'm just trying to get a bare-minimum X/Firefox/Chromium kiosk setup going to keep configuration simple while I figure out FreeBSD.

I identified what I believe are the correct drivers for my card from the Nvidia website (package is nvidia-driver-390-390.144) and followed FreeBSD documentation to set up the driver and X, installing the correct drivers from pkg. I tried both Firefox and Chromium with and without -kiosk, --kiosk, and --kiosk-mode flags per various web tutorials.

When I run startx, xinit firefox or Xorg -configure, I get similar results where it seems like X can't "talk to" the Nvidia card. All commands are being run as root, though I've also started added a user account to the video group and intend to run X as that user after successful testing as root. I also used commands given in a tutorial using bash, but usually am using fish as my default shell.

Here are some examples where I've trimmed the output to what seems relevant:

IN:

$ Xorg -configure

OUT:

Code:
(==) Log file: "/var/log/Xorg.0.log"
List of video drivers:
            nvidia
           scfb
           modesetting
           vesa
scfb trace: probe start
(++) Using config file: "/root/xorg.conf.new"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
Number of created screens does not match number of detected devices.
  Configuration failed.
(EE) Server terminated with error (2).


xinit firefox AND xinit firefox $* -- :1

Code:
(==) Log file: "/var/log/Xorg.0.log"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
scfb trace: probe start
scfb trace: probe done
(EE)
Fatal server error:
(EE) Cannot run in framebuffer mode. Please specify busIDs for all framebuffer devices

I've run Xorg with just the defaults (twm, xterm) on other systems, so I tried startx with no .conf files in /etc/X11/ or /usr/local/etc/X11/xorg.conf per the instructions in 5.4.1 here.

startx

Code:
file /root/.serverauth.14244 does not exist
(stdin):1:  bad display name ":0" in "add" command/
file /root/.Xauthority does not exist
(argv):1:  bad display name ":0" in "list" command
(argv):1:  bad display name "/unix:0" in "add" command
...
xinit: giving up
xinit: unable to connect to X server. Connection refused.

So far, it seems like the defaults aren't going to work and I need to actually configure things. I took a look at the Xorg log to see what went wrong.

less /var/log/Xorg.0.log

Code:
(==) Using system config directory
(==) No Layout section. Using the first Screen section.
(==) No Screen section available. Using defaults.
...
(==) Not automatically adding GPU devices
(II) The server relies on udev to provide the list of input devices. If no devices become available, reconfigure udev or disable AutoAddDevices.
(--) PCI:*(1@0:0:0)
(II) LoadModule: "glx"
(II) LoadModule: "nv"

According to FreeBSD's Compiz Fusion documentation, I explicitly want X to use the "nvidia" driver and not the "nv" one. I'm not sure if that's just necessary for CF, but "X with full proprietary Nvidia bells and whistles" is my end goal here anyway. I also haven't looked into how udev and AutoAddDevices might be factoring into this but that's on my to-do list.

When I check the config file that Xorg -config generates at /root/xorg.conf.new (I renamed it to xorg.conf.auto for the last "defaults" test), I see in the last section:
Code:
Section "Device"
            Identifier    "Card0"
            Driver        "nvidia"
            BusID        "PCI:1:0:0"
Endsection

This appears to be the correct device based on /var/log/messages.

Finally, I checked up on the loaded modules and was surprised to not find a loaded Nvidia module. I have set
Code:
nvidia-load="YES"
in /boot/loader.conf per aforementioned instructions.

kldstat | grep nv
<no output>

When I checked with the verbose flag (side note, love the insight this gives):
kldstat -v | less
Code:
...         kernel (/boot/kernel/kernel)
Contains modules:
    ...
    82 pci/ata_nvidia
    359 g_raid_md_nvidia

In those instructions, it's mentioned that the Nvidia driver needs to be loaded at boot time. I checked pkg info -l nvidia-driver-390-390.144 | grep ko and found /boot/modules/nvidia.ko, which I'm guessing is what I need to load.

So knowing that I need to load it at boot, I tried loading it manually and running everything again anyway.
kldload nvidia
kldstat | grep nv
Code:
8 ...    nvidia.ko
startx and so on, with same results as before. So I know there's something wrong with this module at boot, but I might be making mistakes with X as well.

I also tried running xinit firefox after loading the module and got a different result; I got a black screen with white text cursor and mouse cursor, which is more-or-less what I was expecting in the first place. But it's weird that it isn't loading at boot.

Some relevant output from /var/log/messages:
Code:
kernel: vgapci0: <VGA-compatible display> ... at device 0.0 on pci1
kernel: vgapci0: Boot video device
...
pkg[3118]: xinit-1.4.1,1 installed
devd[42000]: check_clients:  dropping disconnected client.
kernel: interface ata_nvidia.1 already present in the KLD 'kernel'!
kernel: linker_load_file: /boot/kernel/atanvidia.ko - unsupported file type
kernel: nvidia0: <GeForce GTX 765M> on vgapci0
kernel: vgapci0: child nvidia0 requested pci_enable_io
syslogd: last message repeated 1 times
devd[13870]: check_clients:  dropping disconnected client
syslogd: last message repeated 1 times
syslogd: last message repeated 1 times
syslogd: last message repeated 1 times

When I actually try using the generated configuration file, I get the same results unless I manually load the nvidia driver first:
mv /root/xorg.conf.auto /etc/X11/xorg.conf
Xorg -config
startx
xinit firefox

With the driver loaded and (known faulty) configuration file in place, I get a black screen with a white text cursor and pointer cursor. It looks like I'm actually getting a graphical shell though, there's no more text output and I have to reboot to get back to the terminal (I should really just ssh into the machine from my other system and kill the process or something, I know, but I expected to fix this sooner).

My questions are:
- What can I do to get the Nvidia driver loading correctly? It keeps not loading at boot and seems like something's still wrong when I load it manually (devd & kernel keep repeating a "client dropped" message).
- do I have the right idea for getting a basic X system up on FreeBSD so far? If not, what other configuration might I need to do?

Any advice on the "FreeBSD web kiosk" idea in general that people happen to have would be appreciated, too.

I'm noticing that Xorg seems to be expecting udev stuff and that kldload nvidia loads Linux compatibility modules as dependencies. I think the X package is configured for Linux compatibility and I'm going to either have to configure it for classic FreeBSD features from Ports or configure my system for Linux compatibility. Going "Linux mode" might be necessary for my workstation in the end but I want to see how far I can get with a "classic" FreeBSD desktop stack (OSS and devd instead of PA and udev, that kind of thing).

In that case, advice or pointers to advice on how to compile Xorg/Firefox/Chromium and configure FreeBSD for both/either Unix and/or Linux-y would be awesome. But I'm not even 100% sure if that's what's wrong, nor am I sure what settings I'd need to worry about it if is. The Xorg log seemed to suggest that it was having no trouble finding all my input devices despite constantly mentioning udev. It also mentioned the nvidia PCI device and /usr/local/lib/xorg/modules/drivers/nvidia_drv.so and I didn't see any errors about that.

EDIT: editing this before it's even been approved, I found this Thread 82201 and it seems like nvidia-modeset might be what I need. I'll need to come back to this and test more later, but I'll post again if I get things working with that information.
 
Thanks, and in the meantime:
I've done a little more testing. While I've marked this as "solved" because my original problem is indeed solved, it seems like it might be helpful for fellow BSD n00bs if I write out what I've learned a bit more. Good to know the documentation issue is known and being worked on though, please let me know if I can make myself useful with that.

"Kiosk mode" as a specific feature of FF and Chrome continues to elude me, but I'm starting to think that might be because I'm running as root. I'll try that again with the user account and come back.

For right now, I wanted to update that the module loads at boot. kldstat gives the Linux modules and both Nvidia modules when I add nvidia-modeset_load="YES" to /boot/loader.conf. No other boot options seem necessary, though I am now also using configs generated with Xorg -configure.

Further, the -geometry flags that I've seen in several tutorials weren't doing anything for the browsers, I'm thinking maybe that was for openbox or twm specifically and I misunderstood. In any case, they both have their own window sizing options and they both work when added to /root/.xinitrc. I've started a separate "kiosk init" file for each.

tail -n 3 .xinitfirefox
Code:
exec firefox -width 800 -height 800 -name login
tail -n 3 .xinitchrome
Code:
exec chrome --no-sandbox --window-size=800,800 -name login

Chromium/Chrome needs the --no-sandbox flag to run as root. Might try installing a WebKit browser and seeing if there's any quirks to those, too, I think I've read that Ubuntu has to run them with different Snap sandbox rules that FF or Chrome for some reason.
 
"Kiosk mode" as a specific feature of FF

<https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options> has disappeared. There's a capture <https://web.archive.org/web/2021053...a.org/en-US/docs/Mozilla/Command_Line_Options>, however I have not yet discovered the new home for the definitive Mozilla document

Firefox/CommandLineOptions - MozillaWiki might be definitive.

That, plus (or bettered by) what's below?

 
Firefox/CommandLineOptions - MozillaWiki might be definitive.

That, plus (or bettered by) what's below?

That Mozilla page does seem to be definitive.

Kiosk mode works, I just need to actually give it a URL and not be root.

The info in that forum link has actually already been helpful, but I think there's still more for me to use. I still want to get a "pure BSD" kiosk that isn't using Linux compatibility stuff and the tip about disabling dbus has given me an idea of what I need to do.

I'll be coming back to this in a few days, but I might make it a different post. Thanks again for the help, grahamperrin
 
Back
Top