树莓派上的VNC显示“无法显示桌面”

6

我正在尝试在我的树莓派4上使用VNC无头安装,运行的是通过Raspberry Imager安装的Raspberry Pi OS。安装基本上是原始的,因为我所做的唯一更改是为了连接(根据此指南设置SSH,无线和VNC)。

当我通过VNC登录时,我会收到“当前无法显示桌面”的错误。可以通过通过raspi-config更改屏幕分辨率来解决它,但这会使pi无响应。将pi设置为使用“G3 legacy”应该可以解决这个问题,可以在重启后或不重启的情况下(答案有所不同),但在任何情况下似乎都没有任何区别。

有谁知道怎么才能通过VNC连接到我的pi?

谢谢 :)

6个回答

7
根据文档

如果您的Raspberry Pi是无显示器(即无头)或控制机器人,则不可能运行图形桌面。

因此,想法是通过vncserver命令创建一个新的虚拟桌面,并在VNC中使用该显示数字。

1
我欠你一杯你喜欢的饮料。我花了两天时间阅读指南,这就是它们所有缺失的东西。 - CanonicalBear
很高兴能帮助@CanonicalBear! - Tarod
4
我曾陷入阅读教程并按照所提供的步骤一无所获的循环中。运行vncserver就是我需要做的全部。感谢@CanonicalBear。 - Devin Norgarb

4

Raspbian Buster:

  1. 打开命令行并运行:

    sudo raspi-config

  2. 显示选项 -> 分辨率。然后选择分辨率模式,我建议选择 1280x720,但您也可以选择更高的分辨率(1920x1080)。保存并完成。

  3. 重新启动并通过 VNC 客户端再次连接树莓派。

Raspbian Bullseye:

  1. 打开命令行并运行:

    sudo raspi-config

  2. 显示选项 -> VNC 分辨率。然后选择分辨率模式,我建议选择 1280x720,但您也可以选择更高的分辨率(1920x1080)。保存并完成。

  3. 重新启动并通过 VNC 客户端再次连接树莓派。


3
这曾经是可以运行的,但现在在最新版本的Raspbian下似乎已经出了问题。 - Lucas
对我来说也一样,在树莓派4B上无法运行(最新的操作系统更新)。 - TOL

4

基本上只需指定HDMI模式即可。我有一台没有显示器的Raspberry Pi4电脑,以下是我的/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

然后我关闭了加密并设置了一个VNC密码。此外,如果你想通过VNC查看树莓派摄像头的预览,你需要将其启用:RealVNC Viewer > 菜单 > 选项 > 故障排除 > 优化屏幕截取 - 选择“启用直接截取模式”。


嗨,rok。谢谢你的回答。我已经将你的配置文件复制粘贴到我的树莓派上,但没有任何改变。每当我尝试访问屏幕分辨率时,我的树莓派仍然会挂起,并且我无法通过VNC获取桌面 :( - Martin Vinter
我不明白你所说的“我尝试访问屏幕分辨率”的意思...只需将我的配置文件中的设置复制到你的文件中即可,它已经包含了屏幕分辨率设置。我建议你尝试使用全新的Raspbian安装。 - rok

1

我的Rpi4 Bullseye机器已经设置为安全模式...在/boot/config.txt文件中,这一行

hdmi_safe=1

被取消注释。

将其注释掉后,解决了我低分辨率VNC显示问题

然后必须重新启动,注销并登录以使所有设置正常


1

取消注释 hdmi_force_hotplug=1 对我也解决了这个问题。 - Sego

0

简述

设置树莓派(Raspberry Pi)中 VNC 的分辨率:

/usr/bin/xrandr --fb 1920x1080

长答案

可以检查 raspi-config Bash 脚本的代码,这里

寻找 do_vnc_resolution 函数。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接