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

add fw for dvb tuner #1157

Open
luci-11 opened this issue Jan 5, 2021 · 40 comments
Open

add fw for dvb tuner #1157

luci-11 opened this issue Jan 5, 2021 · 40 comments
Labels

Comments

@luci-11
Copy link

luci-11 commented Jan 5, 2021

I'm trying to modify an existing addon for tvheadend in order to make it compatible with an usb tuner I have at home (MyGica T230C v2) .
The tuner is recognized from tvheadend cofiguration panel but cannot get any channles.
Dmesg confirms USB is recognized properly but I have: Direct firmware load for dvb-demod-si2168-d60-01.fw failed with error -2
Same for dvb-tuner-si2141-a10-01.fw

Tried tvheadend on raspbian adding these two files manually as written here https://www.linuxtv.org/wiki/index.php/Geniatech_T230C
and everything works.

Could you please add them to /lib/firmware for hassos build?
files are here: t230C.v2-fw
Thanks a lot.

@agners agners added board/raspberrypi Raspberry Pi Boards enhancement labels Jan 5, 2021
@agners
Copy link
Member

agners commented Jan 11, 2021

It seems that this firmware is not available from the linux-firmware git tree. This would mean I need to create a separate buildroot package and all that, which is a bit much. Also, I am not sure about the license. Usually there is a reason if something doesn't find its way into linux-firmware.

@admin-lm
Copy link

Could you add a mount point to /usr/lib/firmware which is writable for the users, instead of creating a seperate buildroot package, to allow adding fw files by the user itself?

@agners
Copy link
Member

agners commented Jan 11, 2021

@admin-lm the problem is we already ship firmware with the OS today. So we would have to do it in such a way that we can still ship firmware with the OS, e.g. an overlay or something. The question then is how do we make it accessible exactly, e.g. via container from supervisor?

@luci-11
Copy link
Author

luci-11 commented Jan 11, 2021

It seems that this firmware is not available from the linux-firmware git tree. This would mean I need to create a separate buildroot package and all that, which is a bit much. Also, I am not sure about the license. Usually there is a reason if something doesn't find its way into linux-firmware.

MMM ..Strange story.
For licence, I think they were created using CrazyCat's media_build tool that is mentioned in the Linux page liked above. He is the owner also for the added support in linux kernel Si2168-D60 support . Commits are also there linux-next .
In fact adding just the two fw does the job in Raspbian OS.. Strange

But I completely understand your point.

That's why being able to add them by ourselves could be the best way for future (less work for you, If we create mess, it's our problem :) ) But I really don't know how to help tecnically.

@admin-lm
Copy link

I think an overlay for /lib/firmware helps, devices could be made accessible via portainer; /dev/dvb:/dev/dvb

@stale
Copy link

stale bot commented May 12, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 12, 2021
@agners agners removed the wontfix label Oct 6, 2021
@Billiadis
Copy link

Billiadis commented Sep 27, 2022

hi, how exactly did you solve this problem?
how to create an overlay for /lib/firmware?
by adding

devices:
- /dev/dvb:/dev/dvb

I get the TV tuner in the container but unfortunately I don't understand how to add the firmware 🥲

@7wells
Copy link

7wells commented Oct 3, 2022

Hi! I also would like to place 3 necessary files under /lib/firmware (for an AverMedia TD310 DVB-C/T/T2 USB stick). It works like a charm on plain Tvheadend on Raspberry Pi OS, but how on HAOS?

@weidi
Copy link

weidi commented Nov 14, 2022

Would it help to have CONFIG_DVB_USB=m added to device-support.config ?
This has been done but reverted previously #609

@HahnBenjamin
Copy link

I just found a viable solution to the custom firmware issue for my USB DVB Tuner I was trying to attach to my HAOS setup.

There are actually multiple firmware search paths the kernel uses to find firmware files to upload to the device.

There is even a option to specify a custom search path, which is what I utilized.
The path can be specified using a kernel boot parameter. I my case I placed the firmware files in the /share folder exposed to the supervisor, specifically /share/firmware.
Within the underlying operating system the path translates to /mnt/data/supervisor/share/firmware. This path is what is need for the kernel parameter. firmware_class.path=/mnt/data/supervisor/share/firmware/ must be added to cmdline.txt on the PI SD card.
On the next boot the HAOS will happily load the firmware from the specified location.

@agners I am not sure if the usecase of user specific device firmware is relevant enough to establish a more streamlined solution. The built-in the firmware search paths could be utilized for this. If I understand correctly e.g ‘/lib/firmware/updates/’ could be symlinked\bind mounted to some writeable location within HAOS. If this location would then be exposed to the supervisor there would be a working solution. This should also not interfere with the firmware currently shipped with HAOS.

@thatsthat
Copy link

I just found a viable solution to the custom firmware issue for my USB DVB Tuner I was trying to attach to my HAOS setup.

There are actually multiple firmware search paths the kernel uses to find firmware files to upload to the device.

There is even a option to specify a custom search path, which is what I utilized. The path can be specified using a kernel boot parameter. I my case I placed the firmware files in the /share folder exposed to the supervisor, specifically /share/firmware. Within the underlying operating system the path translates to /mnt/data/supervisor/share/firmware. This path is what is need for the kernel parameter. firmware_class.path=/mnt/data/supervisor/share/firmware/ must be added to cmdline.txt on the PI SD card. On the next boot the HAOS will happily load the firmware from the specified location.

@agners I am not sure if the usecase of user specific device firmware is relevant enough to establish a more streamlined solution. The built-in the firmware search paths could be utilized for this. If I understand correctly e.g ‘/lib/firmware/updates/’ could be symlinked\bind mounted to some writeable location within HAOS. If this location would then be exposed to the supervisor there would be a working solution. This should also not interfere with the firmware currently shipped with HAOS.

Your solution worked, but only after manually reloading the dvb-usb module after each reboot, otherwise the problem persists. Any idea on how to automate this? HAOS doesn't allow automatically running scripts with root permissions AFAIK

@7wells
Copy link

7wells commented Mar 26, 2023

Is there any progress about this issue?

I also would like to add some firmware files for TVHeadend on my Home Assistant:

# How to download AverMedia TD310 (DVB-C/T/T2 USB stick) firmware files (used on Raspberry Pi 4 Model B)
#
sudo wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-usb-it9303-01.fw -O /lib/firmware/dvb-usb-it9303-01.fw
sudo wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-demod-si2168-02.fw -O /lib/firmware/dvb-demod-si2168-02.fw
sudo wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-demod-si2168-b40-01.fw -O /lib/firmware/dvb-demod-si2168-b40-01.fw

I saved the files under /lib/firmware/ as indicated above, but after restarting the system, the /lib/firmware/ folder is empty.

It would be great to make this possible. Thank you!

PS1:
Rebooting the system seems to delete these files, whereas restarting Home Assistant keeps them.

PS2: Does this help?
#2222 (comment)
A permanent solution to be able to have drivers stored in /lib/firmware would be great.

@thatsthat
Copy link

thatsthat commented Mar 27, 2023

Is there any progress about this issue?

I also would like to add some firmware files for TVHeadend on my Home Assistant:

# How to download AverMedia TD310 (DVB-C/T/T2 USB stick) firmware files (used on Raspberry Pi 4 Model B)
#
sudo wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-usb-it9303-01.fw -O /lib/firmware/dvb-usb-it9303-01.fw
sudo wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-demod-si2168-02.fw -O /lib/firmware/dvb-demod-si2168-02.fw
sudo wget https://github.com/OpenELEC/dvb-firmware/raw/master/firmware/dvb-demod-si2168-b40-01.fw -O /lib/firmware/dvb-demod-si2168-b40-01.fw

I saved the files under /lib/firmware/ as indicated above, but after restarting the system, the /lib/firmware/ folder is empty.

It would be great to make this possible. Thank you!

PS1: Rebooting the system seems to delete these files, whereas restarting Home Assistant keeps them.

PS2: Does this help? #2222 (comment) A permanent solution to be able to have drivers stored in /lib/firmware would be great.

There is already a solution (I can confirm it works):

I just found a viable solution to the custom firmware issue for my USB DVB Tuner I was trying to attach to my HAOS setup.

There are actually multiple firmware search paths the kernel uses to find firmware files to upload to the device.

There is even a option to specify a custom search path, which is what I utilized. The path can be specified using a kernel boot parameter. I my case I placed the firmware files in the /share folder exposed to the supervisor, specifically /share/firmware. Within the underlying operating system the path translates to /mnt/data/supervisor/share/firmware. This path is what is need for the kernel parameter. firmware_class.path=/mnt/data/supervisor/share/firmware/ must be added to cmdline.txt on the PI SD card. On the next boot the HAOS will happily load the firmware from the specified location.

@agners I am not sure if the usecase of user specific device firmware is relevant enough to establish a more streamlined solution. The built-in the firmware search paths could be utilized for this. If I understand correctly e.g ‘/lib/firmware/updates/’ could be symlinked\bind mounted to some writeable location within HAOS. If this location would then be exposed to the supervisor there would be a working solution. This should also not interfere with the firmware currently shipped with HAOS.

@agners
Copy link
Member

agners commented Mar 27, 2023

@agners I am not sure if the usecase of user specific device firmware is relevant enough to establish a more streamlined solution. The built-in the firmware search paths could be utilized for this. If I understand correctly e.g ‘/lib/firmware/updates/’ could be symlinked\bind mounted to some writeable location within HAOS. If this location would then be exposed to the supervisor there would be a working solution. This should also not interfere with the firmware currently shipped with HAOS.

Yes, that is what #2225 proposes, and it got merged now for OS 10. The directory /mnt/data/supervisor/firmware is not accessible by default from within Home Assistant Core/Add-ons. The plan is to have APIs in Supervisor which allows to manage firmwares.

@thatsthat
Copy link

thatsthat commented Mar 27, 2023 via email

@agners
Copy link
Member

agners commented Mar 27, 2023

But the kernel can be instructed to get the firmware from any folder accessible to addons (e.g. under /mnt/data/supervisor/share)

Yes. With the chosen solution this option is still available to you. 🤷‍♂️

@7wells
Copy link

7wells commented Mar 30, 2023

Please forgive me, guys, but I am not such an expert and still unsure what this now means for me. After I updated to the latest HA version, what do I have to do to permanently store drivers/firmware files, i.e. where should I store them? Thanks for your patience and advice! :)

@thatsthat
Copy link

thatsthat commented Mar 31, 2023 via email

@7wells
Copy link

7wells commented Apr 1, 2023

I.e., this is all that's needed?

firmware_class.path=/mnt/data/supervisor/share/firmware/ must be added to cmdline.txt on the PI SD card.
On the next boot the HAOS will happily load the firmware from the specified location.

😎

@thatsthat
Copy link

thatsthat commented Apr 1, 2023 via email

@7wells
Copy link

7wells commented Apr 1, 2023

I just flashed the HAOS image for the RPi 4 fresh to a nano SD card and opened cmdline.txt in an editor that shows just this one line:
dwc_otg.lpm_enable=0 console=tty1 usb-storage.quirks=174c:55aa:u,2109:0715:u,152d:0578:u,152d:0579:u,152d:1561:u,174c:0829:u,14b0:0206:u

Can I simply append the path, so the cmdline.txt afterwards looks as follows, i.e. just a blank between "u" and "firmware_class.path" etc.? (still one line)
dwc_otg.lpm_enable=0 console=tty1 usb-storage.quirks=174c:55aa:u,2109:0715:u,152d:0578:u,152d:0579:u,152d:1561:u,174c:0829:u,14b0:0206:u firmware_class.path=/mnt/data/supervisor/share/firmware/

Thank you! 😃

@thatsthat
Copy link

thatsthat commented Apr 1, 2023 via email

@7wells
Copy link

7wells commented May 18, 2023

@thatsthat
Sorry for my very late reply (I was distracted by other stuff 😊)!
I don't have this path:
/mnt/data/supervisor/share/firmware/

There's /mnt but it's empty. What have I missed?

@7wells
Copy link

7wells commented May 19, 2023

@agners
@HahnBenjamin
I don't have this path:
/mnt/data/supervisor/share/firmware/

There's /mnt but it's empty. What have I missed?

PS:
I have asked also in the HA community:
https://community.home-assistant.io/t/how-to-use-firmware-search-path-e-g-mnt-data-supervisor-share-firmware/573387

@7wells
Copy link

7wells commented May 26, 2023

Hello! Is there really nobody with a hint for me?

@admin-lm
Copy link

I switched to Home Assistant Supervised

@7wells
Copy link

7wells commented May 27, 2023

Sorry, I don't understand. what you mean.

I use this:

Home Assistant 2023.5.4
Supervisor 2023.04.1
Operating System 10.1
Frontend 20230503.3 - latest

@7wells
Copy link

7wells commented Jun 2, 2023

Has really nobody a hint for my question?

@7wells
Copy link

7wells commented Jul 16, 2023

Really sad :(

@agners
Copy link
Member

agners commented Jul 17, 2023

This is an issue tracker and not a support forum. I've responded to your community post.

@7wells
Copy link

7wells commented Aug 20, 2023

Maybe I've missed it, but I asked how to make the path persistent and never saw an answer on this.

https://community.home-assistant.io/t/how-to-use-firmware-search-path-e-g-mnt-data-supervisor-share-firmware/573387/4

Sorry to bother you with this and thanks for your patience. 😊

PS: Am I the only one with this problem?

@7wells
Copy link

7wells commented Sep 3, 2023

If there is anything else I should add, please let me know. Thank you!

@7wells
Copy link

7wells commented Oct 6, 2023

Hi there!

I still have no solution for my problem, i.e. any firmware drivers for my DVB-T2 USB stick that I want to store will be removed after a restart.

Are there any ways to do this with the recommended HA installation?

@7wells
Copy link

7wells commented Nov 6, 2023

Ok, only months later I understand that the paths described obviously meant the underlying system, whereas I logged into HA and placed them there. Well, at least I think that was my problem. I've now managed to get access to the underlying system with ssh via port 22222 and public/private keys and will see if that helps me further.

@agners
Copy link
Member

agners commented Nov 7, 2023

Sorry for failing to recognize the problem here exactly, glad you found how to progress.

Note however, as I posted in this community post and noted in this comment #1157 (comment):

The alternative firmware path is available a bit later during boot. For many devices this means that the driver will not be able to load the firmware because the driver is loaded earlier at boot time, leading to the exact same issue.

You can work around by hot-plugging the device (if the device is connected through USB or similar). But if not, placing the firmware there likely won't work, unfortunately 😢

I tried to find a solution to that, but from what I understand, there is really no way to tell the kernel to delay loading of firmwares until a later point in time. The HAOS architecture of using a read-only file system really doesn't allow to include firmware into the root partition which is available earlier. So what we are trying to do (add firmware to a mounted location) really seems not to work 😢 If someone has an idea how to implement this, I would be grateful.

Until then, for non-hotpluggable device (or people which don't want to work around the limitation), using Supervised is probably the best alternative right now.

@7wells
Copy link

7wells commented Nov 21, 2023

Is it possible to simulate hot-plugging?

@7wells
Copy link

7wells commented Dec 17, 2023

@agners

I feel really embarrassed to bother you and the community with this topic again, but maybe you find my below described observation useful (sorry, if it does not).

So I have that DVB-T2 USB stick (AVerMedia TD310) connected to my Raspberry Pi 4 that runs Home Assistant (2023.12.1). I restart my RPi4, log in via ssh (not port 22222 but just 22, i.e. not logged in via the "developer's method") and check if the card appears under /dev.

TL;DR: First it is, then it isn't.

After a reboot of my Raspberry Pi 4 that runs Home Assistant, it's shown:

ls -al /dev/dvb /dev/dri
/dev/dri:
total 0
drwxr-xr-x    3 root     root           120 Apr  4  2023 .
drwxr-xr-x   17 root     root          4040 Apr  4  2023 ..
drwxr-xr-x    2 root     root           100 Apr  4  2023 by-path
crw-rw----    1 root     netdev    226,   0 Apr  4  2023 card0
crw-rw----    1 root     netdev    226,   1 Apr  4  2023 card1
crw-rw-rw-    1 root     plugdev   226, 128 Apr  4  2023 renderD128

/dev/dvb:
total 0
drwxr-xr-x    3 root     root            60 Apr  4  2023 .
drwxr-xr-x   17 root     root          4040 Apr  4  2023 ..
drwxr-xr-x    2 root     root           120 Apr  4  2023 adapter0

But after about 10 seconds later, it's gone:

ls -al /dev/dvb /dev/dri
ls: /dev/dvb: No such file or directory
/dev/dri:
total 0
drwxr-xr-x    3 root     root           120 Apr  4  2023 .
drwxr-xr-x   16 root     root          3960 Dec 17 19:17 ..
drwxr-xr-x    2 root     root           100 Apr  4  2023 by-path
crw-rw----    1 root     netdev    226,   0 Apr  4  2023 card0
crw-rw----    1 root     netdev    226,   1 Apr  4  2023 card1
crw-rw-rw-    1 root     plugdev   226, 128 Apr  4  2023 renderD128

How can /dev/dvb/ be available after hardware restart and gone several seconds later? The card is tightly plugged in, and I use an official Raspberry USB-C power supply (5.1 V, 3 A output). EDIT: The (active) DVB-T antenna is powered by a separate power plug.

Do you have an idea why it is first shown and then - without me doing anything - "disappearing" again?

@7wells
Copy link

7wells commented Dec 17, 2023

After unplugging and replugging it, it's visible again. Is this due to the problem you described in post #1157 (comment)?

@7wells
Copy link

7wells commented Dec 17, 2023

As I made progress with this DVB-T2 USB stick and the TVheadend add-on in Home Assistant, I would like to share it here as well for other people who stumble over a similar problem. Please note that there are 2 TVheadend add-ons for HA, and it seems that you need both, i.e. first install one, then deinstall it, then install the other. The details are described in this thread:
GauthamVarmaK/addon-tvheadend#45 (comment)

Good luck! 👍

@agners
Copy link
Member

agners commented Dec 20, 2023

After unplugging and replugging it, it's visible again. Is this due to the problem you described in post #1157 (comment)?

Yeah the replugging is explained by that. I am not sure why the device disappeared above. Once it is there, it should stay there. Unless there is some USB bus problems, but in that case you should see some errors in the host logs.

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

No branches or pull requests

8 participants