Skip to content

Instantly share code, notes, and snippets.

@larsr
Last active March 27, 2022 11:14
Show Gist options
  • Save larsr/b3912c0ac21031ceaecb to your computer and use it in GitHub Desktop.
Save larsr/b3912c0ac21031ceaecb to your computer and use it in GitHub Desktop.
Dvb dongle in linux

I have a cheap DVB USB dongle.

After plugging it in to linux lsusb shows me

Bus 001 Device 004: ID 15a4:1001 Afatech Technologies, Inc. AF9015/AF9035 DVB-T stick
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

so it is an Afatech dongle model AF9035.

NOTE: JUST FOR REFERENCE FOR OLDER KERNELS: If you have an old linux that thinks it is a HID (Human input device), a keyboard, you can stop the HID driver from taking control over the device by adding the line

options usbhid quirks=0x15a4:0x1001:0x0004

to the file /etc/modprobe.d/usbhid.conf . It tells the usbhid driver to ignore (0x0004) the device. END OF NOTE.

Plugging the dongle out and in again, gives these messages:

[  203.880184] usb 1-1: new high-speed USB device number 2 using ehci-pci
[  204.111902] usb 1-1: New USB device found, idVendor=15a4, idProduct=1001
[  204.111909] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  204.111914] usb 1-1: Product: AF9035A USB Device
[  204.111918] usb 1-1: Manufacturer: Afa Technologies Inc.
[  204.111922] usb 1-1: SerialNumber: AF0102020700001
[  204.405951] usb 1-1: dvb_usb_af9035: prechip_version=ff chip_version=f8 chip_type=f790
[  204.411415] usb 1-1: dvb_usb_v2: found a 'Afatech AF9035 reference design' in cold state
[  204.411886] usb 1-1: Direct firmware load failed with error -2
[  204.411893] usb 1-1: Falling back to user helper
[  204.412437] usb 1-1: dvb_usb_v2: Did not find the firmware file 'dvb-usb-af9035-02.fw'. Please see linux/Documentation/dvb/ for more details on firmware-problems. Status -2
[  204.414362] dvb_usb_af9035: probe of 1-1:1.0 failed with error -2
[  204.417311] usbcore: registered new interface driver dvb_usb_af9035
[  204.422780] hidraw: raw HID events driver (C) Jiri Kosina
[  204.439168] usbcore: registered new interface driver usbhid
[  204.439175] usbhid: USB HID core driver
[  204.444348] input: Afa Technologies Inc. AF9035A USB Device as /devices/pci0000:00/0000:00:0b.0/usb1/1-1/1-1:1.1/input/input6
[  204.444570] hid-generic 0003:15A4:1001.0001: input,hidraw0: USB HID v1.01 Keyboard [Afa Technologies Inc. AF9035A USB Device] on usb-0000:00:0b.0-1/input1

Apparently I'm missing the firmware. I found it throug linuxtv.org via this path https://linuxtv.org/wiki/index.php/DVB_USB https://linuxtv.org/wiki/index.php/DVB-T_USB_Devices https://linuxtv.org/wiki/index.php/Afatech_AF9035 https://linuxtv.org/wiki/index.php/EzCap_DVB_T_Stick

The last page says that the firmware can be downloaded from http://palosaari.fi/linux/v4l-dvb/firmware/af9035/

I downloaded http://palosaari.fi/linux/v4l-dvb/firmware/af9035/dvb-usb-af9035-02.fw_3735d499d945a6bb873a7f3ad5c701fa_12.13.15.0_6.20.15.0 and checked the checksum with md5sum and put the file in /lib/firmware/dvb-usb-af9035-02.fw

I removed and reinserted the dongle, and got the dmesg messages

[ 1307.983215] usb 1-1: new high-speed USB device number 4 using ehci-pci
[ 1308.250941] usb 1-1: New USB device found, idVendor=15a4, idProduct=1001
[ 1308.250946] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1308.250951] usb 1-1: Product: AF9035A USB Device
[ 1308.250954] usb 1-1: Manufacturer: Afa Technologies Inc.
[ 1308.250958] usb 1-1: SerialNumber: AF0102020700001
[ 1308.771378] usb 1-1: dvb_usb_af9035: prechip_version=ff chip_version=f8 chip_type=f790
[ 1308.777246] usb 1-1: dvb_usb_v2: found a 'Afatech AF9035 reference design' in cold state
[ 1308.777878] usb 1-1: dvb_usb_v2: downloading firmware from file 'dvb-usb-af9035-02.fw'
[ 1310.832451] usb 1-1: dvb_usb_af9035: firmware version=12.13.15.0
[ 1310.832470] usb 1-1: dvb_usb_v2: found a 'Afatech AF9035 reference design' in warm state
[ 1310.858434] usb 1-1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
[ 1310.858462] DVB: registering new adapter (Afatech AF9035 reference design)
[ 1310.873707] i2c i2c-0: af9033: firmware version: LINK=12.13.15.0 OFDM=6.20.15.0
[ 1310.885540] usb 1-1: DVB: registering adapter 0 frontend 0 (Afatech AF9033 (DVB-T))...
[ 1310.890466] i2c i2c-0: Fitipower FC0011 tuner attached
[ 1311.051154] usb 1-1: dvb_usb_v2: 'Afatech AF9035 reference design' successfully initialized and connected

I installed xine with

apt-get install xine-ui

xine needs a list of channels. I used scan to scan for channels.
It needs channel files of version v3, so I installed the dvb-apps packages plus some other dvb packet and did

git clone git://linuxtv.org/dtv-scan-tables.git
cd dtv-scan-tables
make clean
make install_v3

and then put the channels file in the right place. As root do

mkdir -p ~/.config/xine-lib
sudo -s
# scan /usr/local/share/dvbv3/dvb-t/se-Stockholm_Nacka  \
    > ~/.config/xine-lib/channels.conf

When running as sudo, xine gets confused and takes some config files from my home-dir and some from /root.

Edit /root/.xine/config and set the media.capture.save_dir for instance to /root.

Then I launched xine

sudo xine -H -V none -A none dvb://<channelnr>#save:tv

which saves the channel to the file /root/tv. It can be played back with for instance VLC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment