Commit Graph

41 Commits

Author SHA1 Message Date
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Mario Limonciello
798d1ed3ee trivial: update markdown for pre-commit style 2021-07-18 14:42:47 -05:00
Richard Hughes
bf72d393fd Split up FuUsbDevice into ->open() and ->setup()
Before this change calling FuUsbDevice->open() opened the device, and
also unconditionally added various GUIDs and InstanceIDs which we
normally do in setup.
Then fu_device_setup() would call the FuSubclass->setup() vfunc which
would have no way of either opting out of the FuUsbDevice->setup()-like
behaviour, or controlling if the parent class ->setup is run before or
after the subclass setup.

Split up FuUsbDevice->open() into clear ->open() and ->setup() phases
and add the parent class calls where appropriate.

This means that ->setup() now behaves the same as all the other vfuncs.
2021-06-17 16:21:41 +01:00
Mario Limonciello
73cdf067ed trivial: fixup includes for a variety of plugins 2021-06-14 10:12:45 +01:00
Richard Hughes
ddc40ab595 fastboot: Add some trivial error prefix for the getvar failure 2021-05-12 10:10:57 +01:00
Richard Hughes
faa35e430b Show a warning if the device has no GType and the plugin has no default
This also renames a symbol to make it clear that you can call it more than once.

Fixes https://github.com/fwupd/fwupd/issues/3148
2021-04-15 16:52:56 +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
7d132b728c Simplify the quirk file format
The best way of not getting something wrong is to not require it in the first
place...

All plugins now use DeviceInstanceId-style quirk matches and we can just drop
the prefix in all files. We were treating HwId=, Guid= and DeviceInstanceId= in
exactly the same way -- they're just converted to GUIDs when building the silo!
2021-03-03 08:30:34 +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
a22c13c637 Move the plugin build logic to the plugins themselves 2021-02-18 14:46:20 +00:00
Richard Hughes
9b11af985f Add fu_memdup_safe()
See https://mail.gnome.org/archives/desktop-devel-list/2021-February/msg00000.html
for more details.
2021-02-04 21:01:00 +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
Mario Limonciello
75835b4a0b Use FWUPD_COMPILATION define to indicate an in tree build
When this is done, include:
* Including the hash
* Including anything that is not ABI stable in plugins yet

Suggested-by: Simon McVittie <smcv@debian.org>
2021-01-22 14:01:25 -06:00
Mario Limonciello
8aa5d41eb7 Add external interface messages 2020-10-26 12:05:20 -05:00
Richard Hughes
0164141f9b trivial: Fix incorrect comment text 2020-06-19 10:59:16 +01: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 Hughes
0cc22a5ff6 trivial: Document the use of vendor-id in each plugin 2019-12-11 18:10:44 +00:00
Mario Limonciello
6b0e66354b Convert libfwupdprivate to a shared library libfwupdplugin 2019-11-27 11:32:43 +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
6abe21efbd trivial: stop including fu-hash.h as part of fu-plugin-vfuncs.h
Explicitly include it in all "in-tree" plugins.

If headers are exported out of tree we will likely explicitly not
export this header.
2019-11-25 09:29:46 +00:00
Richard Hughes
6e55cff444 fastboot: Fix a regression when updating modem firmware
Set `IS_BOOTLOADER` unconditionally when in fastboot mode. This seems logically
what it is; a degraded mode that's able to update firmware without runtime
functionality.

Fixes https://github.com/fwupd/fwupd/issues/1532
2019-11-05 06:04:36 -06:00
Richard Hughes
8653e70480 trivial: Remove G_BEGIN_DECLS from all private headers 2019-10-09 20:02:16 +01:00
Richard Hughes
731875af86 Remove FU_PLUGIN_RULE_REQUIRES_QUIRK as all the plugins now use it 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
4b30380e78 Provide a default implementation of common FuDevice actions
This reduces the amount of boilerplate in each plugin.

    32 files changed, 156 insertions(+), 584 deletions(-)
2019-10-04 14:57:32 +01:00
Richard Hughes
6e3e62bee8 Use fu_common_string_append_kv() in subclassed device
Also define the indent level in the the ->to_string vfunc so we can correctly
print client devices in all cases.
2019-08-14 16:48:37 +01: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
dce91204c9 Fix some typos spotted using codespell 2019-04-08 12:47:53 +01:00
Richard Hughes
bfd946e463 Use '#pragma once' to avoid a lot of boilerplate 2019-02-09 08:42:30 -06:00
Aleksander Morgado
0f0da353c2 fastboot: Use a much longer timeout as the removal delay
A device that has gone through a fastboot update may need more than
the previous default of 10s to come back up. Just use a much longer
value to make sure it's detected properly.

Signed-off-by: Richard Hughes <richard@hughsie.com>
2019-02-01 10:26:43 +00:00
Richard Hughes
b9b6834f54 trivial: Add FuFastbootDeviceReadFlags to fu_fastboot_device_cmd() 2019-01-30 12:14:17 +00:00
Aleksander Morgado
046c84b5b3 fastboot: flash the partition after downloading the file 2019-01-30 12:14:17 +00:00
Richard Hughes
4fef28d0ac trivial: Add the missing protocol IDs to the plugin READMEs 2019-01-29 22:28:09 +00:00
Richard Hughes
f425d29a28 Show a console warning if loading an out-of-tree plugin
Fixes https://github.com/hughsie/fwupd/issues/950
2019-01-19 07:26:20 +00:00
Richard Hughes
0e17e6d030 Fix building with -Wl,-z,defs
This allows us to find undefined references at compile time, not runtime.
2018-12-25 16:10:54 -06:00
Richard Hughes
9729584ee4 Allow plugins to define support for a 'well-known' protocol
Future metadata from the LVFS will set the protocol the firmware is expected to
use. As vendors love to re-use common terms like DFU for incompatible protocols,
namespace them with the controlling company ID with an approximate reverse DNS
namespace.

This also allows more than one plugin to define support for the same protocol,
for instance rts54hid+rts54hub and synapticsmst+dell-dock.
2018-12-14 18:15:01 +00:00
Richard Hughes
b4fd12a4c6 Add a plugin to update hardware that supports fastboot 2018-12-03 15:50:38 +00:00