简体   繁体   中英

VNC on Raspberry Pi shows Cannot Currently Show the Desktop

I am trying to use VNC in a headless install on my Raspberry Pi 4, running Raspberry Pi OS, installed via Raspberry Imager. The install is more or less vanilla, as the only changes I have made are for connecting (seting up SSH, wireless and VNC as noted in this guide: https://www.tomshardware.com/reviews/raspberry-pi-headless-setup-how-to,6028.html ).

When I log in via VNC I get the "Cannot Currently Show the Desktop"-error. It should be possible to fix by changing the screen resolution via raspi-config, but that makes the pi unresponsive. Setting the pi to use "G3 legacy" should fix that issue either after a reboot or without (answers vary on that), but it doesn't seem to make a difference in either case.

Does anyone know how I can get to connect via VNC to my pi?

Thanks:)

Tested in raspberry 4 using raspbian buster:

  1. Launch command line and run:

    sudo raspi-config

  2. Display options -> Resolution. Then select a resolution mode, I recommend select 1280x720 but you can also choose the higher resolution (1920x1080). Save and finish.

  3. Reboot and connect to raspberry again through VNC client.

Basically should be sufficient to specify a HDMI mode. I have a Raspberry Pi4 headless, this is my configuration in /boot/config.txt

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=82

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
gpu_mem=128
start_x=1
enable_uart=1
#hdmi_enable_4kp60=1

Then I disabled encryption and set a VNC password. In addition, if you to see the raspistill/raspivid preview through VNC you have to enable this: RealVNC Viewer > Menu > Options > Troubleshooting > Optimize screen capture - select 'Enable direct capture mode'

According to the documentation :

If your Raspberry Pi is headless (ie not plugged into a monitor) or controlling a robot, it is unlikely to be running a graphical desktop.

So the idea is to create a new virtual desktop via vncserver command and use the display number in VNC.

It is sufficient to uncomment one line in the configuration in /boot/config.txt:

# uncomment if hdmi display is not detected and composite is being output
# hdmi_force_hotplug=1

Find this part in the file and remove the # before hdmi_force_hotplug=1 . Save the file (use sudo). Remove the hdmi, then reboot, and now you should see the desktop with VNC.

To set the resolution to 1920×1080 (1080p) 60Hz , you have to uncomment and modify 2 more lines:

# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=82

To see what the numbers/modes mean, see HDMI Display Modes .

TL;DR

Setting the resolution of VNC in Raspberry Pi (RPi):

/usr/bin/xrandr --fb 1920x1080

Long answer

One can examine the code of raspi-config bash script, here

Look for the do_vnc_resolution function.

My Rpi4 Bullseye machine had set itself into safe mode … in /boot/config.txt the line

hdmi_safe=1

Was uncommented.

Commenting it out fixed my lo-resolution VNC display problem

Then had to reboot, then logout, and login for everything to be set ok

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM