Can't start Kodi

I just installed DietPi and had Kodi working yesterday, but it’s not working now. When I start Kodi, the screen goes black for few seconds and comes back without any warning or error message.

I successfully setup squeezelite and RealVNC today. Is there a conflict among these softwares?

How do I view the logs? Please help.

does the command startkodi gives any output?

Nope. Same as clicking on the icon.

there is nothing shown on command line if you execute startkodi ?

Can you share some more system details

Required Information

  • DietPi version | cat /boot/dietpi/.version
  • Distro version | echo $G_DISTRO_NAME $G_RASPBIAN
  • Kernel version | uname -a
  • SBC model | echo $G_HW_MODEL_NAME or (EG: RPi3)

root@DietPi:~# cat /boot/dietpi/.version
G_DIETPI_VERSION_CORE=7
G_DIETPI_VERSION_SUB=9
G_DIETPI_VERSION_RC=3
G_GITBRANCH=‘master’
G_GITOWNER=‘MichaIng’
G_LIVE_PATCH_STATUS[0]=‘applied’
G_LIVE_PATCH_STATUS[1]=‘not applicable’
G_LIVE_PATCH_STATUS[2]=‘not applicable’
G_LIVE_PATCH_STATUS[3]=‘not applied’
root@DietPi:~# echo $G_DISTRO_NAME $G_RASPBIAN
bullseye 0
root@DietPi:~# uname -a
Linux DietPi 5.10.63-v7+ #1488 SMP Thu Nov 18 16:14:44 GMT 2021 armv7l GNU/Linux
root@DietPi:~# echo $G_HW_MODEL_NAME
RPi 3 Model B+ (armv7l)
root@DietPi:~#


This time I try to run Kodi (by clicking on the icon or use startkodi), it shows a black screen with “Unable to Create GUI. Exiting.” on the top right corner. Then it freezes.

is there a need to start it from desktop? Would it be an option to try autostart feature?

I need to use web browsers so it’s not an option to autostart to Kodi.

ok I setup a RPi3B+ using same version as you. Installed LEDX + Kodi and selected autostart option 2 : Automatic login. This way I’m able to start kodi from desktop without issues. What version of Kodi you are running

dpkg -l kodi

When I freshly installed DietPi two days ago, I was able to start Kodi and it was v19.3. Then I setup RealVNC and Squeezelite, and turned off my RPi. Then I couldn’t start Kodi the very next day.

Are you trying to view Kodi directly or via VNC?

Kodi cannot be viewed through VNC due to how it interacts with the display. It is direct and not via the normal routes, which basically makes it invisible to VNC and other remote desktop apps.

I did try that, but I also tried to run Kodi directly using a keyboard and a mouse connected to my RPi.

I removed Kodi and reinstalled it. Now Kodi works, well partially.

I have difficulties setting up the sound card, which is a Hifiberry DAC2 Pro.

In Audio Options, if I use the one in Auto Detection (hw:1,0), I don’t get sound in Kodi. I can’t even find hifiberry option in Kodi audio setup.
If I use hifiberry-dacplus, I get sound in Kodi, but lose sound from the system (no sound watching YouTube) and no sound from Squeezelite service.

Also, to get YouTube sound, I need to stop squeezelite service. This is so inconvenient.
soundcard1.jpg
soundcard2.jpg

MichaIng can you have a look pls, you are more the sound expert.

I think this is due to the additional KMS audio devices which show up with different card index recently. Please check:

aplay -l

The DAC, depending on RPi model, shows as card 1 or card 2. Replace the card index in /etc/asound.conf accordingly, which should restore system sound. In Kodi you can define/select the sound card explicitly, which is why it works. When /etc/asound.conf is fixed, in Kodi you can also select “default” which should then be the DAC as well.

I’ll play a bit with the different conditions of the sound card appearance and indices to ship a reliable selection with DietPi v8.0, independant of KMS being used or not. The required logic has become more complicated.

root@DietPi:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi [vc4-hdmi], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0 [HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0]
Subdevices: 0/1
Subdevice #0: subdevice #0
root@DietPi:~#

Now I set /etc/asound.conf as

pcm.!default {
type hw
card 1
device 0
}

ctl.!default {
type hw
card 1
}

Then I get system sound from the DAC, but Kodi sound is from HDMI. The DAC is not present in Kodi’s audio option. See picture.

Also, I still have to stop squeezelite to get YouTube sound from the system. Is it normal?

Sorry I was on a trip over Christmas days. Strange that the USB DAC does not appear in Kodi audio settings, and also I was expecting a “default” ALSA device which now correctly points to the DAC. I’ll test this at home.

That only one player can access each audio device is normal on Linux with ALSA. There is a dmix plugin which allows concurrent payback, but the RPi VC4 HDMI audio device(s) do not support it, discussed just recently on the RPi GitHub :thinking:. Probably Kodi does even hide the DAC as it is currently used by Squeezelite. Could be tested via:

systemctl stop squeezelite
startkodi

If this works, I can give you instructions about how to enable the dmix plugin. Looks like this is another reasonable addition for our audio options, apart of fixing the sound card selection when these VC4 HMDI devices are present.

I got it fixed. Basically, I need to add “-C 10” to the start up command for squeezelite so it can turn off (or release) audio device after 10 sec.

Ah right, I forgot about that option. I just had a look, when installed via dietpi-software, the service file should start Squeezelite with -C 5 automatically :thinking:. Did you install it manually?

Happy new year btw :slight_smile:.

I installed squeezelite from dietpi-software. I guess somehow the default “-C 5” did not work. Happy new year to you, too.

Strange :thinking:. I’ll test this as well, probably there is a minimum value or the other of the options play a role?

I could verify that a USB DAC shows up find in Kodi, when not in use by other software. Furthermore it is possible to disable the VC4 HDMI devices completely. One can add ,noaudio to the end of the dtoverlay=vc4-kms-v3d line. But RPi onboard audio must be completely disabled then, at least the onboard firmware HDMI devices. As long as not rpi-bcm2835-auto or rpi-bcm2835-hdmi is selected in dietpi-config audio options, this should be the case already, hence in your case it should work fine.

Background is that when ,noaudio is added while the firmware HDMI audio device is not disabled, it shows up again as “replacement” for the VC4 HDMI audio device, but it remains non-functional and worse: If anything (like Kodi, but also speaker-test etc) tries to play sound through the firmware HDMI device while KMS is enabled, HDMI output goes blank and cannot be recovered until a reboot or power cycle is done. I’ll implement it so that ,noaudio is added automatically when not rpi-bcm2835-auto or rpi-bcm2835-hdmi are selected as audio devices, so regardless whether KMS is enabled or not, both HDMI device variants are enabled/disabled always together.