With the recent modernization of the USB API (release 24.05), we take a big step into the direction of sharing an USB device in between separate drivers. Thereby, the resource granularity to split an USB device is on the level of interfaces and not endpoints. Of course, one interface can aggregates up to several endpoints.
So, I do not have the USB configuration of your concrete device at hand, but as long as the serial protocol of the USB device is done in a separate interface from the ethernet one, it should be possible to use distinct drivers.
Now come the “but”: but as we have no concrete scenario tested yet, we haven’t unlocked the possibility to share an USB device within the USB host controller driver fully yet. Especially, we’d like to distinguish drivers with ultimate control from drivers with limited ability to “only” use an interface, but no right to re-configure the USB device. As we do not have tested this thoroughly, it is not recommended yet.
However, it shouldn’t be hard to use it, given that you prevent one of the drivers to re-configure the USB device (probably at best the Genode native driver).
Of course you need to tweak your USB configuration in a way that both drivers have policies to access the device. Finally, you have to remove the checks for double-usage within acquire_device
and acquire_single_device
within repos/os/src/lib/genode_c_api/usb.cc
, like:
--- a/repos/os/src/lib/genode_c_api/usb.cc
+++ b/repos/os/src/lib/genode_c_api/usb.cc
@@ -1382,16 +1382,6 @@ Device_capability Session_component::acquire_device(Device_name const &name)
[&] (genode_usb_device & device) {
found = true;
- _sessions.apply(
- [&] (Session_component &sc) {
- return sc.acquired(device); },
- [&] (Session_component &) {
- found = false; });
-
- if (!found) {
- warning("USB device ", name,
- "already acquired by another session");
- }
cap = _acquire(device.label(), true);
_sessions.for_each([&] (Session_component &sc) {
@@ -1415,16 +1405,6 @@ Device_capability Session_component::acquire_single_device()
return !cap.valid() && _matches(device); },
[&] (genode_usb_device & device) {
- bool acquired = false;
- _sessions.apply(
- [&] (Session_component &sc) {
- return sc.acquired(device); },
- [&] (Session_component &) {
- acquired = true; });
-
- if (acquired)
- return;
-
cap = _acquire(device.label(), true);
_sessions.for_each([&] (Session_component &sc) {
if (sc._matches(device)) sc.update_devices_rom(); });
I wouldn’t recommend to you to share one USB device in between different Linux driver ports now! There are high chances that the drivers will interfere badly by re-configuring the USB device in initialization simultanously.
If you want to stay on safe, well-worn pathes, of course you can combine usb net & uart Linux ports within one driver component.