Commit Graph

624 Commits

Author SHA1 Message Date
Mario Limonciello
6d1afc3e87 trivial: reformat all python code with black 2021-04-08 10:43:29 -05:00
Richard Hughes
4d76d18d35 Set the system battery state and level on the FuContext shared state
This allows plugins to set the battery power state of the *machine* which means
we can automatically inhibit devices with FWUPD_DEVICE_FLAG_REQUIRE_AC set.

It also allows to set the BatteryThreshold to 25% for Lenovo hardware, and we
can override other vendors with further quirks as required.

Fixes https://github.com/fwupd/fwupd/issues/3084
2021-04-07 08:05:15 +01:00
Mario Limonciello
0f50a3186c Add a new internal flag for whether or not to inherit activation
The activation flag is stored into the history database, but not all
plugins will want to inherit it on coldplug the next time the daemon
is started.

For example the Dell Dock plugin will query this information from the
device and it will prevent getting into a bad state as a result.
Fixes: #3106
2021-04-06 14:09:12 -05:00
Richard Hughes
776a0890fe srec: Make FuIhexFirmware derivable for possible future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Richard Hughes
7f7e4437fc ihex: Make FuIhexFirmware derivable for future use
An ABI change, so probably not a good idea to backport.
2021-04-06 14:54:39 +01:00
Richard Hughes
edcca6d1d7 Do not show a GType failure when using fwupdtool
If only one plugin is enabled and there exists a device match for a GType that
has not been registered then the user sees a GType error about not being able
to create a device that wouldn't be created anyway.

By removing the error in the quirk parser we will catch actual errors in
fu_plugin_runner_backend_device_added() which actually does chcek for
FWUPD_PLUGIN_FLAG_DISABLED.

Fixes https://github.com/fwupd/fwupd/issues/3099
2021-04-02 21:52:55 +01:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
Richard Hughes
0d4255b589 vli: Remove deprecated quirk prefixes 2021-04-01 18:40:14 +01:00
Richard Hughes
c6569eff67 Remvoe the unused fu_plugin_set_coldplug_delay() 2021-04-01 16:01:06 +01:00
Richard Hughes
4ae7b5e837 Remove the unused fu_plugin_recoldplug() 2021-04-01 16:01:06 +01:00
Richard Hughes
250f30ceb9 trivial: Remove more deprecated API because we can
We bumped soversion, so lets clean up the API.
2021-04-01 13:12:45 +01:00
Richard Hughes
a3b8515e51 trivial: Inhibit when the *device* power is below the threshold 2021-03-31 19:19:46 +01:00
Richard Hughes
74ac5ab86d trivial: Add fu_device_remove_flag() as a proper symbol
This allows us to automatically uninhibit() like we do in fu_device_add_flag().
2021-03-31 19:19:46 +01:00
Richard Hughes
b9ac0bc029 Add fu_device_inhibit() to mark the device as non-updatable
We already have two things managing the UPDATABLE_HIDDEN->UPDATABLE transition,
and we're about to add a third.

