Commit Graph

74 Commits

Author SHA1 Message Date
Richard Hughes
b02872cbea trivial: Add two unrecoverable error codes to all USB devices 2020-03-28 12:46:03 +00:00
Richard Hughes
00e43fe50e trivial: Allow using NULL as func for fu_device_add_possible_plugin()
This should be used when a device recovery is not possible.
2020-03-28 12:46:03 +00:00
Richard Hughes
89a5ed01ef trivial: Add fu_device_retry_set_delay() to set a generic device delay 2020-03-28 12:46:03 +00:00
Richard Hughes
348719f759 Add fu_device_retry() helper functionality
Sometimes plugins need to retry various commands send to hardware, either due
to unreliable transfers (e.g. using USB bulk) or from slightly quirky hardware.

Between them they seem to get various things wrong; either the error messages
are repeated and thus difficult to parse, or they just get the memory handling
of `g_propagate_prefixed_error()` wrong.

Providing sane helpers we can reduce the amount of boilerplate. Additionally
we can support a 'reset' function that can try to automatically recover the
hardware for specific error domains and codes.
2020-03-27 15:47:08 +00:00
Richard Hughes
184baf6f4a trivial: Partially revert some of 464eacdc
The FuUsbDevice was using a locker of NULL to indicate unlocked, and just
calling `fu_device_locker_close()` does not unset the object.
2020-03-27 13:21:47 +00:00
Richard Hughes
464eacdc53 libfwupdplugin: Use fu_device_locker_close() 2020-03-26 15:23:10 -05:00
Richard Hughes
a1882f8c4b Add fu_device_locker_close()
This allows us to manually close the locker, allowing proper error handling.
2020-03-26 15:23:10 -05:00
Richard Hughes
754d85e282 ccgx: Set the update message when running in backup firmware 2020-03-24 21:16:08 +00:00
Richard Hughes
69b761ce64 trivial: Export fu_device_add_instance_id_full() for plugins to use
Sometimes we only want to add the instance ID to get the quirk matches, and it
is confusing to see the "fake" IDs in the 'fwupdmgr get-devices' output.
2020-03-24 14:43:31 +00:00
Richard Hughes
cff23f798f trivial: Autodetect the HID interface to use 2020-03-24 08:34:16 -05:00
Richard Hughes
d5aab65f30 Use Jcat files in firmware archives and for metadata
A Jcat file can be used to store GPG, PKCS-7 and SHA-256 checksums for multiple
files. This allows us to sign a firmware or metadata multiple times (perhaps
by the OEM and also then the LVFS) which further decentralizes the trust model
of the LVFS.

The Jcat format was chosen as the Microsoft catalog format is nonfree and not
documented. We also don't want to modify an existing .cat file created from WU
as this may make it unsuitable to use on Windows.

More information can be found here: https://github.com/hughsie/libjcat
2020-03-23 19:55:12 +00:00
Richard Hughes
1ae456c49c trivial: Show the expected size when HID reads or writes were truncated 2020-03-23 13:40:34 +00:00
Richard Hughes
c04f5a3e15 Add FuHidDevice abstraction
Quite a few plugins use HID commands to communicate with the hardware. At the
mement we have ~6 implementations of SET_REPORT and are soon to add one more.

