Leveraging both FuUsbDevice & FuUdevDevice for same device

69 views
Skip to first unread message

Sanjay Sheth

unread,
Sep 22, 2022, 11:47:13 PM9/22/22
to fwupd
Hi,
Our camera device leverages following:
  • XU control (FuUdevDevice, subsystem: video4linux): To query device info like firmware version
  • USB bulk transfer (FuUsbDevice, subsystem: usb): To update firmware using g_usb_device_bulk_transfer APIs
Currently we are leveraging FuUdevDevice, with following quirk file entry to support get-devices() API. Console output (get-devices-console-output.txt file) attached.
[VIDEO4LINUX\VEN_046D&DEV_08E2]
Plugin = logitech_whiteboardcams

Question is how do we achieve firmware update, leveraging FuUsbDevice/g_usb_device_bulk_transfer for the same device?
  • Use fu_device_new/g_object_new to create FuUsbDevice on the fly!
  • Any customization needed in quirk/firmware.metainfo.xml files?
  • Pointers to similar plugins?
Also attaching v4l2-ctl/udevadm console out (device_info.txt file) for your reference.

Thanks in advace,
Sanjay 

get-devices-console-output.txt
device_info.txt

Richard Hughes

unread,
Sep 23, 2022, 2:13:30 AM9/23/22
to Sanjay Sheth, fwupd
On Fri, 23 Sept 2022 at 04:47, Sanjay Sheth <ssh...@logitech.com> wrote:
> Use fu_device_new/g_object_new to create FuUsbDevice on the fly!

I think what you're asking for is the analogous function to:

GUdevDevice *fu_usb_device_find_udev_device(FuUsbDevice *device, GError **error)

i.e. a way to get the GUsbDevice from a FuUdevDevice -- correct? If
so, that's not easy, as we need the GUsbContext to call
g_usb_context_find_by_bus_address() which the FuUdevDevice obviously
doesn't have. Maybe it's okay to just call g_usb_context_new() like
the usb device calls g_udev_client_new()? That's certainly the easiest
option. Can you try that and see if it works in practice?

Richard.

Sanjay Sheth

unread,
Sep 23, 2022, 2:54:41 AM9/23/22
to fwupd
Thanks Richard. Will try that out. Let me see if USB->UDEV works!. Is there any similar plugin, as sample/
example!

Richard Hughes

unread,
Sep 23, 2022, 3:49:35 AM9/23/22
to Sanjay Sheth, fwupd
On Fri, 23 Sept 2022 at 07:54, Sanjay Sheth <ssh...@logitech.com> wrote:
> Thanks Richard. Will try that out. Let me see if USB->UDEV works!. Is there any similar plugin, as sample/
> example!

Not quite, but how does this 100% untested PR work?
https://github.com/fwupd/fwupd/pull/5071 If it works for you please
let me know.

Richard

Sanjay Sheth

unread,
Sep 23, 2022, 4:33:52 PM9/23/22
to fwupd
Not that familiar with bus level details. Seeing 0 for busnum/devnum values. I have created temp branch https://github.com/fwupd/fwupd/tree/wip/vcdmp/wbcams1 for new logitech_whiteboardcams plugin. Also attached get-devices() output. 
get-devices-console-output9_23.txt

Sanjay Sheth

unread,
Sep 27, 2022, 12:26:07 PM9/27/22
to fwupd
Hi Richard any updates? Do we have to set any other properties before invoking fu_udev_device_find_usb_device()? Any backdoor (reverse engineering) to create USB first and then UDEV?

Richard Hughes

unread,
Sep 29, 2022, 8:38:27 AM9/29/22
to Sanjay Sheth, fwupd
On Tue, 27 Sept 2022 at 17:26, Sanjay Sheth <ssh...@logitech.com> wrote:
> Hi Richard any updates?

Can you try the wip/hughsie/fu_udev_device_find_usb_device branch
again; it now looks at the parent chain until it finds a device.

Richard.

Sanjay Sheth

unread,
Sep 29, 2022, 12:29:29 PM9/29/22
to fwupd
Thank you very much Richard. That helped.

I am using something like following to create FuUsbDevice from GUsbDevice, let me know if any issues:
 g_autoptr(GUsbDevice) g_usb_device = fu_udev_device_find_usb_device(FU_UDEV_DEVICE(device), error);
g_autoptr(FuUsbDevice) usb_device = fu_usb_device_new(fu_device_get_context(device), g_usb_device);

Richard Hughes

unread,
Sep 30, 2022, 8:19:05 AM9/30/22
to Sanjay Sheth, fwupd
On Thu, 29 Sept 2022 at 17:29, Sanjay Sheth <ssh...@logitech.com> wrote:
> g_autoptr(GUsbDevice) g_usb_device = fu_udev_device_find_usb_device(FU_UDEV_DEVICE(device), error);
> g_autoptr(FuUsbDevice) usb_device = fu_usb_device_new(fu_device_get_context(device), g_usb_device);

Yes that works; but I do wonder why you don't create a FuUsbDevice
directly -- e.g. matching against a specific VID/PID and subclassing
FuUsbDevice.

Richard

Sanjay Sheth

unread,
Oct 6, 2022, 2:34:47 PM10/6/22
to fwupd
Hi Richard,
If no issues, would you please push changes of your branch: wip/hughsie/fu_udev_device_find_usb_device branch
Let me explore creating FuUsbDevice. Is there a example? What are the mandatory properties needed?
Sanjay

Richard Hughes

unread,
Oct 7, 2022, 10:16:54 AM10/7/22
to Sanjay Sheth, fwupd
On Thu, 6 Oct 2022 at 19:34, Sanjay Sheth <ssh...@logitech.com> wrote:
> If no issues, would you please push changes of your branch: wip/hughsie/fu_udev_device_find_usb_device branch

Before we push this to main I'd really like to see how it's going to be used.

> Let me explore creating FuUsbDevice. Is there a example? What are the mandatory properties needed?

If you can share your current code I can give you some more specific
pointers, but you probably want to look at
https://github.com/fwupd/fwupd/tree/main/plugins/colorhug for a
super-simple example.

Richard

Sanjay Sheth

unread,
Oct 10, 2022, 8:42:19 PM10/10/22
to fwupd
Thanks Richard,
I have created temp branch https://github.com/fwupd/fwupd/tree/wip/vcdmp/wbcams1 for new logitech_whiteboardcams plugin. Also attached fwupd/fwupdmgr/fwupdtool output captured during firmware upgrade. Branch not ready for PR yet, but let me know if seeing any major issues.
Sanjay 

fwupd_output.log
fwupdmgr_output.log

Richard Hughes

unread,
Oct 12, 2022, 1:12:36 PM10/12/22
to Sanjay Sheth, fwupd
Hi Sanjay,

I'm just wondering why you couldn't do:

[USB\VID_046D&PID_08E2]
Plugin = logitech_whiteboardcams

...and then you can derive from FuUsbDevice in
FuLogitechWhiteboardcamsDevice and then use
g_usb_device_bulk_transfer() directly.

Richard.
> --
> You received this message because you are subscribed to the Google Groups "fwupd" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fwupd+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/fwupd/cb4243d4-4e64-453d-b0a9-fd3b7679c978n%40googlegroups.com.

Sanjay Sheth

unread,
Oct 12, 2022, 2:14:33 PM10/12/22
to Richard Hughes, fwupd
Hi Richard,
Our camera device leverages following:
XU control (FuUdevDevice, subsystem: video4linux): To query device info like current firmware version

Richard Hughes

unread,
Oct 12, 2022, 3:42:27 PM10/12/22
to Sanjay Sheth, fwupd
On Wed, 12 Oct 2022 at 19:14, Sanjay Sheth <ssh...@logitech.com> wrote:
> XU control (FuUdevDevice, subsystem: video4linux): To query device info like current firmware version

I guess V4L gets the version from somewhere? e.g. a control transfer
we could duplicate in fwupd? Or you could go "the other way", i.e. get
a GUdevDevice from a proper FuUsbDevice.

Richard.

Sanjay Sheth

unread,
Oct 13, 2022, 2:10:39 PM10/13/22
to fwupd
Hi Richard,
V4L code looks complex. Let me try "the other way" approach first.
Thanks,
Sanjay

Sanjay Sheth

unread,
Oct 19, 2022, 9:26:42 PM10/19/22
to fwupd
Hi Richard,

1. Creating UDEV from USB is not working. Code: https://github.com/fwupd/fwupd/blob/wip/vcdmp/scribe1/plugins/logitech-scribe/fu-logitech-scribe-device.c#L552

2. Creating USB from UDEV works. Code: https://github.com/fwupd/fwupd/blob/wip/vcdmp/wbcams1/plugins/logitech-whiteboardcams/fu-logitech-whiteboardcams-device.c#L543

Not sure if need video4linux subsystem in fu-udev-device or need to explicitly set some properties before creating UDEV.

v4l2-ctl/udevadm console output already attached at the beginning of this thread. I have also attached the get-devices console output with non-working code (#1).

Thanks,
Sanjay
get-devices-console-output_Oct_19.txt

Sanjay Sheth

unread,
Oct 25, 2022, 1:16:57 PM10/25/22
to fwupd
Just a gentle reminder for any updates here.

Richard Hughes

unread,
Oct 25, 2022, 1:24:20 PM10/25/22
to Sanjay Sheth, fwupd
Hi Sanjay,

Sorry for the delay; I'm working like crazy here.

I guess I'm just a bit confused why you need to do UVCIOC_CTRL_QUERY
(on the udev device) and also g_usb_device_bulk_transfer() on the USB
device. Is there a way to only use g_usb_device_xxx() and not use the
udev functionality at all? Can you provide a bit of context about what
both calls are and what they're trying to do? Thanks.

Richard.
> --
> You received this message because you are subscribed to the Google Groups "fwupd" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fwupd+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/fwupd/8c94d598-72b4-44f9-b881-197074501427n%40googlegroups.com.

Sanjay Sheth

unread,
Oct 25, 2022, 1:29:17 PM10/25/22
to fwupd
Thanks Richard,
Our camera device leverages following:
  • XU control (FuUdevDevice, subsystem: video4linux): To query device info like firmware version
  • USB bulk transfer (FuUsbDevice, subsystem: usb): To update firmware using g_usb_device_bulk_transfer APIs

Richard Hughes

unread,
Oct 25, 2022, 2:04:26 PM10/25/22
to Sanjay Sheth, fwupd
On Tue, 25 Oct 2022 at 18:29, Sanjay Sheth <ssh...@logitech.com> wrote:
> XU control (FuUdevDevice, subsystem: video4linux): To query device info like firmware version

Is XU doing something simple (e.g. a couple of control transfers) or
something altogether more complicated?

Richard.

Sanjay Sheth

unread,
Oct 25, 2022, 2:09:52 PM10/25/22
to fwupd
We just make couple of XU calls to get version info, so simple from client side. But I looked at XU code and duplicating that code in fwupd seems complicated.

Richard Hughes

unread,
Oct 25, 2022, 2:56:23 PM10/25/22
to Sanjay Sheth, fwupd
On Tue, 25 Oct 2022 at 19:09, Sanjay Sheth <ssh...@logitech.com> wrote:
> We just make couple of XU calls to get version info, so simple from client side. But I looked at XU code and duplicating that code in fwupd seems complicated.

I'm tempted to say that merging
https://github.com/fwupd/fwupd/pull/5071 makes sense. Would that work
for you?

Richard.

Sanjay Sheth

unread,
Oct 25, 2022, 3:01:10 PM10/25/22
to fwupd
Yes please. I will also cleanup our plugin and do more testing
Reply all
Reply to author
Forward
0 new messages