Encender el HDMI de la Raspberry PI aunque no esté conectada a una pantalla
Todo empezó de manera inocente con este mensaje que escribí en el foro OSMC:
Title: Audio related messages flooding the logs when no HDMI display present
For “reasons”, during the christmas holidays, I am using my regular OSMC Raspberry PI device abroad with no HDMI cable connected to a screen. No display at all. This is useful to me because this device does other functions beside OSMC.
I noticed these messages flooding /home/osmc/.kodi/temp/kodi.log:
2024-12-27 02:00:52.928 T:688 info <general>: CActiveAESink::OpenSink - initialize sink 2024-12-27 02:00:52.929 T:688 info <general>: CAESinkALSA::Initialize - Attempting to open device "default" 2024-12-27 02:00:52.931 T:688 info <general>: CAESinkALSA - Unable to open device "default" for playback 2024-12-27 02:00:52.931 T:688 error <general>: CAESinkALSA::Initialize - failed to initialize device "default" 2024-12-27 02:00:52.931 T:688 error <general>: CActiveAESink::OpenSink - no sink was returned 2024-12-27 02:00:52.931 T:687 error <general>: ActiveAE::InitSink - returned error 2024-12-27 02:00:52.935 T:674 error <general>: failed to duplicate EGL fence fd (EGL_SUCCESS)The logfile grows fast, possibly filling soon the microSD and decreasing its lifetime.
Beside that, maybe unrelated, KODI is using all the file descriptors (1024 in my case) trying to do “something”. Maybe related to those logs or not:
root@osmcpi:/home/osmc/.kodi/temp# ls -la /proc/674/fd|tail lr-x------ 1 root root 64 Dec 27 02:03 990 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 991 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 992 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 993 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 994 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 995 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 996 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 997 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 998 -> anon_inode:sync_file lr-x------ 1 root root 64 Dec 27 02:03 999 -> anon_inode:sync_fileChecking /proc/674/fdinfo/ I see this (the same data for any file descriptor):
root@osmcpi:/home/osmc/.kodi/temp# cat /proc/674/fdinfo/999 pos: 0 flags: 02000000 mnt_id: 14 ino: 7559I can not determine what mount id 14 filesystem is, even using findmnt.
All filedescriptors stuck prevent my kodi extensions to work correctly, for instance, to update IMDb ratings or screensavers. Not very important while this raspberry is headless during this trip, but I wonder if both issues are related and how to prevent them.
Interestingly, if I plug the HDMI wire to a display, everything works fine.
So, my questions:
- How can I avoid flooding the log my Raspberry PI is running OSMC while headless?. This is an old issue of mine with some friends’ raspberries OSMC when they switch off their TV.
- What is the reason for having all file descriptors (1024) stuck and how to solve it?
Happy Holidays and thanks for your time.
This is a Raspberry PI 3B+, OSMC fully updated.
La respuesta fue apropiada, pero decepcionante: En vez de diagnosticar el problema el consejo fue desactivar KODI cuando esté utilizando la Raspberry PI sin una pantalla conectada. Por ejemplo, usando el comando systemctl stop mediacenter.
Poco satisfecho, seguí investigando. El problema de fondo es que, por defecto, cuando la Raspberry PI se enciende sin una pantalla HDMI conectada, no activa la salida HDMI, y sin dicha salida tampoco se activa, por defecto, el sistema de audio. Los errores que se muestran más arriba son los intentos de KODI de conectarse a un sistema de audio que, sencillamente, está desactivado.
Un efecto secundario es que si enchufamos la pantalla HDMI a la Raspberry PI una vez que esta está funcionando, no tendremos salida de vídeo hasta el próximo reinicio de la Raspberry PI con la pantalla conectada.
¿Cómo activar la salida HDMI de la Raspberry PI aunque no esté conectada a una pantalla? En realidad se trata de un problema común bastante bien documentado. Ejemplos:
- How do I force the Raspberry Pi to turn on HDMI?.
- Raspberry Pi: Force HDMI – Hotplug.
- Forcing HDMI output on Bookworm.
- How do you make the HDMI hot-pluggable on a Pi?.
- Display-HDMI - Hotplug!.
- Re: Bullseye equivalent for hdmi_force_hotplug=1?.
- Can't get a display image using the HDMI.
La lista de ejemplos es infinita, pero la solución es simple, aunque en algunos casos es necesario algo de experimentación: Hay que añadir al fichero /boot/config.txt la línea hdmi_force_hotplug=1. Para asegurar que hay sonido, podemos añadir hdmi_drive=2.
Como casi siempre, lo mejor es acudir a la fuente:
Advertencia
Si forzamos encender el HDMI aún sin monitor, si no forzamos un modo concreto o hemos grabado la información EDID del monitor, la Raspberry PI arrancará con una resolución reducida y compatible con casi cualquier cosa. Eso está bien, pero la imagen puede verse mal por la baja resolución. Habría que reiniciar la Raspberry PI con una pantalla HDMI conectada o bien fijar una configuraciòn manual o un volcado EDID previo. Lo segundo funcionaría hasta que enchufemos algún monitor incompatible con los modos que hemos puesto manualmente...