startx won't start TWM on Lenovo Thinkpad W520

Hi,

I have installed FreeBSD 13.2 on my Lenovo Thinkpad W520 following the Youtube videos "Getting Started With FreeBSD, Part 1" and "Getting Started With FreeBSD, Part 2" from Robonuggie.
When I do startx, it doesn't work and i get a fatal server error 'no screens found' and 'unable to connect to X server' and 'server error':
Code:
xauth:  file /root/.serverauth.1680 does not exist

X.Org X Server 1.21.1.7
X Protocol Version 11, Revision 0
Current Operating System: FreeBSD w520.local 13.2-RELEASE-p1 FreeBSD 13.2-RELEASE-p1 GENERIC amd64

Current version of pixman: 0.42.2
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sun Jul  2 20:35:46 2023
(==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
(EE)
Fatal server error:
(EE) no screens found(EE)
(EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error


I hope someone can help me configuring it so Xorg (startx) and KDE Plasma will work.



/etc/rc.conf
Code:
# SILENCE # ------------------------------------------------------------------
rc_startmsgs=NO

# NETWORK # -----------------------------------------------------------------
hostname="w520.local"
ifconfig_em0="DHCP"

# DAEMONS | yes # -----------------------------------------------------------
zfs_enable="YES"
sshd_enable="YES"
moused_enable="YES"
ntpdate_enable="YES"
dbus_enable="YES"
hald_enable="YES"
kdm5_enable="YES"
# slim_enable="YES"


# DAEMONS | no # ------------------------------------------------------------
sendmail_enable="NONE"

# FS # ----------------------------------------------------------------------
clear_tmp_enable="YES"

# OTHER # -------------------------------------------------------------------
syslogd_flags="-ss"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
kld_list="i915kms"
/etc/fstab
Code:
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ada0p2             none    swap    sw              0       0
proc    /proc   procfs  rw      0       0


My /var/log/Xorg.0.log file:
Code:
[ 16115.199]
X.Org X Server 1.21.1.7
X Protocol Version 11, Revision 0
[ 16115.199] Current Operating System: FreeBSD w520.local 13.2-RELEASE-p1 FreeBSD 13.2-RELEASE-p1 GENERIC amd64
[ 16115.199]
[ 16115.199] Current version of pixman: 0.42.2
[ 16115.199]    Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
[ 16115.199] Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[ 16115.199] (==) Log file: "/var/log/Xorg.0.log", Time: Sun Jul  2 15:31:04 2023
[ 16115.199] (==) Using config directory: "/usr/local/etc/X11/xorg.conf.d"
[ 16115.199] (==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
[ 16115.200] (==) No Layout section.  Using the first Screen section.
[ 16115.200] (==) No screen section available. Using defaults.
[ 16115.200] (**) |-->Screen "Default Screen Section" (0)
[ 16115.200] (**) |   |-->Monitor "<default monitor>"
[ 16115.200] (==) No device specified for screen "Default Screen Section".
        Using the first device section listed.
[ 16115.200] (**) |   |-->Device "Card0"
[ 16115.200] (**) |   |-->GPUDevice "Card0"
[ 16115.200] (==) No monitor specified for screen "Default Screen Section".
        Using a default monitor configuration.
[ 16115.200] (==) Automatically adding devices
[ 16115.200] (==) Automatically enabling devices
[ 16115.200] (==) Not automatically adding GPU devices
[ 16115.200] (==) Automatically binding GPU devices
[ 16115.200] (==) Max clients allowed: 256, resource mask: 0x1fffff
[ 16115.200] (==) 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/,
        catalogue:/usr/local/etc/X11/fontpath.d
[ 16115.200] (==) ModulePath set to "/usr/local/lib/xorg/modules"
[ 16115.200] (II) The server relies on udev to provide the list of input devices.
        If no devices become available, reconfigure udev or disable AutoAddDevices.
[ 16115.200] (II) Module ABI versions:
[ 16115.200]    X.Org ANSI C Emulation: 0.4
[ 16115.200]    X.Org Video Driver: 25.2
[ 16115.200]    X.Org XInput driver : 24.4
[ 16115.200]    X.Org Server Extension : 10.0
[ 16115.201] (!!) More than one possible primary device found
[ 16115.201] (--) PCI: (0@0:2:0) 8086:0116:17aa:21d1 rev 9, Mem @ 0xf1400000/4194304, 0xe0000000/268435456, I/O @ 0x00006000/64, BIOS @ 0x????????/65536
[ 16115.201] (--) PCI: (1@0:0:0) 10de:0dfa:17aa:21d1 rev 161, Mem @ 0xf0000000/16777216, 0xc0000000/268435456, 0xd0000000/33554432, I/O @ 0x00005000/128, BIOS @ 0x????????/65536
[ 16115.201] (II) LoadModule: "glx"
[ 16115.201] (II) Loading /usr/local/lib/xorg/modules/extensions/libglx.so
[ 16115.206] (II) Module glx: vendor="NVIDIA Corporation"
[ 16115.206]    compiled for 4.0.2, module version = 1.0.0
[ 16115.206]    Module class: X.Org Server Extension
[ 16115.206] (II) NVIDIA GLX Module  390.154  Wed Jun 22 04:44:23 UTC 2022
[ 16115.206] (II) LoadModule: "intel"
[ 16115.207] (II) Loading /usr/local/lib/xorg/modules/drivers/intel_drv.so
[ 16115.207] (II) Module intel: vendor="X.Org Foundation"
[ 16115.207]    compiled for 1.21.1.7, module version = 2.99.917
[ 16115.207]    Module class: X.Org Video Driver
[ 16115.207]    ABI class: X.Org Video Driver, version 25.2
[ 16115.207] (II) LoadModule: "nvidia"
[ 16115.207] (II) Loading /usr/local/lib/xorg/modules/drivers/nvidia_drv.so
[ 16115.207] (II) Module nvidia: vendor="NVIDIA Corporation"
[ 16115.207]    compiled for 4.0.2, module version = 1.0.0
[ 16115.208]    Module class: X.Org Video Driver
[ 16115.208] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
        i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
        915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
        Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
        GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[ 16115.208] (II) intel: Driver for Intel(R) HD Graphics
[ 16115.208] (II) intel: Driver for Intel(R) Iris(TM) Graphics
[ 16115.208] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics
[ 16115.208] (II) NVIDIA dlloader X Driver  390.154  Wed Jun 22 04:46:19 UTC 2022
[ 16115.208] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[ 16115.208] (--) Using syscons driver with X support (version 2.0)
[ 16115.208] (--) using VT number 9

[ 16115.218] (EE) No devices detected.
[ 16115.218] (EE)
Fatal server error:
[ 16115.218] (EE) no screens found(EE)
[ 16115.218] (EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
[ 16115.218] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
[ 16115.218] (EE)
[ 16115.234] (EE) Server terminated with error (1). Closing log file.


Output of kldstat

Code:
Id Refs Address                Size Name
 1   56 0xffffffff80200000  1f3e2d0 kernel
 2    1 0xffffffff8213f000     a4a0 cryptodev.ko
 3    1 0xffffffff8214a000   59dfa8 zfs.ko
 4    1 0xffffffff82b20000   1858b8 i915kms.ko
 5    1 0xffffffff82ca6000    739e0 drm.ko
 6    2 0xffffffff82d1a000     5220 linuxkpi_gplv2.ko
 7    3 0xffffffff82d20000     62d8 dmabuf.ko
 8    1 0xffffffff82d27000     3378 acpi_wmi.ko
 9    1 0xffffffff82d2b000     3250 ichsmb.ko
10    1 0xffffffff82d2f000     2180 smbus.ko
11    1 0xffffffff82d32000     4d00 ng_ubt.ko
12    6 0xffffffff82d37000     aac8 netgraph.ko
13    2 0xffffffff82d42000     a238 ng_hci.ko
14    4 0xffffffff82d4d000     25a8 ng_bluetooth.ko
15    1 0xffffffff82d50000     e250 ng_l2cap.ko
16    1 0xffffffff82d5f000    1bee8 ng_btsocket.ko
17    1 0xffffffff82d7b000     39c0 ng_socket.ko
 
You need to pkg install drm-kmod package.
If you did that already you need to change this line to point to the ports version of i915kms.ko:

Fix /etc/rc.conf path.
kld_list="/boot/modules/i915kms.ko"

You see there are two files of the same name. One from base and one from ports.
# find /boot -name i915kms.ko
Code:
/boot/modules/i915kms.ko
/boot/kernel.old/i915kms.ko

Looks like base i915kms is now removed on FreeBSD 13.2 (see /kernel.old/).
 
OK did some reading. W520 might have Optimus.
This is dual graphics with Nvidia and Intel.
The ThinkPad W520's Nvidia Quadro 2000M graphics card is designed....

That might take a different approach. Confirm you have dual graphics. Look around. There might be an Optimus driver in ports.

x11/nvidia-secondary-driver/
Note that there are two flavors of the port. One for 390 driver and one for 515.
Which one depends on base driver needed for Quadro2000M (either 390 or 515 flavor).
I would try the nvidia-secondary-driver-390 package.
The 515 driver does not support Quadro 2000M on its list.
Notice the 390 driver has the Quadro 2000M at the bottom of the list.
So you should try the 390 secondary package
pkg install nvidia-secondary-driver-390
 
I invite you to try booting a Ghostbsd.org/download . I believe we have overcome booting to a desktop with an Optimus 2 graphics card Intel and NVidia gpus. Resources https://forums.ghostbsd.org http://t.me/ghostbsd Telegram Desktop group WIll take you time to download and write to a USB flash drive, then boot from the USB flash drive. With 4 Gigs dram, you can boot and try on your Lenovo T520. Then look at the configuration files and see what to set for your FreeBSD install. Welcome to BSD computing Fred Finster
 
Phishfry I found /boot/modules/i915kms.ko so I edited /etc/rc.conf and changed kld_list="i915kms" to kld_list="/boot/modules/i915kms.ko"

I had turned off the NVIDIA card in the BIOS, but I have turned it on again. Not in Optimus mode, because the BIOS says that Optimus should only be used when Windows 7 is installed.

And I installed the nvidia-secondary-driver-390. (my W520 has a Nvidia GF108GLM [Quadro 1000M] graphics card, which is compatible with the 390 driver).

But startx still doesn't load TWM and ends with the same error.
 
I tried booting from the GhostBSD flash drive, but got the same error: 'no screens found' and 'unable to connect to X server' and 'server error'.
Then I created a HelloSystem flash drive and that diid boot in a Gui desktop. But that is based on FreeBSD 13.1 in stead of 13.2. I will now try installing FreeBSD 13.1 and then Xorg and KDE Plsma on my Thinkpad W520 to see if I can get that working.
 
I tried booting from the GhostBSD flash drive, but got the same error: 'no screens found' and 'unable to connect to X server' and 'server error'.
Then I created a HelloSystem flash drive and that diid boot in a Gui desktop. But that is based on FreeBSD 13.1 in stead of 13.2. I will now try installing FreeBSD 13.1 and then Xorg and KDE Plsma on my Thinkpad W520 to see if I can get that working.
Thank you for trying, Schuss, with GhostBSD and HelloSystem flash drive. There is NomadBSD.org and MidnightBSD.org also. From GhostBSD and FreeBSD 13.2 (that exhibited screen problems ) and HelloSystem (that did NOT exhibit screen problems). Could you examine the dmesg output that shows the screen failure or tail -50 /var/log/messages and tail -50 /var/log/Xorg.0.log. Maybe with some information, we can dissect the screen display error problem. Probably some version diffferences in the display driver. If you can post the information you uncover in a bug report, EricBSD might look and suggest solution for screen display error problem. He has access to FreeBSD developers.
https://ghostbsd.org/Support/Bugs_&_Feature_Request
Here is github Bug report URL link https://github.com/ghostbsd/issues/issues/new?assignees=&labels=bug&template=bug_report.yaml

Thank you again, Schuss, for testing and reporting your findings here in this freebsd forum post. This sharing will help others in Future who look to get their optimux Intel and Nvidia graphics cards operational with NVidia 390 version graphics driver.

I looked at bsd-hardware.info and saw several Lenovo W520 model versions listed. http://bsd-hardware.info/?view=computers&vendor=Lenovo&model=ThinkPad+W520+(All)
Which specific version matches your version ?
pkg install hw-probe
hw-probe -all -upload
Nomad.org does conatin this tool hw-probe

http://bsd-hardware.info/?probe=40198abaa2&log=xorg.log.1 Here is just one sample Xorg.0.log file for probing and finding Intel HD3000 graphics card
 
When I do startx, it doesn't work and i get a fatal server error 'no screens found' and 'unable to connect to X server' and 'server error':
Hi Schuss,

Not sure if this is germane, but I have recently had a problem with my W520. I was not able to upgrade FreeBSD 13.2 over the last few months...Whenever I would update it, I would lose X. I thought it was a problem with a package, however it turned out that, at some point, the optimus had been turned back on in BIOS, and the laptop was apparently getting confused because it was autodetecting the optimus card and turning on both the nvidia and the intel parts of the card...

My fix was to go into the BIOS, and under Config -> Display, set the Graphics Device to "Integrated" and then make sure the OS Detection for Optimus is set to disabled, otherwise it turns on both cards again, and you are in the same boat.

Cheers,
--vr
 
Starting a GUI sounds easy but has a few prerequisites:

/etc/rc.conf should contain
Code:
kld_list="${kld_list} i915kms"

The user should be in the video group.

The startx should have an entry in ~/.xinitrc what WM to start:
Code:
exec /usr/local/bin/twm
KDE Plasma will be in the same directory, just browse and find the proper name.

Check and double check the FreeBSD Handbook on using Xorg.
 
My fix was to go into the BIOS, and under Config -> Display, set the Graphics Device to "Integrated" and then make sure the OS Detection for Optimus is set to disabled, otherwise it turns on both cards again, and you are in the same boat.
Exactly. The bios has the optimus switch. you must fiddle with this.
Disabled you use i915kms Intel driver.
Enabled you use nvidia-secondary driver

My problem with 'disabled' is your NVidia GPU is still burning watts even if disabled.
You might as well use it.
Its more like a video mux setting than anything.

Because you can't disable Intel Graphics it too is always on.
So you need to consider writing an /usr/local/etc/X11/xorg.conf.d/nvidia-video.conf settings file for xorg to know what video device to use with nvidia-secondary driver..
 
Microsoft really has a knack of being involved with things like Optimus and 32-Bit EFI which were meant to screw over open source.

All hail our github gods.
 
Wikipedia has a good blurb that is relevant here..
Some older and high-end laptops contain a BIOS setting to manually select the state of the hardware multiplexer to switch output between the two video devices. In this case, a Linux user can place the laptop in hardware configurations where there is only once graphics device. This avoids the complexities of running two graphics drivers, but offers no power savings.
Emphasis added because early in the article it sounds like you can shutoff the Nvidia GPU.
 
Exactly. The bios has the optimus switch. you must fiddle with this.
Disabled you use i915kms Intel driver.
Enabled you use nvidia-secondary driver

Going by what happens on my T430s on 12.4, resume from suspend depends on i915kms. I suspect the W520 likely requires the same.

Perhaps switch magic could be added to /etc/rc.{suspend,resume} to ensure i915kms was active on suspend and selected state restored on resume, if suspending is important. It's vital for me.

My problem with 'disabled' is your NVidia GPU is still burning watts even if disabled.
You might as well use it.
Its more like a video mux setting than anything.

I wonder if there's any way to have something? use pci_{g,s}et_powerstate to reduce power on unused but enabled devices, to D1 to D3. See pci(9) - but it's not like USB where power states are easily controlled from userland.

Because you can't disable Intel Graphics it too is always on.
So you need to consider writing an /usr/local/etc/X11/xorg.conf.d/nvidia-video.conf settings file for xorg to know what video device to use with nvidia-secondary driver..

All a bit non-trivial compared to choosing only one device, but likely doable with effort.
 
Hello schuss,
I have Lenovo T530 and use Optimus NVIDIA.
Its almos work fine for mi... you can see whats happen in my case here: https://forums.freebsd.org/threads/multidisplay-on-thinkpad-t530.89626/

You have 3 options how you can use your graphics card:

1. Only Intel card. "Integrated Graphics" options in BIOS setting.
2. Only NVIDIA card. "Discrete Graphics" options in BIOS setting.
3. Hybrid. "NVIDIA Optimus" options in BIOS setting.


Not in Optimus mode, because the BIOS says that Optimus should only be used when Windows 7 is installed.
You can use Optimus mode in FreeBSD with x11/nvidia-hybrid-graphics-390-0.5

Now I use options number 3 in my laptop.
This is my config, I hope it can be useful for you.

1. Enable "NVIDIA Optimus" in BIOS setting.

2023-07-09_13-39.png


2. Install drivers for NVIDIA Optimus and Intel

# pkg install nvidia-hybrid-graphics-390-0.5 drm-kmod

3. rc.conf look like this:

Code:
#Linux Binary Compatibility
linux_enable="YES"

#NVIDIA
nvidia_load="YES"
kld_list="${kld_list} nvidia-modeset"

#NVIDIA HYBRID Xorg in headless mode on Display 8
nvidia_xorg_enable="YES"

#Intel VIDEO CARD
kld_list="${kld_list} i915kms.ko"

4. Edit your xorg.conf

Delete (or move) all your config of Xorg and just leave one for Intel graphic card.
Check and if necessary change yours BusID for Intel

Code:
# cat /usr/local/etc/X11/xorg.conf.d/20-drivers.conf
Section "Device"
    Identifier     "Card1"
    Driver         "intel"
    BusID          "PCI:0:2:0"
    VendorName     "Intel Corporation"
EndSection

5. Create Xorg config for Xorg in headless mode on Display 8
Check and if necessary change yours BusID for NVIDIA

Code:
# cat /usr/local/etc/X11/xorg-nvidia-headless.conf.d/xorg-nvidia-headless.conf
Section "ServerLayout"
    Identifier     "nvidia"
    Screen      0  "Screen0"
    InputDevice    "fake" "CorePointer" "CoreKeyboard"
    Option         "AutoAddDevices" "false"
EndSection

Section "Files"
    ModulePath      "/usr/local/lib/xorg/modules-NVIDIA"
    ModulePath      "/usr/local/lib/xorg/modules"
EndSection

Section "Module"
    Load           "dri3"
    Load           "glx"
    Disable        "efifb"
EndSection

Section "InputDevice"
    Identifier     "fake"
    Driver         ""
EndSection

Section "Monitor"
    Identifier     "Monitor0"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    BusID          "PCI:1:0:0"
    Option         "UseDisplayDevice" "None"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
EndSection

6. Restart your laptop.

P.S.
What we have:
My Intel card it`s a "main" Graphic card

2023-07-09_14-32.png


And NVIDIA work with second Xorg in headless mode on Display 8.
And I can redirect heavy graphics applications to NVIDIA with nvrun or nvrun-vgl

2023-07-09_14-35.png
 
Back
Top