Move this into common code.
2020-03-19 17:02:07 +00:00
Richard Hughes
c134451aeb trivial: Fix up a private function name that was missed 2020-03-19 06:43:42 +00:00
Richard Hughes
86febb681b trivial: Fix a typo when calling fu_firmware_image_add_string() 2020-03-18 18:57:06 +00:00
Richard Hughes
4f0e344a0a Ensure that the DeviceID is set for child devices
If we do not ->open() the device (e.g. because it uses a parent device to proxy
writes) then the child never gets a DeviceID which causes all kinds of issues.
2020-03-10 17:09:13 +00:00
Richard Hughes
51b4a1666e Add fu_device_get_root() shared API
This gets the 'topmost parent' for a composite device, as devices such as hubs
may have more logical layers than just one.
2020-03-10 17:09:13 +00:00
Richard Hughes
03d4675511 Do not add blank lines when tokenizing Intel hex files 2020-03-10 15:07:58 +00:00
Mario Limonciello
243785c8c9 trivial: improve error message on version format guessing 2020-03-06 13:00:59 -06:00
Mario Limonciello
49519a4b03 trivial: improve version format guessing for hex 2020-03-06 13:00:59 -06:00
Mario Limonciello
c8bae2a68c Introduce a new VersionFormat for hex
When CPU microcode is distributed it typically is versioned in
hexadecimal in all tools.  Converting it to any of the existing version
formats provides an unexpected result that requires converting back to
hexadecimal.
2020-03-06 08:12:58 -06:00
Mario Limonciello
b87d48a042 When TPM PCR0 measurements fail, query if secure boot is available and enabled
If the measurements are missing but it's a UEFI system, it's a good indication
that the user has secure boot turned off.
Notify the user on the UEFI device through a non-fatal `UpdateMessage`

To accomplish this, move fu-uefi-vars into the plugin library for other plugins to use
2020-03-05 07:54:15 -06:00
Mario Limonciello
663ac20909 trivial: update libfwupdplugin map for symbol backported to 1_3_X 2020-03-04 10:58:10 -06:00
Mario Limonciello
96117d19df trivial: 1.3.9->1.4.0
We decided to branch at 1.3.8 and backport fix only things for 1_3_X.
So bump all the new stuff to 1.4.0 (which will be next release)
2020-02-28 10:17:56 -06:00
Daniel Campello
227cefb74f Use xb_builder_source_add_simple_adapter
Use xb_builder_source_add_simple_adapter instead
xb_builder_source_add_adapter to avoid sniffing MIME type for output xml
contents

Signed-off-by: Daniel Campello <campello@chromium.org>
Change-Id: I123c37339720b5844351f85a5aeb9cec4928785c
2020-02-27 19:01:28 +00:00
Richard Hughes
c6eb416fd5 Create FuCabinet and untangle a lot of legacy code
Replace fu_common_cab_build_silo() with an actual GObject that can hold parsing
state. This cleans up the code a lot, and means we can add additional
functionality in the future without breaking ABI or API.

The long term plan is to verify the metadata and payload signatures when
parsing FuCabinet, rather than much later in _check_requirements().
This of course requires passing in a keyring context (which we don't yet have)
and would mean we can stop setting the various confusing 'fwupd::ReleaseBlob'
XbNode extra data.

No logic changes for now, just a lot of moving things into sane places.
2020-02-27 18:06:26 +00:00
Richard Hughes
b097603800 Allow server metadata to set the version format on some devices
It appears just choosing 'if Dell then QUAD else TRIPLET' isn't good enough.
2020-02-26 15:45:40 +00: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
Mario Limonciello
c1776c9ad4 Add raw versions for bootloader and lowest
The assumption is that same version format is used for all 3 of these
versions.
2020-02-25 12:20:51 +00:00
Richard Hughes
8d919b3acb Remove support for GCab less than v1.0
We can fall back to the subproject version if required for CI targets.
2020-02-24 12:33:44 +00:00
Richard Hughes
5337a43802 trivial: Fix the comparison function in fu_plugin_get_config_value_boolean() 2020-02-21 12:04:32 +00:00
Richard Hughes
9a68084dbc Always check for PLAIN when doing vercmp() operations
In 1de7cc we checked the version format when checking for update, but there are
many other places that are doing verfmt-insensitive comparisons. For instance,
the predicates in <requires> all fail if the device version format is plain.
his breaks updating some NVMe drives where the `ne` requirements are not
semantic versions.

To avoid trying to catch all the bugs in different places, and in case we have
a future verfmt that should be treated another way, refactor this out in to a
common function and deprecate the old function.
2020-02-20 15:49:27 +00:00
Richard Hughes
334ba7994c trivial: Add helper fu_plugin_get_config_value_boolean() 2020-02-20 14:55:10 +00:00
Richard Hughes
0f66a0236e Add a plugin vfunc to run after subclassed FuDevice creation
Sometimes the plugin will want to influence the subclassed device, for instance
by reading a per-plugin config file. At the moment there's no way to do this,
as even _device_registered() is explicitly designed for devices *not* created
by the plugin itself.

Even if _device_registered() was changed to include the plugin creating the
object it would still happen well after the device has done _probe() and/or
_setup() and would probably be too late to do anything useful.
2020-02-19 19:29:14 +00:00
Richard Hughes
234ee64509 Allow specifying a list of subsystems when setting a physical ID
Sometimes we want to fall back to a different subsystem entirely.
2020-02-12 17:15:28 +00:00
Richard Hughes
390fc1ad28 trivial: Get the physical ID for the drm_dp_aux_dev subsystem too 2020-02-12 17:15:28 +00:00
Richard Hughes
7ba76b0b01 trivial: Correctly set up the weak ref when using a GObject 'parent' property
This fixes a critical warning when adding MSP devices.
2020-02-11 12:59:27 +00:00
Richard Hughes
4eb7cec24b trivial: Fix memory leak if fu_device_set_parent() is called multiple times 2020-02-11 12:58:37 +00:00
Richard Hughes
08fd6e9179 trivial: Include the device subsubsystem in the physical ID error message
We check for this, so it makes sense to show it in the list of possibilities.
2020-02-11 11:19:14 +00:00
Richard Hughes
c49a2aea88 trivial: Make the &HUB_ instance 16 bits wide for SuperSpeed devices 2020-02-11 11:17:34 +00:00
Richard Hughes
07a41b992e Add an extra instance ID to disambiguate USB hubs
In some hardware there are two identical USB hubs with different firmware.
One is upstream, and one is downstream, making up to 7 user-available ports.

Use the 'removable' bitfield to target the proper firmware to the correct
device, on the logic that the setting will be different on upstream (removable)
and downstream (non-removable, as on the same PCB) hubs.
2020-02-10 14:58:38 -06:00
Mario Limonciello
9dce1f7011 Detect kernel lockdown status
Disable superio when kernel lockdown in effect.
2020-02-04 10:08:25 -06:00
Richard Hughes
47862828e1 trivial: Allow setting an ID of NULL for the FuFirmwareImage
There's no reason to prevent NULL, and doing so means the caller has to check
before setting the value. Only one subclassed type was actually doing this...
2020-01-16 11:24:55 -06:00
Richard Hughes
21eaeeff8d trivial: Fix up some typos found using codespell 2020-01-14 12:25:41 +00:00
Richard Hughes
af14073522 Allow applying all releases to get to a target version
Some hardware does not handle upgrading from version 1.2.2 to 1.2.4 and instead
needs to be upgraded from 1.2.2->1.2.3->1.2.4 so that on-device metadata can be
migrated correctly.

Add a new per-device flag `install-all-releases` which causes the daemon to not
skip directly to the newest release. This is designed to be set from a quirk
file.

This can obviously only be used for devices that can apply firmware "live" and
thus do not need a reboot or system shutdown to actually apply the firmware.
This also needs the cabinet archive to ship multiple versions of the firmware,
and for the metainfo.xml file to refer to multiple release objects.
2020-01-07 15:33:12 +00:00
Richard Hughes
63b9ac8844 Don't always get the vendor ID for udev devices using the parent
Fixes bugs like https://github.com/fwupd/fwupd/issues/1673
2020-01-06 14:48:58 +00:00
Richard Hughes
7f765005e2 Add a runtime warning when adding a device without an vendor-id or protocol set
Also, allow setting the protocol in the quirk file if required.
2020-01-06 14:48:32 +00:00
Richard Hughes
cb543afe6f trivial: Fix some GtkIntrospection issues 2020-01-02 12:52:51 +00:00
Mario Limonciello
695cb5884b libfwupdplugin: Make sure systemd created environment variables exist
If they don't, fall back to the package defined directories.
2019-12-12 13:23:13 -06:00
Richard Hughes
dad3597e76 Allow other plugins to contribute report metadata 2019-12-06 15:05:16 +00:00