Solved Xorg blackscreen with nVidia-driver

Hello Community,

I am new to FreeBSD and have a problem with the nVidia-driver for Xorg. Yesterday I installed FreeBSD-10.3-RELEASE on my laptop (MSI CX61 with NVIDIA GeForce 820M) and build Xorg form the Ports Collection. Then I created the configuration files for the keyboard and for the screen resolution in
/usr/local/etc/X11/xorg.conf.d/
as described in section 5.4 of the handbook. The command startx starts Xorg and its default window manager TWM, so everything worked fine. Even the nvidia-driver installation from
/usr/local/ports/x11/nvidia-driver
didn't cause any problems (to setup the nvidia-driver, I read this tutorial: Thread HOWTO: Setup Xorg with NVIDIA's driver.52311 ).

However, after I created /usr/local/etc/X11/xorg.conf.d/nvidia-driver.conf with the content
Code:
Section "Device"
    Identifier "NVIDIA Card"
    VendorName "NVIDIA Corporation"
    BusID "PCI:1:0:0"
    Driver "nvidia"
    Option "NvAGP" "1"
#    Option "AccelMethod" "none"
#    Option "TripleBuffer" "True"
#    Option "MetaModes" "nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"
EndSection
I get a black screen after starting Xorg with startx. So I looked for a solution in this thread Thread nvidia-driver crashes computer on X start.3065/, but adding
Code:
machdep.disable_mtrrs="1"
to my /boot/loader.conf didn't help. Here is my loader.conf:
Code:
kern.vty="vt"                 # german charset (umlaute)
if_urtwn_load="YES"           # WLAN-driver
legal.realtek.license_ack="1"
nvidia_load="YES"             # nvidia-driver
machdep.disable_mtrrs="1"     # to prevent blackscreens in Xorg
and the /etc/rc.conf:
Code:
hostname="laptop.c0gito.de"
ifconfig_alc0="DHCP"
sshd_enable="YES"
powerd_enable="YES"
# The console-font (iso8859-15)
font8x16="iso15-8x16"
font8x14="iso15-8x14"
font8x8="iso15-8x8"
keymap="german.iso"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
# Linux-Emulator for the nVidia-driver
linux_enable="YES"
# WLAN-Configuration
wlans_urtwn0="wlan0"
ifconfig_wlan0="WPA DHCP"
# for Mate-desktop
moused_enable="YES"
dbus_enable="YES"
hald_enable="YES"
# slim_enable="YES"
This problem doesn't occur when I delete /usr/local/etc/X11/xorg.conf.d/nvidia-driver.conf, so maybe I don't need the file to use the graphic card? Otherwise I have no idea how to solve this problem. This is the output of Xorg -configure in /root/xorg.conf:
Code:
Section "ServerLayout"
    Identifier     "X.org Configured"
    Screen      0  "Screen0" 0 0
    Screen      1  "Screen1" RightOf "Screen0"
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
    ModulePath   "/usr/local/lib/xorg/modules"
    FontPath     "/usr/local/share/fonts/misc/"
    FontPath     "/usr/local/share/fonts/TTF/"
    FontPath     "/usr/local/share/fonts/OTF/"
    FontPath     "/usr/local/share/fonts/Type1/"
    FontPath     "/usr/local/share/fonts/100dpi/"
    FontPath     "/usr/local/share/fonts/75dpi/"
EndSection

Section "Module"
    Load  "glx"
EndSection

Section "InputDevice"
    Identifier  "Keyboard0"
    Driver      "kbd"
EndSection

Section "InputDevice"
    Identifier  "Mouse0"
    Driver      "mouse"
    Option        "Protocol" "auto"
    Option        "Device" "/dev/sysmouse"
    Option        "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
    Identifier   "Monitor0"
    VendorName   "Monitor Vendor"
    ModelName    "Monitor Model"
EndSection

Section "Monitor"
    Identifier   "Monitor1"
    VendorName   "Monitor Vendor"
    ModelName    "Monitor Model"
EndSection

Section "Device"
    Identifier  "Card0"
    Driver      "nvidia"
    BusID       "PCI:1:0:0"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "NoAccel"                # [<bool>]
        #Option     "AccelMethod"            # <str>
        #Option     "Backlight"              # <str>
        #Option     "DRI"                    # <str>
        #Option     "ColorKey"               # <i>
        #Option     "VideoKey"               # <i>
        #Option     "Tiling"                 # [<bool>]
        #Option     "LinearFramebuffer"      # [<bool>]
        #Option     "SwapbuffersWait"        # [<bool>]
        #Option     "TripleBuffer"           # [<bool>]
        #Option     "XvPreferOverlay"        # [<bool>]
        #Option     "HotPlug"                # [<bool>]
        #Option     "ReprobeOutputs"         # [<bool>]
        #Option     "XvMC"                   # [<bool>]
        #Option     "ZaphodHeads"            # <str>
        #Option     "TearFree"               # [<bool>]
        #Option     "PerCrtcPixmaps"         # [<bool>]
        #Option     "FallbackDebug"          # [<bool>]
        #Option     "DebugFlushBatches"      # [<bool>]
        #Option     "DebugFlushCaches"       # [<bool>]
        #Option     "DebugWait"              # [<bool>]
        #Option     "BufferCache"            # [<bool>]
    Identifier  "Card1"
    Driver      "intel"
    BusID       "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device     "Card0"
    Monitor    "Monitor0"
    SubSection "Display"
        Viewport   0 0
        Depth     1
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     4
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     8
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     15
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     16
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     24
    EndSubSection
EndSection

Section "Screen"
    Identifier "Screen1"
    Device     "Card1"
    Monitor    "Monitor1"
    SubSection "Display"
        Viewport   0 0
        Depth     1
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     4
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     8
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     15
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     16
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     24
    EndSubSection
EndSection
and the directory /etc/X11/ ist empty. If I failed to include important information, please let me know.

Thanks for reading and for you help.
 
Make sure there's not a /usr/local/etc/X11/xorg.conf too. It might prevent loading the conf.d/ files.
 
Thanks for your help. This is the output of /var/log/Xorg.0.log
Code:
[    25.233] 
X.Org X Server 1.17.4
Release Date: 2015-10-28
[    25.233] X Protocol Version 11, Revision 0
[    25.233] Build Operating System: FreeBSD 10.3-RELEASE amd64 
[    25.233] Current Operating System: FreeBSD laptop.c0gito.de 10.3-RELEASE FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
[    25.233] Build Date: 13 April 2016  07:55:04PM
[    25.233]  
[    25.233] Current version of pixman: 0.34.0
[    25.233] 	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
[    25.233] Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[    25.233] (==) Log file: "/var/log/Xorg.0.log", Time: Sat Apr 16 11:25:04 2016
[    25.235] (==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
[    25.236] (==) No Layout section.  Using the first Screen section.
[    25.236] (**) |-->Screen "Screen0" (0)
[    25.236] (**) |   |-->Monitor "<default monitor>"
[    25.236] (==) No device specified for screen "Screen0".
	Using the first device section listed.
[    25.236] (**) |   |-->Device "NVIDIA Card"
[    25.236] (==) No monitor specified for screen "Screen0".
	Using a default monitor configuration.
[    25.236] (==) Automatically adding devices
[    25.236] (==) Automatically enabling devices
[    25.236] (==) Not automatically adding GPU devices
[    25.241] (==) FontPath set to:
	/usr/local/share/fonts/misc/,
	/usr/local/share/fonts/TTF/,
	/usr/local/share/fonts/OTF/,
	/usr/local/share/fonts/Type1/,
	/usr/local/share/fonts/100dpi/,
	/usr/local/share/fonts/75dpi/
[    25.241] (==) ModulePath set to "/usr/local/lib/xorg/modules"
[    25.241] (II) The server relies on devd to provide the list of input devices.
	If no devices become available, reconfigure devd or disable AutoAddDevices.
[    25.241] (II) Loader magic: 0x801500
[    25.241] (II) Module ABI versions:
[    25.241] 	X.Org ANSI C Emulation: 0.4
[    25.241] 	X.Org Video Driver: 19.0
[    25.241] 	X.Org XInput driver : 21.0
[    25.241] 	X.Org Server Extension : 9.0
[    25.242] (--) PCI:*(0:0:2:0) 8086:0416:1462:10e9 rev 6, Mem @ 0xf7400000/4194304, 0xd0000000/268435456, I/O @ 0x0000f000/64, BIOS @ 0x????????/65536
[    25.242] (--) PCI: (0:1:0:0) 10de:1140:1462:1116 rev 161, Mem @ 0xf6000000/16777216, 0xe0000000/268435456, 0xf0000000/33554432, I/O @ 0x0000e000/128
[    25.242] (II) LoadModule: "glx"
[    25.244] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so
[    25.371] (II) Module glx: vendor="NVIDIA Corporation"
[    25.371] 	compiled for 4.0.2, module version = 1.0.0
[    25.371] 	Module class: X.Org Server Extension
[    25.371] (II) NVIDIA GLX Module  346.96  Sun Aug 23 21:29:48 PDT 2015
[    25.372] (II) LoadModule: "nvidia"
[    25.372] (II) Loading /usr/local/lib/xorg/modules/drivers/nvidia_drv.so
[    25.379] (II) Module nvidia: vendor="NVIDIA Corporation"
[    25.379] 	compiled for 4.0.2, module version = 1.0.0
[    25.379] 	Module class: X.Org Video Driver
[    25.380] (II) NVIDIA dlloader X Driver  346.96  Sun Aug 23 21:08:26 PDT 2015
[    25.380] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[    25.380] (--) Using syscons driver with X support (version 0.x)
[    25.380] (--) using VT number 9

[    25.404] (II) Loading sub module "fb"
[    25.404] (II) LoadModule: "fb"
[    25.405] (II) Loading /usr/local/lib/xorg/modules/libfb.so
[    25.406] (II) Module fb: vendor="X.Org Foundation"
[    25.406] 	compiled for 1.17.4, module version = 1.0.0
[    25.406] 	ABI class: X.Org ANSI C Emulation, version 0.4
[    25.406] (II) Loading sub module "wfb"
[    25.406] (II) LoadModule: "wfb"
[    25.406] (II) Loading /usr/local/lib/xorg/modules/libwfb.so
[    25.408] (II) Module wfb: vendor="X.Org Foundation"
[    25.408] 	compiled for 1.17.4, module version = 1.0.0
[    25.408] 	ABI class: X.Org ANSI C Emulation, version 0.4
[    25.408] (II) Loading sub module "ramdac"
[    25.408] (II) LoadModule: "ramdac"
[    25.408] (II) Module "ramdac" already built-in
[    25.410] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
[    25.410] (==) NVIDIA(0): Depth 24, (==) framebuffer bpp 32
[    25.410] (==) NVIDIA(0): RGB weight 888
[    25.410] (==) NVIDIA(0): Default visual is TrueColor
[    25.410] (==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
[    25.411] (**) NVIDIA(0): Enabling 2D acceleration
[    25.597] (II) NVIDIA(0): NVIDIA GPU GeForce 820M (GF117) at PCI:1:0:0 (GPU-0)
[    25.597] (--) NVIDIA(0): Memory: 2097152 kBytes
[    25.597] (--) NVIDIA(0): VideoBIOS: 75.17.82.00.08
[    25.597] (II) NVIDIA(0): Detected PCI Express Link width: 8X
[    25.597] (--) NVIDIA(0): Valid display device(s) on GeForce 820M at PCI:1:0:0
[    25.597] (--) NVIDIA(0):     none
[    25.597] (II) NVIDIA(0): Validated MetaModes:
[    25.597] (II) NVIDIA(0):     "NULL"
[    25.597] (II) NVIDIA(0): Virtual screen size determined to be 640 x 480
[    25.597] (WW) NVIDIA(0): Unable to get display device for DPI computation.
[    25.597] (==) NVIDIA(0): DPI set to (75, 75); computed from built-in default
[    25.597] (--) Depth 24 pixmap format is 32 bpp
[    25.597] (II) NVIDIA: Reserving 3072.00 MB of virtual memory for indirect memory
[    25.597] (II) NVIDIA:     access.
[    25.600] (II) NVIDIA(0): Setting mode "NULL"
[    25.613] (II) NVIDIA(0): Built-in logo is bigger than the screen.
[    25.619] (==) NVIDIA(0): Disabling shared memory pixmaps
[    25.619] (==) NVIDIA(0): Backing store enabled
[    25.619] (==) NVIDIA(0): Silken mouse enabled
[    25.620] (==) NVIDIA(0): DPMS enabled
[    25.621] (WW) NVIDIA(0): Option "NvAGP" is not used
[    25.621] (II) Loading sub module "dri2"
[    25.621] (II) LoadModule: "dri2"
[    25.621] (II) Module "dri2" already built-in
[    25.621] (II) NVIDIA(0): [DRI2] Setup complete
[    25.621] (II) NVIDIA(0): [DRI2]   VDPAU driver: nvidia
[    25.621] (--) RandR disabled
[    25.622] (II) Initializing extension GLX
[    25.622] (II) Indirect GLX disabled.(II) config/devd: probing input devices...
[    25.708] (II) config/devd: adding input device (null) (/dev/kbdmux)
[    25.708] (**) kbdmux: Applying InputClass "KeyboardDefaults"
[    25.708] (**) kbdmux: Applying InputClass "KeyboardDefaults"
[    25.708] (II) LoadModule: "kbd"
[    25.709] (II) Loading /usr/local/lib/xorg/modules/input/kbd_drv.so
[    25.709] (II) Module kbd: vendor="X.Org Foundation"
[    25.709] 	compiled for 1.17.4, module version = 1.8.1
[    25.709] 	Module class: X.Org XInput Driver
[    25.709] 	ABI class: X.Org XInput driver, version 21.0
[    25.709] (II) Using input driver 'kbd' for 'kbdmux'
[    25.709] (**) kbdmux: always reports core events
[    25.709] (**) kbdmux: always reports core events
[    25.709] (**) Option "Protocol" "standard"
[    25.709] (**) Option "XkbRules" "base"
[    25.709] (**) Option "XkbModel" "pc105"
[    25.709] (**) Option "XkbLayout" "de"
[    25.709] (**) Option "XkbOptions" "terminate:ctrl_alt_bksp"
[    25.709] (**) Option "config_info" "devd:kbdmux"
[    25.709] (II) XINPUT: Adding extended input device "kbdmux" (type: KEYBOARD, id 6)
[    25.744] (II) config/devd: kbdmux is enabled, ignoring device atkbd0
[    25.744] (II) config/devd: adding input device (null) (/dev/sysmouse)
[    25.744] (II) LoadModule: "mouse"
[    25.744] (II) Loading /usr/local/lib/xorg/modules/input/mouse_drv.so
[    25.745] (II) Module mouse: vendor="X.Org Foundation"
[    25.745] 	compiled for 1.17.4, module version = 1.9.1
[    25.745] 	Module class: X.Org XInput Driver
[    25.745] 	ABI class: X.Org XInput driver, version 21.0
[    25.745] (II) Using input driver 'mouse' for 'sysmouse'
[    25.745] (**) sysmouse: always reports core events
[    25.745] (**) Option "Device" "/dev/sysmouse"
[    25.745] (==) sysmouse: Protocol: "Auto"
[    25.745] (**) sysmouse: always reports core events
[    25.745] (==) sysmouse: Emulate3Buttons, Emulate3Timeout: 50
[    25.745] (**) sysmouse: ZAxisMapping: buttons 4 and 5
[    25.745] (**) sysmouse: Buttons: 5
[    25.745] (**) Option "config_info" "devd:sysmouse"
[    25.745] (II) XINPUT: Adding extended input device "sysmouse" (type: MOUSE, id 7)
[    25.746] (**) sysmouse: (accel) keeping acceleration scheme 1
[    25.746] (**) sysmouse: (accel) acceleration profile 0
[    25.746] (**) sysmouse: (accel) acceleration factor: 2.000
[    25.746] (**) sysmouse: (accel) acceleration threshold: 4
[    25.746] (II) sysmouse: SetupAuto: hw.iftype is 4, hw.model is 0
[    25.746] (II) sysmouse: SetupAuto: protocol is SysMouse
[    25.746] (II) config/devd: device /dev/psm0 already opened
[    30.628] (II) Server zapped. Shutting down.
[    30.637] (II) config/devd: terminating backend...
[    30.637] (II) UnloadModule: "mouse"
[    30.637] (II) UnloadModule: "kbd"
[    30.655] (II) NVIDIA(GPU-0): Deleting GPU-0
[    30.686] (II) Server terminated successfully (0). Closing log file.
The directory /usr/local/etc/X11/ contains a xinit and the xorg.conf.d folder, but no xorg.conf.
 
Code:
[    25.597] (--) NVIDIA(0): Valid display device(s) on GeForce 820M at PCI:1:0:0
[    25.597] (--) NVIDIA(0):     none

This would explain your black screen. Your monitor is not being detected! It should be something like this:

Code:
[1061965.462] (--) NVIDIA(0): VideoBIOS: 62.79.4e.00.01
[1061965.532] (--) NVIDIA(0): Valid display device(s) on GeForce 9400 at PCI:2:0:0
[1061965.532] (--) NVIDIA(0):  CRT-0
[1061965.532] (--) NVIDIA(0):  DFP-0
[1061965.532] (--) NVIDIA(0):  DFP-1
[1061965.532] (--) NVIDIA(0):  BenQ G2420HDBL (DFP-2) (boot, connected)
[1061965.532] (--) NVIDIA(GPU-0): CRT-0: 300.0 MHz maximum pixel clock
[1061965.532] (--) NVIDIA(0): DFP-0: Internal TMDS
[1061965.532] (--) NVIDIA(GPU-0): DFP-0: 165.0 MHz maximum pixel clock
[1061965.532] (--) NVIDIA(0): DFP-1: Internal TMDS
[1061965.532] (--) NVIDIA(GPU-0): DFP-1: 165.0 MHz maximum pixel clock
[1061965.532] (--) NVIDIA(0): BenQ G2420HDBL (DFP-2): Internal DisplayPort
[1061965.532] (--) NVIDIA(GPU-0): BenQ G2420HDBL (DFP-2): 480.0 MHz maximum pixel clock
[1061965.532] (**) NVIDIA(0): Using HorizSync/VertRefresh ranges from the EDID for display
[1061965.532] (**) NVIDIA(0):  device BenQ G2420HDBL (DFP-2) (Using EDID frequencies has
[1061965.532] (**) NVIDIA(0):  been enabled on all display devices.)

This is my device section:

Code:
Section "Device"
  ### Available Driver options are:-
  ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
  ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
  ### [arg]: arg optional
  #Option  "SWcursor"  # [<bool>]
  #Option  "HWcursor"  # [<bool>]
  #Option  "NoAccel"  # [<bool>]
  #Option  "ShadowFB"  # [<bool>]
  #Option  "UseFBDev"  # [<bool>]
  #Option  "Rotate"  # [<str>]
  #Option  "VideoKey"  # <i>
  #Option  "FlatPanel"  # [<bool>]
  #Option  "FPDither"  # [<bool>]
  #Option  "CrtcNumber"  # <i>
  #Option  "FPScale"  # [<bool>]
  #Option  "FPTweak"  # <i>
  #Option  "DualHead"  # [<bool>]
  Option  "DPMS"
  Option  "TripleBuffer" "1"
  Option  "SLI" "Off"
  Option  "MultiGPU" "Off"
  Option  "BaseMosaic" "off"
  Identifier  "Card0"
  ##Driver  "nv"  # xorg driver
  Driver  "nvidia"  # nVidia's driver
  ##Driver  "vesa"
  VendorName  "nVidia Corporation"
  BoardName  "C79 [GeForce 9400]"
  BusID  "PCI:2:0:0"

  ## Added Feb 18, 2015 for xorg nv driver; not needed for real nvidia
  ##Option  "AccelMethod" "EXA"  # Essential or very slow
EndSection

You could see if adapting the above for your nVidia card helps, or you could simply delete all the xorg configuration files as that works :)
 
Replacing the nvidia-driver.conf with
Code:
Section "Device"
   Identifier "NVIDIA Card"
   Driver "nvidia"
   VendorName "NVIDIA Corporation"
   BoardName "GF117M [GeForce 820M]"
   BusID "PCI:1:0:0"
EndSection
didn't help either. I think I will delete the configuration file, so thanks for help.
 
The notebook includes an Intel Haswell CPU and uses Nvidia Optimus hybrid graphics according to the spec sheet. Not surprising as it's a gaming notebook. Unfortunately, Haswell graphics are almost but not quite yet supported(IIRC, it's mostly working in 11-CURRENT but not 10.3-RELEASE or earlier.) and Nvidia Optimus is also not supported in FreeBSD at this time. Some users have reportedly gotten the Intel graphics working in an Optimus setup but since your notebook includes Haswell graphics, that won't work here. The reason it works without a xorg.conf file is probably because X is falling back to the vesa(4) driver. That will certainly work, but will just be a little slow with no 3D acceleration.

If you can get by with the vesa(4) driver for a few months, 11.0-RELEASE should be released with Intel Haswell graphics support. That would possibly give you working graphics with 3D acceleration using Intel graphics.
 
I just installed FreeBSD 11.0-CURRENT on an USB-stick and tried Xorg with the same configuration files. The nVidia driver doesn't work in 11.0-CURRENT either. But I can live with the vesa(4) driver, 3D acceleration isn't that important. (Solved)
 
Back
Top