Commit Graph

71 Commits

Author SHA1 Message Date
Richard Hughes
89d45a0d91 trivial: Standardize on introspection for @error and @cancellable
Also standarize on `Returns:` for the result.
2021-04-28 16:19:50 +01:00
Richard Hughes
d94286b9de Allow enabling plugins only matching a specific HwId
At the moment plugins are doing this a few different ways; either looping
through the HwIds manually (e.g. flashrom) or setting a custom flag that is
checked in fu_plugin_setup (e.g. uefi-recovery).

Define a standard 'Plugin' HwId quirk to simplify plugins.
2021-03-02 18:19:45 +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
cf100293b5 Do not export useless device attributes to the client
That giant uint64_t isn't looking so big now, and we'll want to add even more
to it in the future. Split out some private flags that are never useful to the
client, although the #defines will have to remain until we break API again.
2021-01-06 14:36:23 +00:00
Richard Hughes
3252573ac7 synaptics-prometheus: Fix flashing a fingerprint reader that is in use
The fprint daemon only keeps the device open for 5 seconds and then releases it,
which seems like a small window to hit.

But! We're asking the user to authenticate with the same device we're about to
upgrade so a different part of the stack woke up the hardware just before we're
about to deploy an update onto it.

Just retry a few times to make sure the device is idle. Use a flag to prevent
accidentally causing regressions in other plugins.

Fixes https://github.com/fwupd/fwupd/issues/2650
2021-01-04 21:52:10 +00:00
Richard Hughes
3e445ece04 Allow components to set the icon from the metadata
In this case, we want to set the generic ESRT entry to have the icon 'battery'.
2020-11-06 16:57:21 +00:00
Mario Limonciello
c3a8173a12 Show an error when a plugin is missing dependencies (Fixes: #1526)
```
$ sudo mv /usr/lib/x86_64-linux-gnu/libtss2-esys.so.0.0.0 /usr/lib/x86_64-linux-gnu/libtss2-esys.so.0.0.0.renamed
$ sudo fwupdtool get-devices --plugins=uefi
14:15:48:0735 FuEngine             cannot load: failed to open plugin /usr/local/lib/x86_64-linux-gnu/fwupd-plugins-3/libfu_plugin_uefi.so: libtss2-esys.so.0: cannot open shared object file: No such file or directory
Loading…                 [-                                      ]14:15:48:0753 FuEngine             failed to update history database: device ID b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2 was not found
Loading…                 [***************************************]
WARNING: Plugin depdendencies missing
No detected devices
```
2020-10-20 10:57:21 -05:00
Richard Hughes
7bcb8d4385 Export FwupdPlugin so we can convey enumerated system errors to the end user
For instance, we can tell the user that UEFI UpdateCapsule is disabled in the
system firmware, or that efivarfs is not mounted. This is much better than
creating "dummy" devices which are really just hacks around the problem because
no better API existed. THe dummy devices cause as many problems as they solve.

Plugins have to set FWUPD_PLUGIN_FLAG_USER_WARNING if a warning should be shown
to the user, and only one warning will be shown of each failure type.

It is expected that GUI clients like gnome-software and gnome-firmware would use
this API to notify the user the localized message for why firmware updates are
not being shown.

Fixes https://github.com/fwupd/fwupd/issues/2456
2020-10-13 15:56:49 +01:00
Richard Hughes
1a61258239 Allow devices to save the old firmware to disk for recovery
This would also help, for example, to go back to the nonfree firmware when the
alternate firmware did not work as well as hoped. It would also allow flashing
the firmware using an SPI programmer if everything went very wrong indeed.
2020-09-30 18:33:00 +01:00
Richard Hughes
460c4b75fe Add the concept of firmware 'branches'
This allows a device to identify with different streams, for instance a Lenovo
laptop could have a coreboot firmware or a AMI firmware. The GUIDs would be the
same, but switching firmware would only be done rarely and very carefully.

Another example would be switching the Broadcom BCM57xx nework adaptors from the
vendor nonfree firmware with a signed PXE image, to the free software reverse
engineered driver with no PXE support (and thus no signed DXE) at all.

It is expected firmware would have additional metadata something like this:

    ...
    <branch>sdcc</branch>
    <description>
      <p>
        This is an alternate firmware built by the community using only free
        software tools.
      </p>
    </description>
    <requires>
      <id compare="ge" version="1.5.0">org.freedesktop.fwupd</id>
      <client>switch-branch</client>
    </requires>
    ...

Additionally, alternate branch firmware will not be returned for clients not
setting the FWUPD_FEATURE_FLAG_SWITCH_BRANCH before the GetReleases request.
2020-09-30 18:33:00 +01:00
Mario Limonciello
fbd3508655 trivial: correct some documentation typos 2020-09-17 13:51:59 -05:00
Richard Hughes
df89cd566e Allow firmware to require specific features from front-end clients
At the moment we just blindly assume the capabilities of the front-end client
when installing firmware. We can somewhat work around by requiring a new enough
fwupd daemon version, but the client software may be older or just incomplete.

This would allow, for instance, the firmware to specify that it requries the
client to be able to show a detach image. This would not be set by a command
line tool using FwupdClient, but would be set by a GUI client that is capable
of downloading a URL and showing a PNG image.

Clients that do not register features are assumed to be dumb.
2020-06-27 15:43:57 +01:00
Mario Limonciello
768a2680a6 Introduce a new flag skips-restart
This flag is used internally by plugins to indicate that they will
skip the phase of firmware installation that power cycles a device.

It is intended to be set by quirks or other environment settings.
2020-05-06 15:13:40 -05:00
Richard Hughes
8500b4f233 Allow devices to be updatable, but only when upgrading a proxy device 2020-04-18 14:39:43 +01:00
Richard Hughes
86ae91c144 Add a device quirk that forces an explicit device-id match
This means we do not do the GUID or counterpart GUID matching when adding
devices. Only an exact device-id match or when both the physical and logical
IDs match will the device be considered the 'same'.

This is to handle devices that could share the same GUIDs in both child and
parent modes where the logical ID differs.
2020-04-17 21:48:59 +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
52c1a4d38e Export the release urgency
Show it in the various command line tools if it has been set by the vendor.
2020-04-02 13:22:07 +01: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
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
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
f43381f4a7 Allow server metadata to set the device name on some devices
This does 'bleed' the metadata contents into areas previously covered by quirks,
but in this case may be pragmatic and more up to date than a build-time
generated quirk file, which increases the user-friendliness of fwupdmgr.
2020-02-24 14:15:34 +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
1eb7c7443e Allow quirking devices that always require a version check
These are devices that we have to be careful with the version numbers, for
instance only updating from versions that have already had data migration
completed.

The new flag can be set in quirk files or on the objects directly.
2020-01-07 12:29:28 +00:00
Richard Hughes
f1a7122250 Add a dell-bios version format
Dell does not include the first byte in the ESRT value, ignoring it. Using a
`quad` means we get versions like `0.1.4.0` rather than `1.4.0` which confuses
both users comparing versions to the vendor website, and also anyone trying to
do analysis on the firmware.
2019-12-04 16:22:46 +00:00
Richard Hughes
5272cfc63d Add versions formats for the Microsoft Surface devices
Apparently there are yet more ways to encode a 32 bit number...
2019-11-07 21:34:09 +00:00
Mario Limonciello
97c1e727c4 Add new device flags indicating update resilience
fwupd clients will ideally use this information as part of a policy to schedule
updates in the background without user interactions on safe devices.
2019-10-17 11:38:46 -05:00
Mario Limonciello
8fa0b382fa Add new flags can-verify and can-verify-image
These are used to indicate that the device can verify checksums or
can dump an image for checksumming.
2019-10-14 12:41:09 -05:00
Mario Limonciello
e1b4d8ebcd Add a new device flag for indicating device won't come back
Devices like this can't be verified that the version was updated
until they're manually put into the correct mode by the user.
2019-10-12 14:07:34 -05:00
Richard Hughes
d8a8d5e776 Set all FuUdevDevice plugins to use FU_QUIRKS_PLUGIN
This speeds up startup as we're only calling fu_plugin_udev_device_added() on
plugins that can actually handle the device.
2019-10-09 20:02:16 +01:00
Mario Limonciello
3be596b907 fu-util/fu-tool: Better display historical information
* When firmware has been modified use the device key "Previous version"
  instead of "Current version".
* Show release as a child node when looking at history
* Don't output empty flags for release
* Use the key "New version" for releases

Sample output from `get-history`
```
├Integrated Webcam™:
│ │   Device ID:           08d460be0f1f9f128413f816022a6439e0078018
│ │   Previous version:    1.2.2
│ │   Update State:        success
│ │   Flags:               updatable
│ │   Last modified:       2019-09-20 14:53
│ │   GUID:                b585990a-003e-5270-89d5-3705a17f9a43
│ │
│ └  New version:       1.2.3
│
└Integrated Webcam™:
  │   Device ID:           08d460be0f1f9f128413f816022a6439e0078018
  │   Modified version:    1.2.2
  │   Update State:        success
  │   Flags:               updatable
  │   Last modified:       2019-09-20 14:53
  │   GUID:                b585990a-003e-5270-89d5-3705a17f9a43
  │
  └  New version:       1.2.4
```

Sample output from `get-updates`
```
Integrated Webcam™:
  │   Device ID:           08d460be0f1f9f128413f816022a6439e0078018
  │   Summary:             A fake webcam
  │   Current version:     1.2.2
  │   Previous Version:     1.2.0
  │   Bootloader Version:  0.1.2
  │   Vendor:              ACME Corp. (USB:0x046D)
  │   Flags:               updatable|supported|registered
  │   GUID:                b585990a-003e-5270-89d5-3705a17f9a43
  │
  ├FakeDevice Firmware:
  │     New version:       1.2.4
  │     Remote ID:         fwupd-tests
  │     Summary:           Firmware for the ACME Corp Integrated Webcam
  │     License:           GPL-2.0+
  │     Size:              17 bytes
  │     Vendor:            ACME Corp
  │     Flags:             is-upgrade
  │     Description:       Fixes another bug with the flux capacitor to prevent time going backwards.
  │
  └FakeDevice Firmware:
        New version:       1.2.3
        Remote ID:         fwupd-tests
        Summary:           Firmware for the ACME Corp Integrated Webcam
        License:           GPL-2.0+
        Size:              17 bytes
        Vendor:            ACME Corp
        Flags:             is-upgrade
        Description:       Fixes a bug with the flux capacitor to avoid year 2038 overflow.
```
2019-09-20 16:02:55 -05:00
Richard Hughes
94422f651e Only force a semver when the device opts-in
This is only used by one, so-far out-of-tree plugin. Reduce complexity by not
using the version format to decide if we're forcing a semver.
2019-04-30 09:25:41 +01:00
Richard Hughes
c84b36c541 Export the version-format to clients
This allows a vendor to verify the VersionFormat of a device without running
the daemon in verbose mode.
2019-04-30 09:25:41 +01:00
Richard Hughes
cce6a1cb5a Do not report transient failures
We don't need to report failures to do with AC or battery level to the LVFS.
2019-04-17 08:20:44 +08:00
Richard Hughes
8dd4c1c4dd Allow restricting firmware updates for enterprise use 2019-03-05 19:05:07 +00:00
Richard Hughes
8e0cc802fe Show the upgrade and downgrade flags when getting releases for a device
This allows us to one day implement 'reinstall', allows us to have a more useful
`get-releases` command and also means we can add other reasons for blocking the
release in the future.
2019-03-04 15:11:36 +00:00
Richard Hughes
245885ca1f Rename FwupdRelease:trust-flags to FwupdRelease:flags
In the future we'll want to use this flag to signify if the release is an
upgrade, downgrade, below the version-lowest, or if it is locked in some way.
2019-03-04 13:55:31 +00:00
Mario Limonciello
96a0dd5606 Add a support for delayed activation
This is intended for devices that it is not safe to immediately activate
the firmware.  It may be called at a more convenient time instead.

Both fwupdmgr and fwupdtool support the feature.

- if called at runtime with fwupdmgr it uses the daemon
- during shutdown fwupdtool uses the pending.db to perform this feature.
2019-02-27 09:04:54 +00:00
Richard Hughes
1bc432316a Defer the InstanceID->GUID hashing until after setup
This allows hardware from OEMs to *not* match generic firmware supplied by the
device manufacturer. The idea being, that the OEM will supply firmware that
will actually work on the device.

Based on a patch from Mario Limonciello, many thanks.
2019-02-06 08:02:16 +00:00
Richard Hughes
5297678d3c Allow a plugin to set _ANOTHER_WRITE_REQUIRED to run more than one plugin
For this to work with different plugins the device IDs must match.
2019-02-04 14:54:54 +00:00
Richard Hughes
f803964e37 Add _NEEDS_SHUTDOWN flag for devices
Some devices require the system to be powered down and back up, rather than
just being "warm" rebooted.
2019-01-17 16:35:34 +00:00
Richard Hughes
75b965d01d Shut down the daemon after 2h of inactivity
Plugins are allowed to 'opt-out' of this behaviour using _RULE_INHIBITS_IDLE.
This should be used where waking up the hardware to coldplug is expensive,
either from a power consumption point of view, or if other artifacts are going
to be seem -- for instance if the screen flickers when probing display devices.

This functionality is also inhibited when the actual upgrade is happening,
for obvious reasons.

Admins can turn off this auto-sleep behaviour by editing the daemon.conf file.

Fixes https://github.com/hughsie/fwupd/issues/417
2018-11-21 18:54:44 +00:00
Mario Limonciello
9c3a6fd60f Add a new device flag "ignore-validation" that will override validation checks
This flag isn't really intended for production, but more for development
to allow setting a quirk for a device during a transition period.
2018-09-05 08:03:28 -05:00
Richard Hughes
3a8d532855 Allow the device list to take care of waiting for the device replug
This means that individual plugins do not have to manage thier own GUsbDevice
lifecycle and no longer have to call g_usb_context_wait_for_replug().
2018-08-31 16:41:40 +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
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
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
9f86ade6bf Allow plugins to define the order composite firmwares are installed 2018-05-12 20:46:02 +01:00
Richard Hughes
fbf17e9c85 Allow devices to use the runtime version when in bootloader mode
Some devices like the Nitrokey use a generic DFU bootloader that reports a
version number unrelated to the version number of the runtime. Add a flag so
that we can set the correct version when switching plugins during detach and
attach.
2018-02-16 18:23:07 +00:00
Richard Hughes
ad54f65f05 Add FWUPD_DEVICE_FLAG_NOTIFIED
This allows us to record whether we've shown the user a notification (either in
the terminal or in a GUI) that an update failed or was successful.

This can't be done in the session otherwise we'd get a notification for every
different user on the system. Notifying also isn't the same as reporting,
although one can certainly follow on from the latter.
2018-02-01 14:01:18 +00:00
Richard Hughes
d0d2c8b84e trivial: Add FWUPD_DEVICE_FLAG_REPORTED
This flag is present in the history database when a report has been uploaded.
2018-01-11 10:18:37 +00:00