Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lenovo-li
Copy link
Collaborator

Summary

Introduce lenovo-accessory plugin to support firmware updates for Lenovo USB-HID accessories.

Scope

  • Transport: USB-HID only (hidraw)
  • Supported VID/PID pairs:
    • 17ef:629d
    • 17ef:6201 (USB dongle)

Implementation

  • Add plugins/lenovo-accessory/ with device quirks, plugin code and self-test.
  • Communicate over standard /dev/hidraw*; udev rule grants user access.
  • No dependency on raw /dev/bus/usb.

Checklist (new plugin)

  • Plugin compiles & loads cleanly
  • Listed devices enumerate and report version
  • Signed .cab update installs successfully
  • Quirk file with correct GUIDs added
  • Documentation stub included
  • Zero extra external dependencies
  • Commit message follows project convention

Comment on lines 12 to 18
fu_lenovo_hid_firmware_parse(FuFirmware *firmware,
GInputStream *stream,
FuFirmwareParseFlags flags,
GError **error)
{
return TRUE;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this firmware firmware documented anywhere? if it's just a binary blob with no format then this parser doesn't need to exist :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's not a full parser - could we at least parse the firmware is valid from the header and a version field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the guidance. To clarify, we actually have two types of firmware files: .bin and .hex. The .hex file, in particular, likely requires proper parsing to be handled correctly.

I implemented fu_lenovo_hid_firmware_parse as a placeholder because I'm still learning the framework and noticed other plugins using it. However, during my local testing with fwupdtool install ../fw/Lenovo-hid_6201-vs1.0.2.cab --allow-older, I found that the execution never actually enters this parse function. This is why I haven't implemented the specific logic yet.

I would like to follow @superm1's suggestion to at least implement a header and version check. Could you help me understand how to correctly link this firmware parser to my device so it gets triggered during the installation process? Once I can verify the function is being called, I will update it with the necessary parsing logic for both formats.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to correctly link this firmware parser to my device

You can either implement a FuDeviceClass->prepare_firmware() where you can create an instance using fu_lenovo_hid_firmware_new() (if you need to check that VIDs/PIDs are valid) or you can use fu_device_set_firmware_gtype() in fu_lenovo_accessory_hid_device_init() if you want the daemon to just do it for you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the explanation

error))
return FALSE;
if (usb_pid == 0x629d)
fu_device_add_instance_id(device, "HIDRAW\\VEN_17EF&DEV_629D");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you want _build_instance_id here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. When the device is being updated, it enters bootloader mode, and in this state, the PID for all devices changes to 0x6194. I added the instance_id here specifically to differentiate between different devices while they are in this shared bootloader state.


fu_progress_set_id(progress, G_STRLOC);
fu_progress_add_step(progress, FWUPD_STATUS_DEVICE_RESTART, 100, "switch-dfu");
fu_lenovo_accessory_command_dfu_set_devicemode(FU_HIDRAW_DEVICE(self),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to check return value if setting gerror

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@lenovo-li
Copy link
Collaborator Author

Apologies for the noise. I made a mistake while trying to squash my commits from the lenovo-ble branch and force-pushing them to lenovo-accessory. It seems I accidentally cleared the history on the target branch.

@lenovo-li lenovo-li enabled auto-merge (squash) January 8, 2026 09:38
@hughsie
Copy link
Member

hughsie commented Jan 8, 2026

@lenovo-li lets move this to the origin remote so we can all polish it up a bit. Give me a couple of mins.

@hughsie
Copy link
Member

hughsie commented Jan 8, 2026

@lenovo-li I've moved this to #9760 -- give me a couple of hours and I'll fix up some of the issues myself. I've added com.lenovo.accessory to the LVFS -- so it should be possible (and is a requirement for merging to main!) to create an emulation of both wired and BLE updates so we can prevent future regressions. If you need a hand with that please let me know.

@hughsie hughsie closed this Jan 8, 2026
auto-merge was automatically disabled January 8, 2026 12:05

Pull request was closed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants