26

We have a Pi3 connected to a TV on a remote worksite.

Sometimes, the remote site has a power outage, and when power is restored, the TV and Pi get power at the same time.

The problem is that the TV takes a while to power up, so when the Pi starts up, as far as it can tell, there's nothing plugged into its HDMI port.

Unfortunately, using the 2018-11-13-raspbian-stretch-full.img raspbian image (with the GUI), unless the TV is already powered up and plugged into the Pi when the Pi is starting up, the Pi will output nothing to the TV.

There's an option in /boot/config.txt called hdmi_force_hotplug=1 which is commented out by default. Uncommenting it causes the HDMI to be hot-pluggable.

The problem now is that if you plug a TV or monitor in after the Pi starts up, the resolution is horrible. It is way, way below the regular 1920x1080 that it normally runs at.

Our Pi automatically opens up a browser on boot to a particular page, and is totally unattended - there's no one to notice, or fix the resolution on site. We need it to be able to automatically fix itself if the TV is not detected on boot.

Does anyone know any way to fix this?

Edit: While there are a few answers below that are helpful, none really make the HDMI hot-pluggable. When a Desktop OS like Ubuntu/Fedora/Windows has a new monitor plugged into it, it detects it immediately, and adjusts the resolution on it immediately. It doesn't require a reboot, or a hard-coded resolution. The ideal solution would do something similar.

I would think that one way to do it would be to have a service constantly query the HDMI device for an EDID, and cache it. If the EDID changes, the device must have changed, and if the new device has a different preferred resolution, it should change the active resolution to match that.

I have no problems writing a service that can query the EDID, cache it, and see if a resolution change needs to be made. I'm just not sure how to use the terminal to change the Desktop's active resolution without a reboot. I'm not sure if I should be looking for a way to change the framebuffer resolution, or X Server's resolution, or the Desktop Environment's resolution, or all of the above.

7
  • 7
    You should just need to set the resolution to 1920x1080 in Raspberry Pi Configuration.
    – CoderMike
    Commented Jan 7, 2020 at 16:57
  • 1
    In /boot/config.txt? I see framebuffer_width and framebuffer_height. Is that what you're talking about?
    – John
    Commented Jan 7, 2020 at 17:18
  • 2
    Set the static resolution by the help of these links: stackoverflow.com/a/29318136/6602159 | stackoverflow.com/a/23355379/6602159 Commented Jan 7, 2020 at 17:20
  • smells fishy - I have a raspberry Pi3B , connected via HDMI to a Dell screen, which I switch on over the powercable .. so both come up at the same time ... I can even switch off the screen, replug the Pi - and it still comes up with a good resolution - I would upgrade raspbian in your place.. over 15 months old...
    – eagle275
    Commented Jan 8, 2020 at 15:53
  • Would using a power sequencer (q.v.) be acceptable? Commented Jan 8, 2020 at 20:21

4 Answers 4

27

In /boot/config.txt:

hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16

Those are explained here: https://www.raspberrypi.org/documentation/configuration/config-txt/video.md

There is also this: https://www.raspberrypi.org/documentation/configuration/hdmi-config.md -- But if the group 1, mode 16 as above works, you don't have to worry about all that.

4
  • 3
    This does indeed work, and the documentation you linked to is amazing at explaining the options. This does however assume that you know the resolution of the HDMI device ahead of time. We have one Pi image that we clone to as many Pis as we want, and install on site. If a Pi set for 1080p gets plugged into an older TV that doesn't support 1080p, we'd need someone to manually login to the pi to change settings. Is there no way for the Pi to detect a new HDMI device getting plugged in, and change the resolution on a running system automatically? That's what desktop OS's do, isn't it?
    – John
    Commented Jan 8, 2020 at 19:25
  • I'd guess this is a hardware limitation -- the stuff in config.txt isn't used by the OS at all, as far as I am aware. It's used by the firmware before the kernel is loaded. Standard desktop linux does detect and size display output appropriately, but in this context it's getting that size from the SoC. I've never used tvservice, but the output from tvservice -h implies it can be used to dynamically reconfigure a display. That may or may not include "on a Pi".
    – goldilocks
    Commented Jan 8, 2020 at 19:38
  • "Linux isn't like in 2003. It just works! Oh and if you want to see stuff when you plug in a screen you have to edit a text file and btw it won't automatically detect the resolution." lol
    – Timmmm
    Commented Apr 22, 2020 at 18:51
  • 1
    It does not matter what OS or software you run. The hard/firm -ware on the Pi sets the resolution before the OS loads and it cannot be changed without restarting that hardware. The config file in /boot has nothing to do with linux, it is never used for anything by the OS. It is used by the Pi's (partially proprietary) firmware. So again, this is a limitation of the device, not the operating system.
    – goldilocks
    Commented Apr 22, 2020 at 19:06
6

In 'Raspberry Pi Configuration', select 'Set Resolution'

enter image description here

Choose resolution, then reboot.

enter image description here

3
  • 2
    Why JPEG (first image has specific artifacts, despite having PNG format now)? Why upsample (both images)?
    – Ruslan
    Commented Jan 8, 2020 at 7:41
  • 3
    @Ruslan My guess would be that it is a screenshot of a screenshot being shown on a high-dpi system.
    – jpa
    Commented Jan 8, 2020 at 9:04
  • This appears to be the Graphical way to set the same options as @goldilocks mentioned. I wouldn't be surprised if this is just a frontend that automatically modifies /boot/config.txt. Either way, it's good to know both ways to set the resolution - thanks
    – John
    Commented Jan 8, 2020 at 19:29
1

I'm just not sure how to use the terminal to change the Desktop's active resolution without a reboot. I'm not sure if I should be looking for a way to change the framebuffer resolution, or X Server's resolution, or the Desktop Environment's resolution, or all of the above.

From my understanding, the Raspberry Pi GPU resolution is completely unrelated to the framebuffer resolution after boot. tvservice lets you change the GPU resolution, and tvservice -p will use the native resolution of whatever TV/monitor is plugged in. The framebuffer/X server (AFAIK the DE just uses the X server's resolution) is a trickier problem.

You'll need to use fbset to reload the framebuffer resolution. However, fbset will only actually reload the settings if you make changes. You could create a modified version without this limitation, or just do fbset -depth 32; fbset -depth 16 to set the depth to 32 and back to the default of 16 (if you're using a 32-bit framebuffer, switch the order).

Refreshing xorg is much simpler. While I believe changing the framebuffer resolution will set the xorg resolution automatically, windows will need to repaint. xrefresh (part of x11-xserver-utils) will do this for you.

1

There actually exists an easy solution provided that the same (kind of) monitor is connected. The procedure is as follows:

  1. Boot the rpi with the monitor connected via hdmi. It should now work as usual.
  2. As the settings are now correct we can save them by the command sudo /opt/vc/bin/tvservice -d /boot/edid.dat.
  3. Next we modify config.txt by uncommenting hdmi_force_hotplug=1 and adding hdmi_edid_file=1.
  4. When one reboots without the monitor connected the rpi will still set the characteristics for the monitor according to the stored information in edid.dat.
  5. When plugged into the hdmi port, the monitor will come into action in a second or so.

For the RPi4 the procedure is slightly more complicated as there are two hdmi ports, but the idea is the same.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.