Commit Graph

65 Commits

Author SHA1 Message Date
8BitDo
ed663623db Add 8BitDo SN30v2 gamepad 2021-05-31 08:45:10 -05:00
Richard Hughes
69071e14e8 trivial: Use new 8BitDo name 2021-05-24 08:59:54 +01:00
Richard Hughes
1981c63d58 Remove FuFirmwareImage and just use FuFirmware instead
This allows us to 'nest' firmware formats, and removes a ton of duplication.

The aim here is to deprecate FuFirmwareImage -- it's almost always acting
as a 'child' FuFirmware instance, and even copies most of the vfuncs to allow
custom types. If I'm struggling to work out what should be a FuFirmware and
what should be a FuFirmwareImage then a plugin author has no hope.

For simple payloads we were adding bytes into an image and then the image into
a firmware. This gets really messy when most plugins are treating the FuFirmware
*as* the binary firmware file.

The GBytes saved in the FuFirmware would be considered the payload with the
aim of not using FuFirmwareImage in the single-image case.
2021-03-09 21:14:12 +00:00
Richard Hughes
b3f9841924 Support more than one protocol for a given device
Devices may want to support more than one protocol, and for some devices
(e.g. Unifying peripherals stuck in bootloader mode) you might not even be able
to query for the correct protocol anyway.
2021-03-01 16:14:36 +00:00
Richard Hughes
078beafb2d Add a new internal flag to opt-in to GUID matching
It is far too easy to forget to set FWUPD_DEVICE_FLAG_NO_GUID_MATCHING for new
plugins, and without it it all works really well *until* a user has two devices
of the same type installed at the same time and then one 'disappears' for hard
to explain reasons. Typically we only need it for replug anyway!

Explicitly opt-in to this rarely-required behaviour, with the default to just
use the physical and logical IDs. Also document the update behavior for each
plugin to explain why the flag is being used.

This allows you to have two identical Unifying plugged in without one of them
being hidden from the user, at the same time allowing a HIDRAW<->USB transition
when going to and from bootloader and runtime modes.

This removes the workaround added in 99eb3f06b6.

Fixes https://github.com/fwupd/fwupd/issues/2915
2021-02-25 15:47:25 +00:00
Richard Hughes
2e1245728f Call the superclass directly from subclassed devices
This allows a device subclass to call the parent method after doing an initial
action, or even deliberately not call the *generic* parent method at all.

It also simplifies the plugins; you no longer have to remember what the plugin
is deriving from and accidentally clobber the wrong superclass method.
2021-02-18 16:18:34 +00:00
Richard Hughes
d99f86023f trivial: Add getters to FuChunk
At the moment FuChunks are sometimes mutable, and sometimes immutable, and it's
all a bit too low level for comfort.

Before we can do any kind of optimisation or verification we need plugins to
stop reading directly from the C structure. The aim here is to make FuChunk
optionally mutable without making assumptions about the memory model, and also
to be able to introspect it for the docs.
2021-01-28 16:42:54 +00:00
Richard Hughes
5c9b1fcc81 Only include the start year in the copyright header
The end year is legally and functionally redundant, and more importantly causes
cherry-pick conflicts when trying to maintain old branches. Use git for history.
2021-01-07 14:48:16 +00:00
Richard Hughes
58993ac005 trivial: Fix some error prefixes 2020-11-06 09:57:03 +00:00
Richard Hughes
9b688d0b73 trivial: Set FWUPD_STATUS_DECOMPRESSING when preparing firmware
This avoids the plugins forgetting to do it themselves.
2020-09-08 14:18:46 +01:00
Richard Hughes
85226fd9d1 Remove potentially problematic language
Red Hat wants to drive an initiative in correcting problematic and potentially
divisive language in open source projects. These naming conventions and
descriptive phrases are hurtful and offensive to many of our colleagues across
the open source universe.

See https://www.redhat.com/en/blog/making-open-source-more-inclusive-eradicating-problematic-language
2020-06-30 17:31:17 +01:00
Richard Hughes
1283c2696d Do not skip attach() if the device is marked _WILL_DISAPPEAR
The idea here is that the device would not come back after it was restarted,
and skipping the attach in the engine was only working around the fact that the
ebitdo did not split out an ->attach() function.

We can't really blame it; we only decoupled the _IS_BOOTLOADER requirement
for ->attach() recently...
2020-04-16 08:43:45 -05:00
Richard Hughes
cddf5b5b89 Only auto-add counterpart GUIDs when required
Doing this unconditionally means we accidentally 'bleed' one device mode into
another in a non-obvious way. For instance, a device might have two operating
modes with different GUIDs. If firmware is supplied for both modes in the same
cabinet archive then we might accidentally match the 'wrong' firmware when
the daemon has observed a mode switch and added the counterpart GUIDs.

We only really need the counterpart GUIDs when switching between Jabra, 8bitdo
and DFU devices where the DFU bootloader VID:PID is not manually tagged with
`CounterpartGuid` in a quirk file. In the general case lets keep it simple to
avoid difficult to find bugs.
2020-04-08 13:55:39 +01:00
Richard Hughes
f50ff2c27e Decouple the version format from the version itself
If we say that the version format should be the same for the `version_lowest`
and the `version_bootloader` then it does not always make sense to set it at
the same time.

Moving the `version_format` to a standalone first-class property also means it
can be typically be set in the custom device `_init()` function, which means we
don't need to worry about *changing* ther version format as set by the USB and
UDev superclass helpers.
2020-02-25 14:00:09 +00:00
Richard Hansen
a1edff9ab1 ebitdo: Fix the endpoint address logged in the error message
Addresses #1681.
2020-02-14 06:07:37 +00:00
Richard Hughes
10079e6b8c Export the raw device version to the client --verbose output
It turns out this is really useful for debugging UEFI firmware updates which
typically use the 0x-prefixed version numbers without a version format.
2019-12-02 06:51:25 +00:00
Richard Hughes
56ac823af9 Set the protocol per-device not per-plugin
Some plugins have devices with more than one protocol. Logically the protocol
belongs to the device, not the plugin, and in the future we could use this to
further check firmware that's about to be deployed.

This is also not exported into libfwupd (yet?) as it's remains a debug-feature
only -- protocols are not actually required for devices to be added.
2019-11-25 18:01:54 +00:00
Mario Limonciello
e2b8a2797e Skip cleanup after device is done updating if will-disappear is set (Fixes: #1529)
This fixes a regression introduced by 2031ce3bf6
that leads to:
```
USB error on device 2dc8:5750 : No such device (it may have been disconnected) [-4]
```
2019-11-14 08:06:17 -06:00
Richard Hughes
2414f24b8a trivial: Provide some defines for common image names 2019-11-08 09:30:09 -06:00
Mario Limonciello
2e06dcd5e3 trivial: 8bitdo: set a transient failure while waiting for user action 2019-11-01 14:31:03 +00:00
Mario Limonciello
8ecb08ec23 trivial: 8bitdo: show the same message for SN30pro and SN30pro+ 2019-11-01 14:31:03 +00:00
Richard Hughes
7f1b8e7dce ebitdo: Modernize the plugin to use FuFirmware
This allows us to do three things:

* Fuzz the loader with `fwupdtool firmware-parse`
* Check the firmware *before* the hardware is put into bootloader mode
* Use FuChunk to build the 32 byte payload chunks
2019-10-31 09:21:35 -05:00
Mario Limonciello
cbbde24e38 ebitdo: if the device has the will disappear flag, don't wait for ack (Fixes: #994)
Some 8bitdo receivers seem to automatically reboot when done writing,
so just stop if we have that flag and notice this behavior.
2019-10-18 14:47:14 -05:00
Mario Limonciello
f37af548da 8bitdo: use will-disappear flag for sf30/sn30 controllers (Fixes: #783)
These controllers reboot back into Nintendo Switch mode typically
and fwupd will not be able to probe them.
2019-10-12 14:07:34 -05:00
Mario Limonciello
b73d255b13 trivial: ebitdo: don't dump out firmware header unless plugin verbose 2019-10-12 14:07:34 -05:00
Mario Limonciello
cee97bc674 trivial: ebitdo: don't use local errors when writing firmware
Just prefix them instead.
2019-10-12 14:07:34 -05:00
Richard Hughes
2378ff314f ebitdo: Use klass_device->write_firmware like other plugins 2019-10-09 20:02:16 +01:00
Richard Hughes
989acf12e7 Create the custom plugin GType in common code
This reduces the amount of boilerplate in plugins.
2019-10-07 12:37:21 +01:00
Richard Hughes
5308ea4fae Never use memcpy() in a possibly unsafe way
There are several subtle bugs in various places in fwupd caused by not treating
user-provided offsets into buffers as unsafe. As fwupd runs as root we have to
assume that all user firmware is evil, and also that devices cannot be trusted.

Make a helper to put all the logic into one place and convert all users.
2019-08-12 09:22:09 -05:00
Richard Hughes
7afd7cba0d Use FuFirmware as a container for firmware images
In many plugins we've wanted to use ->prepare_firmware() to parse the firmware
ahead of ->detach() and ->write_firmware() but this has the limitation that it
can only return a single blob of data.

For many devices, multiple binary blobs are required from one parsed image,
for instance providing signatures, config and data blobs that have to be pushed
to the device in different way.

This also means we parse the firmware *before* we ask the user to detach.

Break the internal FuDevice API to support these firmware types as they become
more popular.

This also allows us to move the Intel HEX and SREC parsing out of the dfu plugin
as they are used by a few plugins now, and resolving symbols between plugins
isn't exactly awesome.
2019-08-08 13:10:57 +01:00
Richard Hughes
dfa9e11bb2 Allow handling FORCE for devices that subclass FuDevice
Pass FwupdInstallFlags down to the vfunc to allow us to check the flags when
parsing the firmware and updating the device.
2019-05-05 15:29:00 -05:00
Richard Hughes
5079f26f0e Never guess the version format from the version string
This leads to madness, as some formats are supersets of the detected types,
e.g. 'intel-me' is detected as 'quad' and 'bcd' is detected as 'pair'.

Where the version format is defined in a specification or hardcoded in the
source use a hardcoded enum value, otherwise use a quirk override.

Additionally, warn if the version does not match the defined version format
2019-04-30 09:25:41 +01:00
Kelly Anderson
31b2ce83e1 Updated: Add support for 8BitDo M30. 2019-04-09 12:38:24 -04:00
Richard Hughes
363127e518 ebitdo: Fix the reported version number if the daemon locale is not C.UTF-8
Always use a dot as the delimiter of a semver rather than treating it as a
floating point number.

Related to https://github.com/hughsie/lvfs-website/issues/216
2018-12-25 16:09:45 -06:00
Richard Hughes
e59cb9af01 trivial: Add fu_common_dump_raw() 2018-12-05 15:09:56 +00:00
Richard Hughes
7772dcfc91 trivial: Ensure the daemon sends IDLE when firmware is updated 2018-09-10 16:12:12 +01:00
Richard Hughes
2aa3360d46 trivial: Include appstream-glib.h in the main plugin header 2018-09-04 08:22:39 -05:00
Richard Hughes
ff704414f6 Use superclassed versions of FuDevice when calling udev_added() and usb_added()
The daemon creates a baseclass of either FuUsbDevice or FuUdevDevice when the
devices are added or coldplugged to match the quirk database and to find out
what plugin to run.

This is proxied to plugins, but they are given the GUsbDevice or GUdevDevice and
the FuDevice is just thrown away. Most plugins either use a FuUsbDevice or
superclassed version like FuNvmeDevice and so we re-create the FuDevice, re-probe
the hardware, re-query the quirk database and then return this to the daemon.

In some cases, plugins actually probe the hardware three times (!) by creating
a FuUsbDevice to get the quirks, so that the plugin knows what kind of
superclass to create, which then itself probes the hardware again.

Passing the temporary FuDevice to the plugins means that the simplest ones can
just fu_plugin_device_add() the passed in object, or create a superclass and
incorporate the actual GUsbDevice and all the GUIDs.

This breaks internal plugin API but speeds up startup substantially and deletes
a lot of code.
2018-09-04 08:22:39 -05:00
Richard Hughes
1263446b23 trivial: Add a 'setup' vfunc that is used after open()
The setup() is the counterpart to probe(), the difference being the former needs
the device open and the latter does not.

This allows objects that derive from FuDevice, and use FuDeviceLocker to use
open() and close() without worrying about the performance implications of
probing the hardware, i.e. open() now simply opens a file or device.
2018-09-03 19:56:26 -05:00
Richard Hughes
838d91e4ed Add support for counterpart GUIDs
These are GUIDs that are related to the main device, but should not be used for
quirk matching. For instance, we might want to list the GUIDs for a bootloader
mode, but we don't want to import all the quirks for the bootloader when in the
runtime mode.
2018-08-30 16:55:41 +01:00
Richard Hughes
02c90d8a03 Remove the unused Emacs indenting headers from all source files
Fixes https://github.com/hughsie/fwupd/issues/636
2018-08-09 12:48:04 +01:00
Richard Hughes
87fb9ff447 Change the quirk file structure to be more efficient
This pivots the data storage so that the group is used as the preconditon
and the key name is used as the parameter to change. This allows a more natural
data flow, where a new device needs one new group and a few few keys, rather
than multiple groups, each with one key.

This also allows us to remove the key globbing when matching the version format
which is often a source of confusion.

Whilst changing all the quirk files, change the key prefixes to be more familiar
to Windows users (e.g. Hwid -> Smbios, and FuUsbDevice -> DeviceInstanceId)
who have to use the same IDs in Windows Update.

This also allows us to pre-match the desired plugin, rather than calling the
probe() function on each plugin.
2018-06-28 13:32:30 +01:00
Richard Hughes
63b173046d trivial: Rename the 'plugin-hints' functionality to 'custom-flags'
They will be used as actual flags in the future.
2018-06-28 12:07:13 +01:00
Richard Hughes
04d6965a14 ebitdo: Do not use bootloader commands after a successful flash and reboot
We need to remove the flag if the quirk is not present.

Fixes the cosmetic-but-scary-looking 'failed to send to device on ep 0x01: USB
error on device 2dc8:9001 : Input/output error'.

Fixes the other half of https://github.com/hughsie/fwupd/issues/565
2018-06-26 14:12:02 +01:00
Richard Hughes
7a874176ff trivial: Add a FuDevice flag to show the device is in bootloader mode
This is useful to present to the user using the command line, and means each
FuDevice-deriving object does not have to handle this.
2018-05-31 18:50:19 +01:00
Richard Hughes
4152990537 trivial: Convert FuEbitdoDevice to use G_DECLARE_FINAL_TYPE 2018-05-29 09:20:21 +01:00
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
0b8c1e7e92 ebitdo: Move the bootloader fallback instructions 2018-05-14 17:09:23 +01:00
Richard Hughes
0a0483b2ce trivial: Add a write_firmware() vfunc to FuDevice 2018-05-14 17:07:20 +01:00
Mario Limonciello
86b3bcf8c9 ebitdo: Stop matching Nintendo Switch Pro VID/PID
Unfortuantely similar to ead5bf392 this is causing problems with
real Nintendo Switch controllers.
2018-05-07 09:22:12 -05:00