Add a 'stackable' inhibit-style API so we do not accidentally mark a device as
updatable when it should remain hidden.
2021-03-31 19:19:46 +01:00
Richard Hughes
62a8b0c288
Add fu_device_set_battery_threshold() (#3086)
This allows a device to set a custom 'check battery level is X%' value from
either the plugin or from a quirk.
2021-03-31 16:43:36 +01:00
Richard Hughes
dd61689073 Add fu_device_add_security_attrs() 2021-03-28 17:54:19 +01:00
Richard Hughes
790cb8fea2 ihex: Dectect address overflow causing the fuzz process to take along time
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32302
2021-03-21 20:18:34 +00:00
Richard Hughes
c8423fd685 ihex: Do not allow zero-sized data sections 2021-03-21 20:18:34 +00:00
Richard Hughes
69016bda04 ihex: Do not allow data sections after EOF 2021-03-21 20:18:34 +00:00
Richard Hughes
d4ad7cef71 trivial: Print the ASCII data in FuFirmware->to_string() 2021-03-21 20:18:34 +00:00
Richard Hughes
9c318a5a08 trivial: Fix 32 bit overflow in fu_common_get_memory_size()
Spotted by Coverity, thanks!
2021-03-20 17:32:56 +00:00
Norbert Kamiński
76e19930a8 fwupd port for BSD distros
Signed-off-by: Norbert Kamiński <norbert.kaminski@3mdeb.com>
2021-03-19 17:05:09 +00:00
Richard Hughes
a5966f7085 trivial: Codespell fixes 2021-03-19 16:42:33 +00:00
Richard Hughes
119d260bd2 trivial: Limit alignment to 2GB to fix a fuzzing crash
This meant defining alignment values in FuFirmware.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32131
2021-03-17 11:14:46 +00:00
Richard Hughes
f4d3a365f1 fmap: Use standard FuFirmware properties 2021-03-15 12:07:30 +00:00
Richard Hughes
52441f28a4 Allow objects to deserialize to XML
This makes a lot more sense; we can parse a firmware and export the same XML
we would use in a .builder.xml file. This allows us to two two things:

 * Check we can round trip from XML -> binary -> XML

 * Using a .builder.xml file we can check ->write() is endian safe
2021-03-15 12:07:30 +00:00
Richard Hughes
408b056984 trivial: Use fu_byte_array_append_bytes() in more places 2021-03-15 09:46:02 +00:00
Richard Hughes
1ad1458caf dfu: Allow setting the DFU version
The 'version' shadows the variable of the same name in the FuFirmware subclass.
2021-03-15 09:46:02 +00:00
Richard Hughes
664226a350 spi: Move all the IFD parsing to the new 'spi' plugin
We do not want to export this unfinished API, and it's probably best just to
not compile it by default until it is actually useful.
2021-03-15 09:45:17 +00:00
Richard Hughes
1c0ed3ab1d srec: Detect overflow to avoid adding ~4GB of 0xFF padding
Fixes https://oss-fuzz.com/testcase-detail/5468114109202432
2021-03-14 09:50:39 +00:00
Richard Hughes
752c8de149 trivial: Fix up gtk-doc comment for fu_firmware_set_size() 2021-03-13 16:23:26 +00:00
Richard Hughes
d2cdfcdb95 trivial: Fix up gtk-doc for fu_firmware_parse() 2021-03-13 16:09:35 +00:00
Richard Hughes
d27bfc08fd srec: Fix a fuzzing failure when trying to build zero sized firmware 2021-03-11 15:48:02 +00:00
Richard Hughes
88969d10c4 srec: Actually include the address in the written data 2021-03-11 15:48:02 +00:00
Richard Hughes
74db340d93 trivial: Add fu_byte_array_align_up() for future usage 2021-03-11 15:47:13 +00:00
Richard Hughes
8f63180ed0 trivial: Add fu_firmware_get_size()
The idea here is to return the size of the firmware, including the header,
footer or other encapsulation. It would be expected that this value would
include the alignment if provided.
2021-03-11 10:23:26 +00:00
Richard Hughes
7c0560c37f srec: Add support for writing firmware 2021-03-10 21:39:01 -06:00
Richard Hughes
db38dca4c8 trivial: Only print the FuFirmware version once... 2021-03-10 19:21:39 +00:00
Richard Hughes
58d52ede18 trivial: Add fu_common_align_up() for future usage 2021-03-10 17:06:57 +00:00
Richard Hughes
55853e3f2d trivial: Add fu_firmware_get_alignment()
I need this from two different FuFirmware superclasses, and I think it makes
sense in the base object.
2021-03-10 16:13:39 +00:00
Richard Hughes
e9664e8448 trivial: Add fu_byte_array_append_bytes() helper 2021-03-10 14:01:11 +00: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
2d84386034 Remove unused, unsafe and deprecated functions from libfwupdplugin
Keeping *internal* API and ABI compatibility makes working with an already
complex codebase more mentally demanding than it needs to be.

Remember: plugins should be in-tree and upstream! If your out of tree plugin
stops working then it should be upstream.

The public-facing libfwupd will remain API and ABI stable for obvious reasons.
2021-03-09 15:47:56 +00:00
Richard Hughes
aaf74006da trivial: Fix up the Since tags for FuIfd
This was not included in the 1_5_X branch.
2021-03-09 15:35:29 +00:00
Richard Hughes
f2849d24cc Add missing uint64 read and write helpers 2021-03-05 19:34:54 +00:00
Richard Hughes
a76a0da7aa Add fu_device_set_battery_level()
We want to make it as easy as possible for devices to refuse to update on low
battery, as this will likely be one of the WWCB requirements.

Ideally devices will check the battery level inside the firmware, but by also
providing the battery level to fwupd we can give the user a warning *before*
the update has started and without switching the device into bootloader mode.
2021-03-05 12:27:10 +00:00
Richard Hughes
e19ebe7177 Add an Intel Flash Descriptor parser 2021-03-05 10:51:34 +00:00
Richard Hughes
32ffdb2677 Add helper API to write in a safer way 2021-03-05 09:34:18 +00:00
Richard Hughes
bf3732f994 pixart: Use the bluetooth UUID to set the logical ID
This means you can have more than one device attached to the same controller.
2021-03-03 15:36:42 +00:00
Richard Hughes
2ad99bb402 Relax fu_common_bytes_pad() to return the blob if longer than the pad size
This means the caller does not have to do this each time.
2021-03-03 14:29:29 +00:00
Richard Hughes
c81b755872 Be more strict for custom quirk keys
Rather than trying to guess typos, force each plugin to register the quirk
keys it supports, so we can show a sensible warning if required at startup on
the console.
2021-03-03 08:30:34 +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
Mario Limonciello
3df7dd3708 libfwupdplugin: don't allow device updates while needing activation 2021-03-03 07:32:35 +00:00
Richard Hughes
6122034a19 Show a warning when parsing invalid quirk files
I just wasted more than two hours of my life over `DeviceID`.
2021-03-02 06:31:55 +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
Ricardo Cañuelo
3ed91d52a4 Support for GATT characteristic signals/notifications
NOTE that currently this is implemented for GATT characteristics only,
but can be extended to other types of objects.

Listening for property changes in a bluez characteristic requires a
long-lived connection or proxy, so this also refactors bluez device
UUIDs into a simple object that keeps the path, the proxy and the signal
id in case a callback is registered for this UUID.

An additional advantage of this is that fwupd no longer creates a
throwaway proxy object for every read and write UUID operation.
2021-02-26 18:19:06 +01:00
Richard Hughes
0b6c67a3e3 trivial: Set the GError when calling ioctl() on an un-opened device
I've not yet worked out the real bug, but it was unexpected to crash the daemon
when open failed, rather than for a critical misuse of the API.
2021-02-25 16:21:56 +00:00
Richard Hughes
14c0f7c80e trivial: Fix the debug output for FuDevice 2021-02-25 15:47:25 +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
253e6e4f17 Add a backend ID to the device
This is typically a Linux sysfs path or USB platform ID and is used in a
different way to the physical ID. The physical ID is only set for some devices
after setup() and depends on the subsystem list, and this would not be defined
for devices that do not match a plugin.

This also fixes an regression where the FuDeviceList fails to match the new
FuUdevDevice device in fu_device_list_get_by_guids_removed() and instead
silently gets 'fixed up' only if FWUPD_DEVICE_FLAG_NO_GUID_MATCHING is not set.

This also allows us to move the various backends device caches to FuBackend as
we now have a suitable ID that is for just the backend to use.
2021-02-24 16:49:42 +00:00
Richard Hughes
53de7e25a4 trivial: Only allow verify-update for plugins that support _CAN_VERIFY
If the user explicitly specifies the device-id then we do not do the front-end
filtering. If the device detaches without being able to attach then the hardware
could be left in the bootloader state.

See https://github.com/fwupd/fwupd/issues/2926#issuecomment-784234180
2021-02-23 14:48:00 +00:00
Ricardo Cañuelo
01e87896f5 Fix GVariant declarations in fu_bluez_device_write
References to opt_variant and val_variant are sunk in a subsequent
variant creation and consumed by g_dbus_proxy_call_sync. They don't need
to be freed in this context.
2021-02-23 15:35:52 +01:00
Richard Hughes
61e4ff7684 trivial: Fix up two gtk-doc typos 2021-02-23 10:21:52 +00:00
Richard Hughes
edac3d7d3f trivial: Fix spelling of BlueZ in various places 2021-02-23 10:21:52 +00:00
Richard Hughes
ed0af24406 trivial: Use fwupd_device_remove_flag() to remove a single flag 2021-02-22 22:48:56 +00:00
Richard Hughes
a76de3279b Add a test BLE plugin for a demo 2021-02-22 16:53:41 +01:00
Ricardo Cañuelo
536fb85e21 Add initial support for Bluez bluetooth devices
Bare skeleton for what will be the Bluez backend and the base bluetooth
device class.
2021-02-22 16:53:41 +01:00
Richard Hughes
ad3cfc0fea Convert MBR types to GPT GUIDs to help find the ESP
Fixes https://github.com/fwupd/fwupd/issues/2916
2021-02-22 13:00:33 +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
86c6c2d4a3 Add fu_firmware_set_version_raw()
A few plugins need this now, so move it into the base class.
2021-02-16 15:24:29 +00:00
Ricardo Cañuelo
a92026476b Fix ioctl error checking
fu_udev_device_ioctl() interprets the return value of ioctl() as the
error cause and generates a misleading error message (permission
denied).
Fix it to use errno for error checking and reporting.
2021-02-15 16:39:00 +01:00
Richard Hughes
665c5feaca ihex: Never add more than 1 Intel hex signature
If you can create a 1Mb file with hundreds of thousands of zero-byte signatures
it takes a *long* time to parse the image.
2021-02-14 22:03:57 +00:00
Richard Hughes
ffbb1175d0 trivial: Do not consider all whitespace a valid strsafe string 2021-02-14 22:03:57 +00:00
Richard Hughes
a4e0de462c trivial: Fix AddressSanitizer heap-buffer-overflow 2021-02-14 22:03:57 +00:00
Richard Hughes
60a4b56802 srec: Fix an overflow causing an infinite loop when parsing 2021-02-12 20:51:39 +00:00
Richard Hughes
293ccbf106 fmap: Fix self test failure on PPC64 2021-02-12 10:47:34 +00:00
Richard Hughes
c3ecec575b fmap: Use memmem to find the FMAP signature
Trust glibc to optimize for the binary search, removing a oss-fuzz detected
crash with our bad pointer maths.
2021-02-11 20:27:20 +00:00
Richard Hughes
3ffc5baaad trivial: Also fuzz the CRC checking routines
At the moment these sections are all red in the coverage report.
2021-02-11 20:27:20 +00:00
Richard Hughes
220ec716ca trivial: Include firmware writing when fuzzing 2021-02-11 20:27:20 +00:00
Richard Hughes
54bc512388 Add firmware flags for presence of CRC and VID/PID 2021-02-11 20:27:20 +00:00
Richard Hughes
87a8091bed trivial: Fix a crash using fu_firmware_image_get_chunks()
Add a GError as it can return NULL for invalid circumstances. It's okay to
change the API as this symbol has not yet been in a tarball release.
2021-02-11 13:13:06 +00:00
Richard Hughes
9bb5d279db dfuse: Never add a DfuSe image with no defined chunks 2021-02-11 13:12:20 +00:00
Richard Hughes
7a23330158 dfu: Do not allow DfuSe chunk data to include the DFU footer area
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30813
2021-02-11 12:56:05 +00:00
Mario Limonciello
be220a4f56 trivial: fu-common: fix fallback for esp-path if udisks missing
Fixes: #2803
2021-02-10 11:58:37 -06:00
Richard Hughes
525f71f54b Merge the _udev_device() and _usb_device() vfuncs
There are now two 'backends' of device plug/unplug events, and there is about
to become three. Rather than just adding two more vfuncs for every backend type
define common ones that all providers can use.

Also fix up the existing in-tree plugins to use the new vfunc names and filter
on the correct GType.
2021-02-10 12:04:05 +00:00
Richard Hughes
9e9b73f303 Remove fu_plugin_get_usb_context()
It's unused, and only encourages plugins to do the wrong thing.
2021-02-10 12:04:05 +00:00
Richard Hughes
2e73bef923 Be more paranoid when parsing from ASCII buffers 2021-02-09 16:37:25 +00:00
Richard Hughes
6920eb1214 ihex: Fix a buffer-overread spotted by AddressSanitizer 2021-02-09 13:05:32 +00:00
Richard Hughes
abdc82b1c1 dfuse: Fix a buffer-overread spotted by AddressSanitizer 2021-02-09 13:05:13 +00:00
Richard Hughes
c123bee369 trivial: Fix a buffer-overread spotted by AddressSanitizer 2021-02-09 13:05:09 +00:00
Richard Hughes
01a30aa6de Add support for oss-fuzz 2021-02-08 09:17:03 +00:00
Richard Hughes
5294d0c7c0 trivial: Use g_memdup2() on new glib2 versions to avoid a warning 2021-02-05 09:50:02 +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
98972f4a34 libfwupdplugin: Promote DfuFirmware to FuDfuseFirmware
Port the DFU plugin to use the new objects to make it act the same as all the
other plugins.
2021-02-01 19:34:28 +00:00
Richard Hughes
77d333fab5 trivial: Allow building FuChunk objects from a XbNode 2021-01-29 18:39:53 +00:00
Richard Hughes
1d163528ab Add fu_firmware_new_from_gtypes() for future usage
This allows a plugin to define a 'set' of firmwares that it would find
acceptable, for instance either accepting DFU, DfuSe or just a plain binary.
2021-01-29 18:18:18 +00:00
Richard Hughes
9a241be490 trivial: Add fu_chunk_array_mutable_new()
This allows us to check that the plugin is writing into a mutable buffer. Also
fix up the plugins that are currently 'wrong' and use the new function for the
plugins doing the right thing.
2021-01-29 14:22:20 +00:00
Richard Hughes
451db0645b trivial: Use a more standard _to_string() for FuChunk 2021-01-29 14:22:20 +00:00
Richard Hughes
20e82cac46 Allow creating a FuChunk from a GBytes directly
This is a perfect object for when we want to just store a blob of data, address
and/or page.
2021-01-29 14:22:20 +00:00
Richard Hughes
bc8678ef13 trivial: Add three public 'setters' for FuChunk 2021-01-29 14:22:20 +00:00
Richard Hughes
318944f322 trivial: Use a more standard name for array of chunks 2021-01-29 14:22:20 +00:00
Richard Hughes
166c71df38 trivial: Check FuChunk is the correct GObject type 2021-01-29 14:22:20 +00:00
Richard Hughes
a3f8fc30ac Convert FuChunk from a C structure to an object 2021-01-28 17:41:46 +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
c75466751d trivial: Add fu_common_uri_get_scheme() for future use 2021-01-28 15:05:32 +00:00
Richard Hughes
382524d82f trivial: Fix potential crash when doing crazy things
Fix the asan crash when feeding the value back into itself, e.g

    fu_firmware_set_version (firmware, fu_firmware_get_version (firmware));
2021-01-28 14:13:59 +00:00
Richard Hughes
9e2cce9596 trivial: Correctly print PrivateFlags when using --verbose 2021-01-27 10:20:12 +00:00
Richard Hughes
d48e841f77 trivial: Fix up two gtk-doc problems 2021-01-27 09:54:14 +00:00
Richard Hughes
8e7a0dce4a trivial: Do not use deprecated symbols internally
This means shuffling things around a little, but no logic changes.
2021-01-26 14:25:56 +00:00
Richard Hughes
e52e1b49ad trivial: Add fu_common_strjoin_array() to join arrays of strings 2021-01-26 14:25:56 +00:00
Richard Hughes
b54d69467d Run the child setup when calling the parent device
If we're creating the child device using `Children=FuFooDevice|FOO&I2C_01` in
the quirk file then there's not actually anywhere to call FuDevice->setup()
on the child.

The logical place to do it is when we setup the parent, which is a NOP if
already called for the child. We also don't need to convert the child instance
IDs as it's already being handled during the child setup.

Tested-By: Ricky Wu <ricky_wu@realtek.com>
2021-01-25 18:23:28 +08:00
Mario Limonciello
e95c1b3bd5 trivial: fwupdplugin: install deprecated header as well 2021-01-22 14:01:25 -06: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
1313f23307 trivial: correct includes for fu-plugin.h
Needed for working "out of tree" compilation.
2021-01-22 14:01:25 -06:00
Richard Hughes
4d9b2d1233 Always return a valid semver from fu_common_version_ensure_semver()
Return NULL if not valid, and handle tilde and dash where required.
2021-01-19 11:56:32 +00:00
Richard Hughes
f6751cd783 Allow using custom data to generate CHIDs
This is really useful when working out HwId quirk values for remote systems.

    fwupdtool export-hwids target.hwids
    vim target.hwids
    fwupdtool hwids target.hwids
2021-01-18 07:56:34 +00:00
Richard Hughes
667a7b41e3 Add GUIDs straight away if ->setup() has already been called
We only convert the instance IDs to GUID after setup() has been called, which
means if we add even more instance IDs to the device in functions like
fu_plugin_device_registered() they never actually get converted to the GUID
form too.
2021-01-15 15:00:22 +00:00
Richard Hughes
68175e9ba8 Use a quarter of the RAM size as the archive maximum
It is impossible to choose a static default that is appropriate for both a tiny
ARM IoT device and a giant Xeon server.

Fixes https://github.com/fwupd/fwupd/issues/2760
2021-01-14 22:36:38 +00:00
Richard Hughes
97ad335e4b Fix OOM when using large ArchiveSizeMax values
Read from the file descriptor in 32kB chunks rather than allocating a huge
buffer upfront.
2021-01-14 22:36:38 +00:00
Richard Hughes
68ab1e44fd trivial: Add fu_plugin_get_devices() for general plugin use 2021-01-14 21:13:38 +00:00
Richard Hughes
faf2afed02 trivial: Rename the device cache store with a better name 2021-01-14 21:13:38 +00:00
Richard Hughes
1a3d3b338e Make GUsb optional for fuzzing 2021-01-14 14:23:12 +00:00
Richard Hughes
5add3a75dd Make libarchive optional for fuzzing 2021-01-13 20:12:37 +00:00
Richard Hughes
dd0159dc00 trivial: Remove excess #include 2021-01-13 20:06:08 +00:00
Richard Hughes
6c48e67d6c trivial: Make name optional in fu_efivar_exists() 2021-01-13 09:14:26 +00:00
Richard Hughes
ffb6f91f95 trivial: Add fu_efivar_get_monitor() to allow inotify of efivars 2021-01-13 09:14:01 +00:00
Richard Hughes
b19e05156e trivial: Allow plugins to call fu_plugin_remove_flag() 2021-01-13 09:13:12 +00:00
Mario Limonciello
797da4fc60 trivial: adjust error for no UEFI capsules
Point people towards firwmare setup instead (Fixes: #1454)
2021-01-12 12:56:05 -06:00
Richard Hughes
7a9d9e3aa3 trivial: Fix a critical warning when updating ColorHug 2021-01-11 09:44:26 +00:00
Richard Hughes
fdb3a83a20 uefi-dbx: Ignore the legacy OVMF dummy GUID for the version
This was changed recently in https://sourceforge.net/p/edk2/code/29270/
2021-01-08 14:54:31 +00:00
Richard Hughes
21f4cb5d95 trivial: Add one more missing <string.h> 2021-01-07 18:15:31 +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
b63cfa90d6 Detect the AMD TSME encryption state for HSI 2021-01-06 16:45:33 +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
647ec9677e trivial: Do not show unprintable text when parsing invalid SREC firmware 2021-01-06 10:08:45 +00:00
Richard Hughes
b28e325339 trivial: Fix a buffer over-read when parsing corrupt SMBIOS data 2021-01-06 10:08:45 +00:00
Mario Limonciello
9a6692eb84 Notify plugins of their own registrations
The Thunderbolt plugin wasn't actually working properly for
`DelayedActivation` because Thunderbolt devices weren't actually registered.

This only affected ChromeOS.
2021-01-06 09:11:00 +00:00
Richard Hughes
5c9e9f17c5 libfwupdplugin: Export FuEfiSignatureList for plugins to use 2021-01-05 16:42:58 +00:00
Richard Hughes
cba9020eae trivial: Fix a buffer over-read when parsing invalid SMBIOS data 2021-01-05 15:59:30 +00:00
Richard Hughes
338cab9e73 libfwupdplugin: Subclass FuFirmware in FuSmbios
This allows us to get fuzzing support for free.
2021-01-05 15:59:30 +00:00
Richard Hughes
8c6bfffe2a trivial: Don't crash in the fuzzer for NULL input
The daemon already checks this, but the fuzzer just blindly flings the buffer
to each parser.
2021-01-05 15:59:30 +00:00
Richard Hughes
4bd5450c03 Fix a critical warning when parsing invalid Intel HEX firmware 2021-01-05 15:59:30 +00:00
Richard Hughes
ebb10a5c4a trivial: Fix a tiny memory leak when using fu_plugin_add_firmware_gtype() 2021-01-05 15:59:30 +00:00
Richard Hughes
364e2685ca Do not show unprintable chars from invalid firmware in the logs 2021-01-05 15:15:07 +00:00
Richard Hughes
ac927583a3 libfwupdplugin: Allow getting images by checksum value 2021-01-05 14:45:31 +00:00
Richard Hughes
eddaed0c11 Allow specifying more than one VendorID for a device
Asking the user for the UID mapping isn't working very well, as it requires lots
of manual handholding. It also doesn't work very well when the device vendor
does not actually have a PCI ID or if the vendor has split into two entities.

Just use the OUI address as an additional VendorID and match any of the device
IDs against any of the metadata-supplied values.
2021-01-04 22:30:20 +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
64e9f6bd92 trivial: Fix up some NULL/FALSE confusion 2021-01-04 16:32:50 +00:00
Richard Hughes
9f71fe3dc9 Make the 'id' for fu_plugin_add_firmware_gtype() optional
We can work out the correct value automatically in all cases but one, and it's
less for the plugin author to get wrong...
2021-01-04 15:27:10 +00:00
Richard Hughes
2e5c1d15bc Do not hardcode building shared libraries
Respect the -Ddefault_library meson define.
2021-01-04 15:26:28 +00:00
Richard Hughes
6a489a9eaf trivial: Add missing calls to g_return_val_if_fail() 2021-01-04 15:24:35 +00:00
Richard Hughes
a2abc42760 libfwupdplugin: Use G_GNUC_WARN_UNUSED_RESULT for methods that should be checked 2021-01-04 15:24:35 +00:00
Mario Limonciello
ed4e9123c6 trivial: libfwupdplugin: don't fail to set up bwrap if /lib64 doesn't exist
Fixes: #2690
2020-12-16 07:56:09 +00:00
Richard Hughes
9d20bf9212 Do not trust the Block.HintSystem boolean for ESP filtering
Instead use it for preferential selection. If there is none it's okay, but if
there are 3 pick the one with the flag.

Fixes https://github.com/fwupd/fwupd/issues/2676
2020-12-15 15:42:13 +00:00
Richard Hughes
e3fb2e45cd trivial: Fix two more missing <string.h> instances 2020-12-14 20:24:04 +00:00
Richard Hughes
4ab347ec78 trivial: Do not use g_file_load_bytes() in the self tests
This is not available in older GLib versions.
2020-12-14 20:24:01 +00:00
Richard Hughes
a14de30153 trivial: Require <string.h> for strlen() and memcpy() 2020-12-14 16:49:03 +00:00
Richard Hughes
db8533f743 trivial: Don't accidentally depend on GLib 2.54.3
None of these branches are important enough to provide fallbacks for.
2020-12-14 15:33:00 +00:00
Richard Hughes
e5074cdbbb trivial: Fix compiling without GUdev 2020-12-14 11:34:43 +00:00
Richard Hughes
72df114793 fmap: Do not assume FuFmapArea.name is NUL terminated 2020-12-11 14:33:50 +00:00
Richard Hughes
fdea9336a6 fmap: Make mixed-endian safe 2020-12-11 14:33:50 +00:00
Richard Hughes
8b99d4f2ec fmap: Use fu_memcpy_safe() to prevent buffer over-read 2020-12-11 14:33:50 +00:00
Richard Hughes
531b8b417f fmap: Fix a critical warning when the FmapArea has zero size 2020-12-10 20:43:54 +00:00
Richard Hughes
f3539621ee ihex: Do not dump binary out to the terminal for corrupt files 2020-12-10 14:58:11 +00:00
Richard Hughes
976b6afe63 trivial: Allow turning off the FMAP binary search when fuzzing
This speeds up the fuzzing task from 22ms to 33us.
2020-12-09 18:08:08 +00:00
Richard Hughes
84617b6699 fmap: Allow writing and reading the image base 2020-12-09 18:02:07 +00:00
Richard Hughes
5771756f85 fmap: Allow creating test firmware from builder.xml 2020-12-09 18:02:07 +00:00
Richard Hughes
a9060f671c fmap: Correctly check minimum firmware size 2020-12-09 18:02:07 +00:00
Richard Hughes
05e3377d11 trivial: Add fu_common_bytes_new_offset()
This is a safer version of g_bytes_new_from_bytes() which returns a GError
if the offsets are invalid rather than emitting a critical warning.

This prevents a critical warning and potential crash when parsing invalid
bcm57xx firmware.
2020-12-08 20:54:25 +00:00
Richard Hughes
fa595a7334 libfwupdplugin: Do not overwrite GError when parsing invalid fmap 2020-12-08 20:32:21 +00:00
Richard Hughes
698099f643 trivial: Remove several unused variables 2020-12-08 20:06:46 +00:00
Philip Withnall
aa48b6b0e3 libfwupdplugin: Support new libxmlb query binding API
See https://github.com/hughsie/libxmlb/pull/67. This doesn’t bump the
hard version dependency.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-12-08 14:39:40 +00:00
Richard Hughes
0ec634e7db trivial: Codespell fixes 2020-12-07 20:55:18 +00:00
Richard Hughes
ab63e94107 Fall back to the misc device for serio devices 2020-12-03 10:58:38 +00:00
Richard Hughes
9d78383622 Actually implement rescan in FuUdevDevice
This allows the plugin to force a reload of the device using a new GUdevDevice
object. This is required as the values are cached in the immutable object.
2020-12-03 09:07:24 +00:00
Richard Hughes
6fca469737 trivial: Fix regression when using a custom GType
Although the fix in a21e025e46 is correct, we
also need to return TRUE higher up in the conditional.
2020-12-01 18:22:51 +00:00
Richard Hughes
d51f2ec939 trivial: Use DEVPATH for platform UDev devices 2020-12-01 14:15:33 +00:00
Richard Hughes
a21e025e46 trivial: Return with an error if the device GType is unclear
Returning TRUE means this is really hard to debug...
2020-12-01 14:15:33 +00:00
Richard Hughes
f8fc7de209 Fix a possible critical warning due to missing retval 2020-12-01 14:15:33 +00:00
Richard Hughes
3dbfc21171 trivial: Include the possible plugins in the FuDevice->to_string output 2020-12-01 14:15:33 +00:00
Richard Hughes
70aca476d7 Add the serio->firmare_id for UDev devices
If set, it is a device-specified InstanceID specifying the firmware stream.
2020-12-01 14:15:33 +00:00
Richard Hughes
7a63a4c41c Export the driver name from FuUdevDevice
We have to supply it when using fu_device_bind_driver(), so we need to get the
old value for ->attach() to avoid guessing what driver was previously loaded.
2020-12-01 14:15:33 +00:00
Richard Hughes
419c04c504 trivial: Show the subsystem when calling FuUdevDevice->to_string() 2020-12-01 14:15:33 +00:00
Richard Hughes
2bbb7d2b40 trivial: Merge some GtkDoc introspection fixes 2020-11-30 09:18:45 +00:00
Richard Hughes
4cbe99c607 Restrict loading component types of firmware
This would allow us to add other component types in the future, for instance a
'generic' type that adds information to the composite device.

Any generic components would need to have a requirement of 1.5.2 to avoid
showing a runtime warning when trying to get the local file details.
2020-11-29 07:06:29 +00:00
Richard Hughes
3a73c342ba Switch from libsoup to libcurl
The former drags on glib-networking and then gsettings-desktop-schemas, which
add over 5Mb to the minimal IoT and CoreOS composes. Everything already uses
libcurl (even NetworkManager!) and so this is an easy way to reduce image size.
2020-11-19 19:39:37 +00:00
Richard Hughes
05efd7b960 trivial: Don't assume a specific page size in the unit tests
This was found in the self tests on PPC64.

Fixes https://github.com/fwupd/fwupd/issues/2581
2020-11-15 09:17:08 +00:00
Mario Limonciello
56d816a53b Fall back to FAT32 internal partitions for detecting ESP
Fixes #2576
2020-11-12 13:42:21 -06:00
Richard Hughes
1b6d5e5085 trivial: Ignore failure to close USB device for a missing device 2020-11-07 19:51:45 +00:00
Richard Hughes
b4f8a5dc83 trivial: Ignore failure to release HID interface with a missing device 2020-11-07 19:51:45 +00:00
Richard Hughes
8c415e0568 trivia: Allow controlling HID kernel driver rebind 2020-11-07 19:51:45 +00:00
Richard Hughes
7bb9b1f6e8 trivial: Improve the debugging output for FU_HID_DEVICE_VERBOSE 2020-11-07 19:51:45 +00:00
Richard Hughes
a01fdde628 Allow setting global flags for FuHidDevice 2020-11-07 19:51:45 +00:00
Richard Hughes
01ba0c1eea Set the SMBIOS chassis type to portable if a DT battery exists
This allows getting the HSI result on a Pinebook Pro laptop.
2020-11-07 08:15:20 +00:00
Richard Hughes
e0f9207d3b trivial: Fix two introspection warnings 2020-11-06 09:57:03 +00:00
Richard Hughes
41a1650c2a Remove HSI update and attestation suffixes
The logic here is that the attestation is more than just the PCR0 value, and
multiple device firmware (such as EC, ME, etc.) needs to be included to validate
the system.

By the same logic, updates for the system firmware do not tell the whole story,
and confuse HSI as a specification. Remove them.
2020-11-05 15:12:12 +00:00
Richard Hughes
203ed841da trivial: Codespell fixes 2020-11-02 14:26:26 +00:00
Richard Hughes
0bdf561035 Use UDisks to find out if swap devices are encrypted
Using a heuristic is certainly not awesome.
2020-11-02 14:22:37 +00:00
Richard Hughes
2b188c8488 trivial: Export if the volume is encrypted
This requires passing in the udisks block proxy when creating the object.
2020-11-02 14:22:37 +00:00
Richard Hughes
f3993a6b96 trivial: Add GObject properties to FuVolume
This will allow us to add other properties in the future.
2020-11-02 14:22:37 +00:00
Richard Hughes
43417b2a95 trivial: Return GDBusProxy objects from fu_common_get_block_devices()
This allows us to reuse the GDBusConnection without passing it to all places a
new interface proxy is created.
2020-11-02 14:22:37 +00:00
Richard Hughes
c57a8f5726 trivial: Fix GtkDoc for fu_common_get_block_devices() 2020-11-02 14:22:37 +00:00
Richard Hughes
e612078b8d Remove the duplicate parent-child data in FwupdDevice and FuDevice
The FuDevice derives from FwupdDevice, and yet both objects have a (potentially
different) parent and set of children. This is super confusing, and just not
required.

Removing the duplication also removes a sizable memory leak when hotplugging
composite devices as the parent was ref'd by the child and the child was ref'd
by the parent in different objects... Fun to debug...
2020-10-31 13:19:11 +00:00
Richard Hughes
6d257cbe7f Fix probe warning for the Logitech Unifying device
The same plugin name was being added to the device from the quirk file more than
once, and so we enumerated the device *again* and tried to add a duplicate
device -- the device list correctly refusing to do so.

Check the plugin name does not already exist before adding it, and add a self
test to catch this for the future.
2020-10-27 15:43:17 +00:00
Richard Hughes
49c2a78c99 Include the amount of NVRAM size in use in the LVFS failure report 2020-10-27 13:58:40 +00:00
Richard Hughes
d9b97e308b Add a flag to retry the HID request up to 10 times
This is something that we now need in two plugins, so move it into common code.
2020-10-22 14:36:05 +01:00
Richard Hughes
a2a8f8ea70 Add fu_byte_array_set_size()
The GLib g_byte_array_set_size() function does not zero the contents if the
array size is larger, which leads to unpredictable output when using valgrind.
2020-10-20 19:54:07 +01: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
6a29672bc3 Do more processing when tokenizing the Intel HEX file 2020-10-20 16:27:15 +01:00
Richard Hughes
c7283ea61e uefi: Drop efivar dependency 2020-10-19 16:13:21 +01:00
Richard Hughes
f019971c00 redfish: Drop efivar dependency 2020-10-19 16:13:21 +01:00
Richard Hughes
81b5defaa6 uefi: Use fu_efivar_get_data() to fix setting BootNext correctly
Fixes https://github.com/fwupd/fwupd/issues/2169
2020-10-19 16:13:21 +01:00
Richard Hughes
377feea500 Only show the HSI for sane chassis types
Fixes https://github.com/fwupd/fwupd/issues/2440
2020-10-18 20:24:10 +01:00
Richard Hughes
9f93b8bc66 trivial: Add fu_smbios_get_integer() helper 2020-10-18 20:24:10 +01:00
Richard Hughes
f27e19beac Parse the HEX version before comparing for equality
This fixes the error: 'Update Error: device version not updated on success,
0x00000002 != 0x0002' -- it seems a bit crazy to have to specify 32 bits of
zero digits in the firmware.metainfo.xml
2020-10-13 15:57:03 -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
cc2f6aa1b2 Add fu_device_sleep_with_progress helper()
This makes the console a bit more helpful than just 'hanging'...
2020-10-11 07:34:00 +01:00
Érico Rolim
0651aeef24 Fix header names.
- <sys/poll.h> should be <poll.h>
- <sys/errno.h> should be <errno.h>
2020-10-10 12:33:56 +01:00
Mario Limonciello
5a83563701 uefi: Correct a logic error with FuVolume
Fixes: #2443
2020-10-08 09:16:32 -05:00
Richard Hughes
6450d0deb4 Add FwupdInstallFlags of _IGNORE_CHECKSUM, _IGNORE_VID_PID and _IGNORE_POWER
The FWUPD_INSTALL_FLAG_FORCE flag has really unclear semantics, and ignoring a
file CRC, checksum or model ID should only be done when using fwupdtool actually
debugging a plugin or firmware parser.

Use the existing --force flag when we want a "gentle nudge" like reuploading
previously processed reports.
2020-10-07 13:15:09 +01:00
Richard Hughes
ad69dbbe48 trivial: Fix 'returning FALSE in a pointer function' warning 2020-10-05 22:13:51 +01:00
Mario Limonciello
39bd45f4f7 trivial: don't show quirk directories skipped 2020-10-03 06:58:13 -05:00
Richard Hughes
7d1267fd84 Clarify various parts of the HSI specification
Firsly, that HSI isn't expected for embedded devices and then secondary how we
require SecureBoot to be available for HSI:1

At the moment we get a runtime failure if it is disabled. Making SB a part of
`HSI:1` makes this requiremnt explicit and prevents us getting `HSI:2!` if it
is not available.
2020-10-02 09:13:56 +01:00
Richard Hughes
10c3fd2ff9 Support loading DMI data from DT systems
To do this with the existing codebase just fake the required SMBIOS structures.
2020-09-30 19:22:45 -05: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
2865b61991 trivial: don't show messages about missing version format
This is a plugin error, it shouldn't be in logs constantly for history
devices while plugins load
2020-09-28 15:58:53 -05:00
Mario Limonciello
d4155ff673 trivial: fu-common: don't mention making directories unless they don't exist 2020-09-28 15:58:53 -05:00
Mario Limonciello
67a8b89453 trivial: clean up some debugging statements 2020-09-28 15:58:53 -05:00
Richard Hughes
33dcfb7219 trivial: Remove over-eager debugging output 2020-09-28 16:43:12 +01:00
Richard Hughes
c46aa815ea trivial: Do not show the libxmlb debugging by default 2020-09-28 16:43:12 +01:00
Richard Hughes
496fb826f1 trivial: Add fu_udev_device_get_number() 2020-09-26 12:20:41 +01:00
Richard Hughes
44ae2a75e4 trivial: Add CRC8 as well 2020-09-25 18:00:21 +01:00
Richard Hughes
6f5e35a3ea Add common CRC routines
We have quite a few versions of CRC in-tree, and are about to get two more...
2020-09-25 17:52:43 +01:00
Richard Hughes
f02571b3f3 Use the 'real' hardware class for virtual classes like net 2020-09-25 13:25:52 +01:00
Richard Hughes
de9be2d34c trivial: Correctly set subsystem when using _VENDOR_FROM_PARENT 2020-09-25 13:25:52 +01:00
Richard Hughes
3e9fafcc6f Add fu_firmware_remove_image() 2020-09-24 10:54:27 -05:00
Richard Hughes
fbd8b5d325 Add fu_device_dump_firmware()
Conceptually we were trying to stuff subtly different actions into one vfunc:

 * Read firmware from the device to update the verification checksums

 * Read a firmware blob from the device for debugging

For the first action we might want to mask out the sections of the flash with
serial numbers (so the verification hashes match the ones published on the LVFS)
and for the second we want just a raw ROM file from the hardware with no
pre-processing that we can compare against an external SPI dumper.

Split out ->dump_firmware to get the raw blob, and allow plugins to also
implement ->read_firmware() if they have to mask out specific offsets or remove
specific images from the FuFirmware container.

In the common case when masking is not required, fall back to using a 'binary'
FuFirmware automatically to make most plugins simpler.
2020-09-24 10:54:27 -05:00
Richard Hughes
6b5926ca59 trivial: Fix two warnings in the win32 build 2020-09-24 09:19:15 +01:00
Richard Hughes
88d80119d1 trivial: Document the firmware build XML format 2020-09-23 15:22:31 +01:00
Richard Hughes
aff64d3e75 trivial: Allow specifying zero-sized data sections
This can be done using '<data/>' to specify a zero-sized image.
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
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
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
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