Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DVBSky V2 card is not recognized with the "autoinstall-dvbsky-firmware" role #36

Open
obrain17 opened this issue May 1, 2024 · 3 comments

Comments

@obrain17
Copy link

obrain17 commented May 1, 2024

I am currently setting up a new yaVDR server with Ansible remotely.

Now I found that:

a) my DVBSky V2 card is not recognized with the autoinstall-dvbsky-firmware role

b) the firmware is installed with the autoinstall-firmware role - but this role also installs other firmwares that are not needed for the DVBSky

I already have created fixes for my own, and do not think it is appropriate to create a PR for all. But I still want to share the patches to be applied with git patch.

@seahawk1986 maybe you implement them as well in the repo, and let me know if you prefer me to create a PR.

a) is fixed with the following patch.

Additionally a task is implemented that would not download dvbsky-firmware.tar.gz if the file is already present in some file folder accessible by the role. (e.g. yavdr-ansible/files, which I also use for other files like channels.conf to be copied from). This is probably not necessary any more since the file has been available again with the new url.

diff --git a/roles/autoinstall-dvbsky-firmware/tasks/main.yml b/roles/autoinstall-dvbsky-firmware/tasks/main.yml  
index bec72d9..f6004e9 100644
--- a/roles/autoinstall-dvbsky-firmware/tasks/main.yml
+++ b/roles/autoinstall-dvbsky-firmware/tasks/main.yml
@@ -15,23 +15,39 @@
            - 'dvb-fe-ds300x.fw'
            - 'dvb-fe-ds3103.fw'
            - 'dvb-fe-rs6000.fw'
-      when:
-        - '"1ade:3038" in pci'
+      when: '"1ade:3038" in pci or "14f1:8852" in pci'
+
   when:
-    - not dvbsky_firmware_files
+    - dvbsky_firmware_files | length == 0
+
 
 - name: Download firmware for DVBSky cards and copy required files to /lib/firmware
   block:
+    - name: check if firmware exists in files folder
+      set_fact:
+        dvbsky_firmware_exists: "{{ 'files/dvbsky-firmware.tar.gz' is file }}"
+
+    - name: extract firmware found in files folder
+      unarchive:
+        src: files/dvbsky-firmware.tar.gz
+        dest: /tmp/
+#        remote_src: yes
+      when:
+        - dvbsky_firmware_exists 
+
     - name: download and extract firmware
       unarchive:
         src: https://web.archive.org/web/20220131124432if_/http://www.dvbsky.net/download/linux/dvbsky-firmware.tar.gz
         dest: /tmp/
         remote_src: yes
+      when:
+        - not dvbsky_firmware_exists 
 
     - name: copy firmware file
       copy:
          src: "/tmp/dvbsky-firmware/{{ item }}"
          dest: /lib/firmware/
+         remote_src: yes
          owner: root
          group: root
          mode: 0644
@@ -44,7 +60,7 @@
         state: absent
   when:
     - dvbsky_firmware_files is defined
-    - dvbsky_firmware_files | bool
+    - dvbsky_firmware_files | length > 0
   tags:
     - install
     - autodetect

With this all DVBSky firmware files get copied if either a card V2 ("14f1:8852" in pci') or V3 ("1ade:3038" in pci') has been found.

You can override this detection by placing a section like:

dvbsky_firmware_files:
  - 'dvb-demod-m88ds3103.fw'
  - 'dvb-demod-m88rs6000.fw'

in e.g. in a file host_vars/my_yavdr_host. Then only the listed files will be copied, regardless if a card was detected or not.

b) is fixed with the following patch.

For card detection union(pci) is changed to intersect(pci), so a firmware will only be installed if its id is in both *_ids list and pci or usb.

diff --git a/roles/autoinstall-firmware/tasks/main.yml b/roles/autoinstall-firmware/tasks/main.yml  
index d6a3aab..ad2fbd9 100644
--- a/roles/autoinstall-firmware/tasks/main.yml
+++ b/roles/autoinstall-firmware/tasks/main.yml
@@ -7,7 +7,7 @@
     url: https://github.com/LibreELEC/dvb-firmware/raw/master/firmware/dvb-demod-si2168-b40-01.fw
     checksum: sha256:d25c7deb9f69dca232ce25ab108da8ff5013d6d39088e0ec3475d97ded8af718
     dest: /lib/firmware/dvb-demod-si2168-b40-01.fw
