DVB issue since LE switched to kernel 4.9.x

  • mchehab I managed to get LibreELEC 8.2.2 with upstream 4.14.13 booting on RPi3. The process is a bit tricky/hacky and Kodi won't start - not sure if LibreELEC's Kodi can work at all on upstream kernel, could well be that the graphics layer relies on some downstream kernel changes. popcornmix should be able to tell more.

    The official way to use a different kernel in LE is to fully rebuild it from source, but this shortcut could be enough for a few quick tests:

    I've done this by starting with a plain LE 8.2.2 installation on sdcard - it'd probably be best if you follow the same route, then you can enable ssh and install tvheadend from Kodi. Even if kodi won't work with upstream kernel tvheadend should run and you can test it over the net.

    LE uses an initrd to mount the read-only rootfs (that's the SYSTEM) file on the FAT partition. It's compresses with LZ4 so you'll also need to enable LZ4 squashfs support in the kernel.

    I used this (hacky) script to extract the initramfs from the kernel image (KERNEL file on FAT partition):

    I started that with "./extract-initramfs KERNEL initrd-8.2.2" and copied the initrd-8.2.2 file to the root of the FAT partition. Fortunately there are no kernel modules in the initramfs, so we don't need to change that.

    I then compiled a 32bit (ARCH="arm") upstream kernel using multi_v7_defconfig. I patched the the rpi3 DT so I could use PL011 as serial console and manually enabled CONFIG_SQUASHFS_LZ4. Then I copied zImage and the bcm283*.dtb files to a "upstream" directory on the FAT partition.

    To get the upstream kernel booting I used these additional settings in config.txt - the initramfs entry brings in the previously extracted initrd

    Code
    [PI3]
    kernel=upstream/zImage
    device_tree=upstream/bcm2837-rpi-3-b.dtb
    avoid_warnings=2
    initramfs initrd-8.2.2

    and this cmdline.txt:

    Code
    boot=/dev/mmcblk0p1 disk=/dev/mmcblk0p2 ssh root=/dev/ram0 console=ttyAMA0,115200 earlycon=pl011,mmio32,0x3f201000

    This is enough to get LE booting, but the initramfs will complain loudly because it doesn't find matching kernel modules in the rootfs (SYSTEM file) - after a minute it will continue booting up, but of course without modules it's a bit meh.

    So I simply installed the modules to a temp directory on my PC, unsquashed the SYSTEM in a fakeroot, copied the modules into the unsquashed rootfs and then ran mksquashfs

    Code
    cd ~/upstream-kernel
    mkdir /tmp/modules
    INSTALL_MOD_PATH=/tmp/modules make modules_install
    cd ~/le-test
    fakeroot
    unsquashfs SYSTEM
    cp -r /tmp/modules/lib/modules/4.14.13-dirty squashfs-root/usr/lib/modules/
    mksquashfs squashfs-root SYSTEM-4.14 -comp lz4

    Then I copied that SYSTEM-4.14 file to the root of the FAT partition, naming it SYSTEM. LE then booted up fine and could load at least some modules.

    Hope I didn't miss an important step, if you have problems or questions just ping me.

    so long,

    Hias

  • @HiassofT: Thanks for the detailed explanation! it worked as a charm.
    The only detail is that here, I installed it via NOOBS, dual-booted with raspbian and LibreELEC. The kernel image file is named kernel.img. I'm also using the standard serial interface (with is ttyS1 on Kernel 4.14), instead of PL011.

    It is funny that Kodi didn't work. I don't think it is due to a DRM module, as 4.14 comes with VC4 driver (with is enabled here and works on raspbian here). Maybe it requires some other Kernel feature that it is not enabled (like some namespace feature). Anyway, this shouldn't matter for tvheadend to work. The only thing is that, without Kodi, it won't be possible to test recording while watching a movie on RPi.

    As a reference, this is my .config file, with contains several media drivers enabled:

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

  • Yeah, the issue with Kodi is due to some VC4 issue:

    * failed to open vchiq instance

    Segmentation fault (core dumped)

    Crash report available at /storage/.kodi/temp/kodi_crashlog_20180112123144.log

  • Kodi / LibreELEC on RPi doesn't use the vc4 drm driver, AFAIK it uses the (downstream) bcm2708 framebuffer driver and the (also downstream) video core shared memory driver (vcsm) to interface to the GPU.

    Could well be that other downstream drivers are involved, but I leave this to popcornmix to answer, he's the expert in this area, my knowledge about RPi graphics stuff is quite limited.

    so long,

    Hias

  • Part of the fix for upstream Kernel is to add vchiq DT data:

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

    That makes it to create /dev/vchiq devnode.

    With that, kodi doesn't crash anymore, but those messages are generated:

    Code
    [    6.846340] vchiq: module is from the staging directory, the quality is unknown, you have been warned.
    [    6.851573] vchiq: vchiq_init_state: slot_zero = ea880000, is_master = 0
    [    7.027647] [<bf00c794>] vchiq_doorbell_irq [vchiq]
    [    8.022814] Modules linked in: cfg80211(+) vc4(+) snd_soc_core ac97_bus snd_pcm_dmaengine snd_pcm snd_timer snd crc32_arm_ce brcmutil soundcore vchiq(C)
    [  106.220212] vchiq: vchiq: connect: could not lock mutex for state 0: -4
    [  149.432097] vchiq: vchiq: could not connect: 1

    Maybe vchiq DT data changed since Kernel 4.11 (the last time I used my RPi3).

  • Hey all,

    I have x86_64 with 8.2.0 (kernel 4.11.12) and have issues with dvb. I have a DVBSky T9580 V3.

    Could somebody provide me a 8.2.2 release with linus torvalds fix?

    Best regards,

    Marcel

  • Hi jahutchi

    Just want to thank you for taking the time for finding this commit. Watching TV is a pleasure now without those artifacts.

    We owe ya one bud 👍

  • Please see my post on page 13

    Here are the links again to some builds i made with the problematic commit reverted...

    LibreELEC-Generic.x86_64-8.2.2-dvbfriendly-nomb.tar

    LibreELEC-Generic.x86_64-8.2.2-dvbfriendly-withmb.tar

    Thanks, but stupid Question: How can I update my system with these files? Usually I place these images (img.gz) in the update folder of libreelec.

    Can I create an image of your files?

    Best regards,

    Marcel

  • Just so there is no confusion - LE 8.2.3 will include the revert of the ksoftirqd commit which is just a short-term/interim solution (but one we know works, particularly with the older 4.11.y kernel in 8.2.x). Hopefully a better long term fix will be added upstream, maybe along the lines of the suggestion from Linus, in time for LE 9.0.

  • Hey guys,

    I applied the 8.2.3, but I still have some artifacts when watching some TV channels. But I dont see continuity errors in the tvheadend webinterface.

    I have a PCIe DVBSky T9580 V3.

  • Hey guys,

    I applied the 8.2.3, but I still have some artifacts when watching some TV channels. But I dont see continuity errors in the tvheadend webinterface.

    I have a PCIe DVBSky T9580 V3.

    Hi all,

    Thanks for the hard work resolving these DVB issues. I'e updated to 8.2.3 and thought I'd mention that I'm also still getting artifacts on mpeg DVB streams. Usually every 5 seconds or so when there's fast motion eg. F1 racing. Turning de-interlace off doesn't make a difference.

    This happens on both my USB and PCI tuners. I'm running generic build 8.2.3 with this (old) hardware :

    Intel core2duo T9500

    Nvidia GT218

    DVBSky T982

    Sundtek MediaTV Pro

    Given that the fix for the issue jahutchi resolved is now released, is there also some other unidentified problem that came with LE 8 ?

    Cheers,

    Neil

  • Record some program and play it at your PC (VLC ...) and have a look if the same problems appear there. Is quite possible that your gpu (driver) the the problem.

    Hi CvH,

    Thanks for quick reply and thanks for your help (again lol).

    OK I can confirm that the recorded stream plays fine on PC. The recording plays back with the same artifacts on LE.

    Any suggestions on how I could possibly resolve ?

  • I can confirm that the recorded stream plays fine on PC. The recording plays back with the same artifacts on LE.

    Any suggestions on how I could possibly resolve ?

    Have you enabled hardware acceleration (VDPAU in your case) in settings>system>display?

    My graphics card is also NVidia ION-based, and my machine cannot cope unless i turn on the h/w acceleration.

    Also, is your cpu overloaded when playing back the stream? As this would be another indicator that the stream is not being decoded by your gpu.