Using TBS5530 with Kaffeine and mumudvb

April 20, 2023   

This is my longest blog post so far :)

TL;DR:

I wanted to capture Full TS of a DVBS/S2 transponder.

This blog post describes my adventures with TBS5530 & Kaffeine & MumuDVB .

Result: SUCCESS!

Purpose

To be able to replay some live TS data from satellites, we need to be able to capture it.

There are various hardware to achieve this, these are commonly referred as “digital TV cards”

History

There were many HW manufacturers all around the world that produces such devices.

Some examples that still manufacture are here:

https://www.hauppauge.com/pages/products/prods.htm

https://www.tbsdtv.com/products/tbs-tv-turner-usb.html

https://www.tbsdtv.com/products/tbs-tv-tuner-pcie.html

https://www.geniatech.com/products/dvb-s2-tv-tuner/

In the past, these devices were a lot more popular. There were many manufacturers. These days, I can’t find more, since DVB doesn’t seem to be popular, ( people doesn’t watch TV WTF!! ) Some past manufacturers were:

www.avermedia.com

www.tevii.com

www.technisat.com

www.dvbsky.net

Here is a good list of vendors that used to manufacture these devices:

https://www.linuxtv.org/wiki/index.php/List_of_device_vendors

The TBS5530

So I got one USB device that support DVB-S/T/C from TBS:

Ubuntu 22.04 and TBS Drivers & Firmware

OK, the sad situation is, these devices are not Plug-and-play. We have to install their kernel drivers & firmware manually under linux.

As of writing this blog, corresponding kernel driver was not ready for 6.3, but it was building fine with the commands described here:

https://github.com/tbsdtv/linux_media/wiki

Simply:

mkdir TBSTDV && cd TBSDTV
git clone https://github.com/tbsdtv/media_build.git
git clone --depth=1 https://github.com/tbsdtv/linux_media.git -b latest ./media
# Skip GCC installation & selection as I already have GCC newer than GCC-8
cd media_build
make dir DIR=../media
make allyesconfig
sed -i -r 's/(^CONFIG.*_RC.*=)./\1n/g' v4l/.config
sed -i -r 's/(^CONFIG.*_IR.*=)./\1n/g' v4l/.config
make -j4
sudo make install

When completed, reboot your PC.

Extra details: Cleaning & Rebuilding source tree

What does that document doesn’t describe is cleaning the build tree.

I managed to achieve this via:

make distclean

and then rebuild as decribed above.

Extra details: Fix Kernel Crash messages

When I performed above steps, after reboot, when I insert TBS5530 to my USB ports, I got following error in dmesg:

[   80.376723] usb 2-2: new high-speed USB device number 3 using xhci_hcd
[   80.603525] usb 2-2: New USB device found, idVendor=734c, idProduct=5530, bcdDevice= 0.01
[   80.603532] usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[   80.630076] WARNING: You are using an experimental version of the media stack.
               	As the driver is backported to an older kernel, it doesn't offer
               	enough quality for its usage in production.
               	Use it with care.
               Latest git patches (needed if you report a bug to linux-media@vger.kernel.org):
               	d94513e97be429847a8bf6ba6bcf74492d3d24d9 media: dvb-frontends/m88rs6060: Fix modcode table.
[   80.631089] dvb-usb: found a 'TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0' in cold state, will try to load a firmware
[   80.631196] dvb-usb: downloading firmware from file 'dvb-usb-id5530.fw'
[   80.631198] tbs5530: start downloading tbs5530 firmware
[   81.025945] usb 2-2: USB disconnect, device number 3
[   81.026742] tbs5530: could not restart the USB controller CPU.
[   81.132768] usbcore: registered new interface driver tbs5530
[   82.844690] usb 2-2: new high-speed USB device number 4 using xhci_hcd
[   83.078297] usb 2-2: New USB device found, idVendor=734c, idProduct=5530, bcdDevice= 0.01
[   83.078306] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   83.078309] usb 2-2: Product: TBS 5530
[   83.078312] usb 2-2: Manufacturer: TBS-Tech
[   83.088357] dvb-usb: found a 'TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0' in cold state, will try to load a firmware
[   83.088362] dvb-usb: downloading firmware from file 'dvb-usb-id5530.fw'
[   83.088364] tbs5530: start downloading tbs5530 firmware
[   83.588680] dvb-usb: found a 'TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0' in warm state.
[   83.588807] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[   83.588809] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[   83.597242] dvbdev: DVB: registering new adapter (TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0)
[   85.132109] dvb-usb: MAC address: 00:22:ab:c0:78:89
[   85.158107] i2c i2c-7: Detect CXD2878/CXD6802(SiP) chip.
[   85.158113] usb 2-2: DVB: registering adapter 0 frontend 0 (TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0 DVB-T/T2/C/C2,ISDB-T/C,ATSC1.0)...
[   85.388087] i2c i2c-7: found a 'Montage m88rs6060' in cold state
[   85.396394] i2c i2c-7: downloading firmware from file 'dvb-demod-m88rs6060.fw'
[   85.399092] ================================================================================
[   85.399098] UBSAN: array-index-out-of-bounds in /home/stulluk/TBSDTV/media_build/v4l/tbs5530.c:93:8
[   85.399102] index 20 is out of range for type 'u8 [20]'
[   85.399106] CPU: 6 PID: 54 Comm: kworker/6:0 Tainted: G           OE      6.2.10-060210-generic #202304061139
[   85.399110] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./B550M-HDV, BIOS P1.90 08/09/2021
[   85.399113] Workqueue: usb_hub_wq hub_event
[   85.399121] Call Trace:
[   85.399123]  <TASK>
[   85.399126]  dump_stack_lvl+0x48/0x70
[   85.399136]  dump_stack+0x10/0x20
[   85.399141]  __ubsan_handle_out_of_bounds+0xc6/0x110
[   85.399148]  tbs5530_i2c_transfer+0x1eb/0x210 [dvb_usb_tbs5530]
[   85.399158]  __i2c_transfer.part.0+0xcb/0x290
[   85.399164]  __i2c_transfer+0x23/0x90
[   85.399168]  i2c_transfer+0x87/0x110
[   85.399173]  m88rs6060_ready.isra.0+0x4d2/0x880 [m88rs6060]
[   85.399185]  m88rs6060_probe+0x2e1/0x570 [m88rs6060]
[   85.399194]  i2c_device_probe+0x2d8/0x370
[   85.399198]  ? __pfx_m88rs6060_probe+0x10/0x10 [m88rs6060]
[   85.399207]  really_probe+0x1e3/0x440
[   85.399211]  __driver_probe_device+0x8c/0x1a0
[   85.399214]  driver_probe_device+0x24/0xd0
[   85.399217]  __device_attach_driver+0xcd/0x170
[   85.399220]  ? __pfx___device_attach_driver+0x10/0x10
[   85.399223]  bus_for_each_drv+0x90/0xe0
[   85.399228]  __device_attach+0xb6/0x200
[   85.399231]  device_initial_probe+0x13/0x20
[   85.399234]  bus_probe_device+0x9b/0xb0
[   85.399239]  device_add+0x436/0x730
[   85.399243]  device_register+0x1a/0x30
[   85.399246]  i2c_new_client_device+0x1a6/0x330
[   85.399251]  ? __pfx_tbs5930_frontend_m88rs6060_attach+0x10/0x10 [dvb_usb_tbs5530]
[   85.399259]  tbs5930_frontend_m88rs6060_attach+0xfb/0x2d0 [dvb_usb_tbs5530]
[   85.399269]  dvb_usb_adapter_frontend_init+0x46/0x4c0 [dvb_usb]
[   85.399278]  dvb_usb_device_init+0x8d2/0xcd0 [dvb_usb]
[   85.399288]  tbs5530_probe+0x25/0x40 [dvb_usb_tbs5530]
[   85.399295]  usb_probe_interface+0xee/0x300
[   85.399300]  really_probe+0x1e3/0x440
[   85.399303]  __driver_probe_device+0x8c/0x1a0
[   85.399306]  driver_probe_device+0x24/0xd0
[   85.399309]  __device_attach_driver+0xcd/0x170
[   85.399311]  ? __pfx___device_attach_driver+0x10/0x10
[   85.399314]  bus_for_each_drv+0x90/0xe0
[   85.399318]  __device_attach+0xb6/0x200
[   85.399321]  device_initial_probe+0x13/0x20
[   85.399324]  bus_probe_device+0x9b/0xb0
[   85.399329]  device_add+0x436/0x730
[   85.399333]  usb_set_configuration+0x5ec/0xa70
[   85.399337]  usb_generic_driver_probe+0x69/0xa0
[   85.399343]  usb_probe_device+0x3c/0x130
[   85.399347]  really_probe+0x1e3/0x440
[   85.399349]  __driver_probe_device+0x8c/0x1a0
[   85.399352]  driver_probe_device+0x24/0xd0
[   85.399354]  __device_attach_driver+0xcd/0x170
[   85.399357]  ? __pfx___device_attach_driver+0x10/0x10
[   85.399359]  bus_for_each_drv+0x90/0xe0
[   85.399364]  __device_attach+0xb6/0x200
[   85.399367]  device_initial_probe+0x13/0x20
[   85.399369]  bus_probe_device+0x9b/0xb0
[   85.399374]  device_add+0x436/0x730
[   85.399378]  usb_new_device+0x42e/0x520
[   85.399381]  hub_port_connect+0x45b/0xc20
[   85.399385]  hub_port_connect_change+0xb8/0x380
[   85.399388]  ? hub_ext_port_status+0xdb/0x140
[   85.399393]  port_event+0x652/0x810
[   85.399397]  hub_event+0x155/0x450
[   85.399401]  process_one_work+0x225/0x430
[   85.399406]  worker_thread+0x50/0x3e0
[   85.399409]  ? __pfx_worker_thread+0x10/0x10
[   85.399413]  kthread+0xe9/0x110
[   85.399418]  ? __pfx_kthread+0x10/0x10
[   85.399422]  ret_from_fork+0x2c/0x50
[   85.399428]  </TASK>
[   85.399429] ================================================================================
[   87.740881] i2c i2c-7: found a 'Montage m88rs6060' in warm state
[   87.740886] i2c i2c-7: firmware version:30
[   87.900639] usb 2-2: DVB: registering adapter 0 frontend 1 (TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC DVB-S/S2/S2X)...
[   87.906785] dvb-usb: TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0 successfully initialized and connected