-  when: '(hauppauge_wintv_hd_usb_ids | union(usb)) | length > 0 or (hauppauge_wintv_hd_pci_ids | union(pci)) | length > 0'
+  when: '(hauppauge_wintv_hd_usb_ids | intersect(usb)) | length > 0 or (hauppauge_wintv_hd_pci_ids | intersect(pci)) | length > 0'
   notify: ['reboot required']
 
 - name: Firmware dvb-demod-si2168-02.fw for Hauppauge WinTV quadHD
@@ -31,14 +31,15 @@
     url: https://github.com/LibreELEC/dvb-firmware/raw/master/firmware/dvb-demod-m88rs6000.fw
     checksum: sha256:9ac84583d83a4222909cb568236b7786e436f27dc050e60a31df404bb1be19dc
     dest: /lib/firmware/dvb-demod-m88rs6000.fw
-  when: '(m88rs6000_pci_ids | union(pci)) | length > 0'
+  when: '(m88rs6000_pci_ids | intersect(pci)) | length > 0'
+  notify: ['reboot required']
 
 - name: Firmware dvb-demod-m88ds3103.fw for DVBSky S952 V2
   get_url:
     url: https://github.com/LibreELEC/dvb-firmware/raw/master/firmware/dvb-demod-m88ds3103.fw
     checksum: sha256:4767ab80ceba4a66315cbec2a07ae1f7ebbd19c5758fd098b932e02c9108eff9
     dest: /lib/firmware/dvb-demod-m88ds3103.fw
-  when: '(m88ds3103_pci_ids | union(pci)) | length > 0'
+  when: '(m88ds3103_pci_ids | intersect(pci)) | length > 0'
   notify: ['reboot required']
 
 - name: Firmware ngenge_18.fw for ngene cards
@@ -70,5 +71,5 @@
     url: https://github.com/LibreELEC/dvb-firmware/raw/master/firmware/dvb-fe-ds3000.fw
     checksum: sha256:ad8c23bfb51642f48d31fe4f797182352bb13a4d4b7247b25aea18e208e0e882
     dest: /lib/firmware/dvb-fe-ds3000.fw
-  when: '(ds3000_pci_ids | union(pci)) | length > 0 or (ds3000_usb_ids | union(usb)) | length > 0'
+  when: '(ds3000_pci_ids | intersect(pci)) | length > 0 or (ds3000_usb_ids | intersect(usb)) | length > 0'
   notify: ['reboot required']

With both fixes only detected or explicitly listed (only for DVBSky) firmware will be installed. For those who still want to install all firmwares the role install-dvb-firmware should be used. It uses the repository https://github.com/LibreElec/dvb-firmware.git, which apparently contains the same files as provided by the other roles.

seahawk1986 pushed a commit that referenced this issue May 3, 2024
thanks to obrain17 for pointing this out in issue #36
@seahawk1986
Copy link
Member

Thank you very much, I chaged the logic error in the autoinstall-firmware role in 35ae7fa

How does "{{ 'files/dvbsky-firmware.tar.gz' is file }}" work in this task?

   block:
+    - name: check if firmware exists in files folder
+      set_fact:
+        dvbsky_firmware_exists: "{{ 'files/dvbsky-firmware.tar.gz' is file }}"

As far as I know one would have to use stat to lookup information about a file: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html and then use the isreg attribute of the result.

Maybe it would be better to download and cache the file on the controller and then just copy it to the target machine?

@obrain17
Copy link
Author

obrain17 commented May 4, 2024

The variable dvbsky_firmware_exists is a bool value set with set_fact depending if "{{ 'files/dvbsky-firmware.tar.gz' is file }}" is True or False.

I also tried using stat to check the existence

  - name: check if firmware exists in files folder
    stat:
      path: files/dvbsky-firmware.tar.gz
    register: dvbsky_firmware

  - name: extract firmware found in files folder
    unarchive:
      src: files/dvbsky-firmware.tar.gz
      dest: /tmp/
    when: dvbsky_firmware.stat.exists
   

But this did not work. I think because the stat action is done on the remote (target) server and the relative path files/ is not found there. Probably it could be done using local_action or similar ( Controlling where tasks run: delegation and local actions — Ansible Community Documentation ) but is file worked for me.

The file is only copied from local files/ folder to the target server when the unarchive is done. Therefore it is very important to have remote_src: no or comment this setting for default behaviour:

#        remote_src: yes

The archive dvbsky-firmware.tar.gz is dated 2015 or older same as the DVBSky V2 and V3 cards are. So owners of these cards probably already have it and can copy it to the files folder rather than downloading it any time the playbook runs.

@seahawk1986
Copy link
Member

Ah ok, I found it: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_test.html - I have to check if this works with older ansible versions like in focal, too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants