Commit Graph

4748 Commits

Author SHA1 Message Date
Richard Hughes
0924c93422 Do not use firmware-convert to build firmware
Copying the images from the src to the destination meant we could never set
properties on the new FuFirmware instance or subclass.
2020-09-23 15:22:31 +01:00
Richard Hughes
d0b205887a Allow subclassing FuFirmwareImage->build() 2020-09-23 15:22:31 +01:00
Richard Hughes
9e96eb67c9 Allow building firmware with subclassed FuFirmwareImages 2020-09-23 15:22:31 +01:00
Richard Hughes
88dd7c4402 Add fu_firmware_image_get_bytes
Without a 'getter' it's impossible to obtain the raw data for the image
extractor or in a image subclass that wants to add a header or CRC.
2020-09-23 15:22:31 +01:00
Richard Hughes
c43208f3d6 Add fu_firmware_image_get_offset
This allows us to save the image file offset, rather than the destination
address and is really useful for debugging.
2020-09-23 15:22:31 +01:00
Richard Hughes
dd65344dde Add firmware-extract subcommand to fwupdtool 2020-09-22 12:11:38 +01:00
Richard Hughes
34f7d9d8fb Allow binding and unbinding kernel drivers 2020-09-21 20:07:54 +01:00
Richard Hughes
41400a8cc6 Allow contructing a firmware with multiple images
At the moment there are commands to convert one file format to another, but not
to 'merge' or alter them. Some firmware files are containers which can store
multiple images, each with optional id, idx and addresses.

This would allow us to, for instance, create a DfuSe file with two different
raw files that are flashed to different addresses on the SPI flash. It would
also allow us to create very small complicated container formats for fuzzing.

This can be used by writing a `firmware.builder.xml` file like:

   <?xml version="1.0" encoding="UTF-8"?>
   <firmware gtype="FuBcm57xxFirmware">
     <version>1.2.3</version>
     <image>
       <version>4.5.6</version>
       <id>header</id>
       <idx>456</idx>
       <addr>0x456</addr>
       <filename>header.bin</filename>
     </image>
     <image>
       <version>7.8.9</version>
       <id>payload</id>
       <idx>789</idx>
       <addr>0x789</addr>
       <data>aGVsbG8=</data>
     </image>
   </firmware>

...and then using something like:

   # fwupdtool firmware-convert firmware.builder.xml firmware.dfu builder dfu
2020-09-21 18:11:13 +01:00
Richard Hughes
f17db477eb Tag the FuFirmwareImage objects with the filename
For containers with multiple images it is sometimes very helpful to know what
file they've been loaded from. This would also allow us to 'explode' the
firmware container into seporate image files on disk.
2020-09-21 18:11:13 +01:00
Richard Hughes
9a1e8e44e0 uefi: Fix critical warning regression with 'fwupdate -a'
Set the ESP when creating the device with a known GUID.

Fixes https://github.com/fwupd/fwupd/issues/2406
2020-09-21 17:00:12 +01:00
Richard Hughes
366805e18e Add the missing fu_firmware_image_parse()
We provided the FuFirmwareImage->parse() vfunc, but did not provide any way to
actually call it...
2020-09-21 06:58:05 +01:00
Richard Hughes
7ef2dea271 optionrom: Test if the PCI device has ROM in probe
This means we make things a simpler by not relying on udev to stat the file.
It also reduces the number of added *unused* GUIDs by one per device too.
2020-09-20 19:11:44 +01:00
Richard Hughes
b9ef4399c9 Remove unused udev rules
We used these before we had the quirk files, and now with all the VLI devices
supported in the quirk files these entries do nothing at all.
2020-09-20 19:11:44 +01:00
mendel5
75810207dc flag_require_ac: System requires external power source 2020-09-20 12:08:52 -05:00
mendel5
f75ff42613 flag_require_ac: System requires external power source 2020-09-20 12:08:52 -05:00
mendel5
923d01b840 flag_require_ac: System requires external power source 2020-09-20 12:08:52 -05:00
Richard Hughes
0d37a9a93a bios: Only warn about CSM when using i?86 or x86_64
We're telling people on PPC64 to switch to UEFI mode...
2020-09-18 13:57:36 +01:00
Richard Hughes
6da96cd04a Add FuFirmwareFlags to allow opt-in dedupe of added images
The function fu_firmware_add_image() has the comment text 'If an image with the
same ID is present it is replaced' which has not been true for some time.

This was removed, as the common case of adding two images with no ID would only
leave one. However, some plugins do actually want to dedupe on the ID or IDX,
so provide a flag they can set which enables this functionality without
introducing regressions into other plugins.
2020-09-17 20:49:01 +01:00
Mario Limonciello
fbd3508655 trivial: correct some documentation typos 2020-09-17 13:51:59 -05:00
Richard Hughes
0038b4a780 Allow plugins to match using the SUBSYS IDs
This is the same format specified by Microsoft in "Identifiers for PCI Devices"
https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-pci-devices
2020-09-17 15:25:26 +01:00
Mario Limonciello
88f0d422ec uefi: correct a logic error in TPM PCR reading (Fixes: #2382)
069449e tried to avoid issues with all zero TPM PCR's, but caused
a problem with any byte was zero.
2020-09-15 14:38:52 -05:00
Mario Limonciello
7fc7da3999 thunderbolt: set install parent first flag for WD19TB
This is only applicable for kernel 5.9 or kernels that backported
the authenticate on disconnect patches.

For installation time this isn't very important since no device will
restart.  This also isn't relevant for the authenticate on disconnect
scenario.
However the manual activation scenario, it's important to activate the
WD19TB device first, followed by Thunderbolt.
2020-09-14 11:28:55 -05:00
Mario Limonciello
0f057d227b thunderbolt: if calling activate always use nvm_authenticate (#2374)
This will force the update to complete on logout or shutdown
2020-09-14 11:28:55 -05:00
Mario Limonciello
02085a0371 trivial: rework fwupdtool activate
Only use the history database to tell if activation should be run.
Instead query the connected devices to find the ones needing activation.

This should allow non-connected devices to not cause a failure (although
it might be a longer shutdown).

Also sort the devices, so that the order follows the defined order from
the daemon and they activate in the same order they install.
2020-09-14 11:28:55 -05:00
Richard Hughes
32173430d4 elantp: Only match the I2C adaptor on the correct laptop model
I2C doesn't have any specification for what is a probe and what is a more
destructive action. Sending tx_buf out on the i2c bus to a generic address
might not be safe in all cases.

To prevent this, use a HWID to check the machine DMI value during device
creation before ->probe() or ->setup() is called on the device.
2020-09-14 16:19:45 +01:00
Richard Hughes
ad32b0c17e elaptp: Allow recovery when the HID firmware fails to load 2020-09-14 16:19:45 +01:00
Richard Hughes
1d633a58fe trivial: Show the device GType when deduping
This allows us to make sense of the case where the same plugin has multiple
possible GTypes.
2020-09-14 16:19:45 +01:00
Richard Hughes
a06a480904 trivial: Allow using fu_udev_device_pread_full() at offset zero
Do not enforce the port is nonzero when reading and writing to a device.
2020-09-14 16:19:45 +01:00
Richard Hughes
13bae744be platform-integrity: Use the BCR values provided by the kernel class
This requires the new kernel driver by Daniel Gutson.
2020-09-14 16:18:12 +01:00
Richard Hughes
81f9552095 Correctly order devices when using logical parents
If the device parent is added using fu_device_add_parent_guid() or ParentGuid
from a quirk file then the child is not returned in fu_device_get_children() by
design as the physical ID will be likely different.

This means we cannot reliably 'depsolve' the order in FuDevice as we need the
full list of devices that might be parents. The existing algorithm had several
logical problems when dealing with more than a single parent and child.

The FuDeviceList object is the right place to do this as it knows about all
added devices on the system.

This means the addition of a logical device causes the root logical device
(and all it's children, and grandchildren) to be re-ordered. This allows
firmware on deeply nested composite devices like hubs to be installed in the
correct order.
2020-09-14 10:13:33 -05:00
Richard Hughes
b7fbb07dcb trivial: Convert the device order to an unsigned int
This allows us to set the parent of an existing parent without wrapping.
2020-09-14 10:13:33 -05:00
Richard Hughes
a1ebcbf743 trivial: Add back the hidden --plugin-whitelist option
It is essentially part of our 'CLI API' and we have to support people using the
old name.
2020-09-14 09:58:46 -05:00
Richard Hughes
5c82b94322 Do not show HSI obsoleted attributes by default
When one result is obsoleted by another, then do not show the old result by
default.

Additionally hide the HSI URLs as this was designed more for GUI clients like
gnome-firmware than CLI tools such as fwupdmgr.
2020-09-14 09:58:46 -05:00
Mario Limonciello
6a1a49eaef dell-dock: mirror updatable flag into thunderbolt
This makes sure that if an update is pending (as stored in the EC), Thunderbolt
won't show in a needing update state again.

Fixes: #2374
2020-09-11 14:08:32 -05:00
Mario Limonciello
258177472f trivial: debian/rules: disable flashrom for ia64 2020-09-11 13:58:11 -05:00
Mario Limonciello
76cc23c736 thunderbolt: make sure that authorized to add updatable flag
If the device is not authorized, it may cause a composite update that it's part
of to not behave properly.

If device is authorized at runtime, add updatable flag at runtime as well
See #2374 for more details
2020-09-11 13:15:51 -05:00
Mario Limonciello
c756405529 trivial: thunderbolt: fixup retimer setting physical ID twice
Only needs to be set once in probe.
2020-09-11 13:15:51 -05:00
Mario Limonciello
6d0c4897e1 fu-udev-device: call rescan on the device for change events
This allows calling the correct method, and instead doesn't have
all the plugins try to process the event when they're missing
vfuncs
2020-09-11 13:15:51 -05:00
Mario Limonciello
6d23514fb1 Revert "fu-plugin: add a new udev_device_changed function that calls rescan"
This reverts commit 096e3cfbb6.
2020-09-11 13:15:51 -05:00
Mario Limonciello
eb4472a479 trivial: debian: add udisks2 to recommends
(Closes: #970054)
2020-09-10 17:31:10 -05:00
Jochen Sprickerhof
25b78a6870 Check returned volumes before accessing them
Without udisks2 installed the list of volumes is empty and fwupdtool
esp-list segfaults.
2020-09-10 17:29:35 -05:00
Mario Limonciello
4550cf51f8 trivial: stop creating sysfs-path metadata
This isn't needed anymore, it was only for legacy thunderbolt3 controllers
that didn't support native enumeration.
2020-09-10 12:42:14 -05:00
Mario Limonciello
64f3857751 thunderbolt: ignore non-updatable host controller (Fixes: #2373)
nvm_version will not export in Intel USB4 host controller running in
SW CM, there is no point in fwupd displaying a device for it.
2020-09-10 12:42:14 -05:00
Richard Hughes
8541a874f0 synaptics-cxaudio: Fix the topology of the audio device on the TR dock
This ensures we perform the updates in this order:

* cxaudio
* vli
* thunderbolt

As any other order causes enumeration failures.

Fixes some of https://github.com/fwupd/fwupd/issues/2377
2020-09-10 17:14:08 +01:00
Daniel Campello
0b74e2c91a thunderbolt: Call fu_device_set_physical_id() during probe for retimer
Error will show up if (priv->physical_id == NULL) on
fu_device_ensure_id(). This method is called after probe but before
setup on fu_device_open.

Call fu_device_set_physical_id() on fu_thunderbolt_device_probe()
for the retimer case.

Fixes https://github.com/fwupd/fwupd/issues/2371

Change-Id: I0e462fff5e8abf6073318f6424b6736afc8259b8
2020-09-09 17:33:18 -05:00
Richard Hughes
8c200a9e41 cpu: Correct the BCR address for Atom Bay Trail 2020-09-09 20:18:32 +01:00
Richard Hughes
db344d5a40 trivial: Fix several small memory leaks discovered with valgrind 2020-09-09 14:16:49 -05:00
Richard Hughes
50ff31de56 Fix memory unsafety when using fu_engine_get_remotes()
When using fwupdtool that runs a mainloop we can get into the state where the
inotify watch fires on the remote directory as we're iterating on the list of
remotes.

This corrupts the list and we start reading freed objects. Return a deep copy
so we can safely update each remote.
2020-09-09 14:16:49 -05:00
Richard Hughes
fb6315f1c6 trivial: Show the failing remote when using 'fwupdtool refresh' 2020-09-09 14:16:49 -05:00
Richard Hughes
49b911f094 nvme: Do not dedupe NVMe devices
Fixes https://github.com/fwupd/fwupd/issues/2366
2020-09-09 16:27:16 +01:00