I contacted with TBS (support) but they really did not treated the situation well IMHO:

  • They don’t have good (careful) english
  • They did not respond to my question regarding DKMS
  • Their source code for linux kernel driver seems to be written in Windows
  • Their documentation is lacking

Anyway, hopefully this time the bug was easy to fix and I did as follows:

stulluk ~/TBSDTV/media (latest) $  git diff
diff --git a/drivers/media/usb/dvb-usb/tbs5530.c b/drivers/media/usb/dvb-usb/tbs5530.c
index 27bc03783ce3..205989d78eb6 100644
--- a/drivers/media/usb/dvb-usb/tbs5530.c
+++ b/drivers/media/usb/dvb-usb/tbs5530.c
@@ -63,8 +63,8 @@ static int tbs5530_i2c_transfer(struct i2c_adapter *adap,
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
        int i = 0;
-       u8 buf6[20];
-       u8 inbuf[20];
+       u8 buf6[40];^M
+       u8 inbuf[40];^M
 
        if (!d)
                return -ENODEV;
stulluk ~/TBSDTV/media (latest) $

Please note:

  • Do you see that “^M” characters in my modification ? That happens when you write a text file with CRLF ( Windows ) and try to save it in Linux via your-favorite-text-editor-here. Thats why I am suspecting that they are using Windows to write linux drivers in the first place.
  • I made the modificationin the “media” directory, not “media_modules” . Because I found that, during make, the sources from media directory is copied to media_modules and compiled there.

Anyway, after this change, here is how my TBS5530 initialises:

[25320.049835] usb 1-2: new high-speed USB device number 26 using xhci_hcd
[25320.276450] usb 1-2: New USB device found, idVendor=734c, idProduct=5530, bcdDevice= 0.01
[25320.276458] usb 1-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[25320.278518] dvb-usb: found a 'TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0' in cold state, will try to load a firmware
[25320.278529] dvb-usb: downloading firmware from file 'dvb-usb-id5530.fw'
[25320.278533] tbs5530: start downloading tbs5530 firmware
[25320.674666] tbs5530: could not restart the USB controller CPU.
[25320.781972] usb 1-2: USB disconnect, device number 26
[25322.489806] usb 1-2: new high-speed USB device number 27 using xhci_hcd
[25322.723217] usb 1-2: New USB device found, idVendor=734c, idProduct=5530, bcdDevice= 0.01
[25322.723225] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[25322.723228] usb 1-2: Product: TBS 5530
[25322.723230] usb 1-2: Manufacturer: TBS-Tech
[25322.733295] dvb-usb: found a 'TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0' in cold state, will try to load a firmware
[25322.733307] dvb-usb: downloading firmware from file 'dvb-usb-id5530.fw'
[25322.733311] tbs5530: start downloading tbs5530 firmware
[25323.233798] dvb-usb: found a 'TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0' in warm state.
[25323.233966] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[25323.233970] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[25323.242172] dvbdev: DVB: registering new adapter (TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0)
[25324.777032] dvb-usb: MAC address: 00:22:ab:c0:78:89
[25324.792036] i2c i2c-3: Detect CXD2878/CXD6802(SiP) chip.
[25324.792043] usb 1-2: DVB: registering adapter 0 frontend 0 (TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0 DVB-T/T2/C/C2,ISDB-T/C,ATSC1.0)...
[25325.029011] i2c i2c-3: found a 'Montage m88rs6060' in cold state
[25325.029064] i2c i2c-3: downloading firmware from file 'dvb-demod-m88rs6060.fw'
[25327.373804] i2c i2c-3: found a 'Montage m88rs6060' in warm state
[25327.373810] i2c i2c-3: firmware version:30
[25327.521737] usb 1-2: DVB: registering adapter 0 frontend 1 (TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC DVB-S/S2/S2X)...
[25327.527707] dvb-usb: TurboSight TBS 5530 DVB-T2/T/C/S/S2/S2x,ISDB-T,ATSC1.0 successfully initialized and connected.

The Kaffeine

The simplest, plug-and-play, easiest solution to watch DVB TV under Linux is definitely this app: Kaffeine:

Kaffeine-Setup for TBS5530:

As you may see from my setting, I am using a diseqc multiswitch with two satellites:

Turksat is on port-1 and Hotbird is on port-2.

Channel Scanning with Kaffeine:

Watching TV:

However, I couldn’t find a way to capture whole TS file from a Transponder via Kaffeine.

So I discovered MumuDVB.

MumuDVB

Firstly, see this ticket: https://github.com/braice/MuMuDVB/issues/310

After long trials and errors and great support from MumuDVB Authors, I managed to capture full TS file from a Transponder as follows:

mumudvb -dt -c TURKSAT-CONF-FILES/42e-11054v30000.conf --dumpfile out3.ts

Here:

  • -d : don’t daemonise
  • -t : show traffic
  • -c : config file to use
  • –dumpfile : full TS capture

And here is my sample config files for Turksat & Hotbird:

https://github.com/stulluk/mumudvb-conf-turkey

Please also notice my helper scripts there: They are used for creating mumudvb conf files automatically or manually.

satcapture.sh even can capture !!

Created output TS file ( out3.ts here ) can be used in many apps under linux:

  • VLC: You can watch FTA channels in the TS
  • TSReader with Wine: You can analyze streams easily (Sadly couldn’t find a way to run VLC.exe-Windows with TSReader under Wine)
  • DVBInspector : Yet another java based analysis app

TSDuck

I love learning new things. tsduck seems to me extremely advanced and well documented solution under linux for TS analysis.

I also managed to capture full stream via tsduck:

tsp --debug  -I dvb -d /dev/dvb/adapter0:1:0:0 --delivery-system DVB-S2 --satellite-number 0 --lnb Extended --frequency 11054000000 --polarity vertical --symbol-rate 30000000 > outfile.ts

Final words

I managed to achieve what I needed : I can capture whole TS from a transponder under linux now.

However, I wish

  • it would be possible to do this with Kaffeine with a visual interface
  • there would be a beautiful app like TSReader & ProgDVB natively under linux


comments powered by Disqus