Commit Graph

73 Commits

Author SHA1 Message Date
Mario Limonciello
4ff6a6dedb trivial: flashrom: Add SPDX license header
Clarify that the license was intended to be LGPL2.1 when the project
adjusted and this source file was just missed as well.
2021-08-08 14:43:21 -05:00
Mario Limonciello
798d1ed3ee trivial: update markdown for pre-commit style 2021-07-18 14:42:47 -05:00
Peter Marheine
000ee9696c flashrom: remove PS175 support
This is now implemented by the parade_lspcon plugin.
2021-07-14 06:40:38 +01:00
Richard Hughes
dfaae2e837 Move amdgpu safety check into the plugin
There are now multiple plugins using drm_dp_aux_dev interface which
may potentially be combined with an amdgpu. Prevent exercising this
interface with any plugin using DP aux unless a new enough kernel is
installed.
2021-07-04 17:49:36 +01:00
Mario Limonciello
73cdf067ed trivial: fixup includes for a variety of plugins 2021-06-14 10:12:45 +01:00
Richard Hughes
88eef48f36 trivial: Use g_memdup2() on newer GLib versions 2021-04-23 13:59:28 -05:00
Peter Marheine
72a273e0ff flashrom/lspcon: probe for actual active partition
While the flag bytes in Flash on the PS175 indicate which partition it is
desired the device boot, the device may actually boot something else
because it performs some kind of integrity check on firmware images before
booting them. If the image specified by the flag bytes fails validation,
the device instead boots partition 3 which should be treated as read-only.

The device provides a register on I2C that indicates which partition is
actually running, so probe that register rather than assuming the device
is running the image that the flag bytes specify.

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2021-04-23 07:03:49 +01:00
Peter Marheine
a8e9802271 flashrom/lspcon: make flash layout non-global
Having a mutable global flash layout makes it difficult to reason about which
flash regions will be affected by any given flashrom operation. Make copies of
the layout from a template instead, and default-exclude regions from
operations.
2021-04-23 07:03:49 +01:00
Richard Hughes
a87440947d flashrom: Do not attempt to change the physical ID after setup() 2021-04-22 15:37:24 +01:00
Richard Hughes
08aeda737a flashrom: Remove the call to fu_plugin_cache_add() as it is not required
This also means we don't need to lazy-create the GHashTable either.
2021-04-20 15:09:58 +01:00
Richard Hughes
4a156deee2 flashrom: Do not add GUID manually
It's just not requried; fu_device_add_instance_id() does this at the right time.
2021-04-20 15:09:58 +01:00
Richard Hughes
378aceae7d flashrom: Never add NULL instance IDs
Probably fixes half of https://github.com/fwupd/fwupd/issues/3156
2021-04-20 15:09:58 +01:00
Richard Hughes
759c0d49e2 flashrom: Make using fu_flashrom_device_set_programmer_name() more safe 2021-04-20 15:09:58 +01:00
Richard Hughes
2f1f218a36 flashrom: Remove unused parent_instance struct member 2021-04-20 15:09:58 +01:00
Richard Hughes
faa35e430b Show a warning if the device has no GType and the plugin has no default
This also renames a symbol to make it clear that you can call it more than once.

Fixes https://github.com/fwupd/fwupd/issues/3148
2021-04-15 16:52:56 +01:00
Daniel Campello
ff51287628 REVERT: flashrom/lspcon: avoid parsing sysfs paths
Reverts 53c61754b3

https://review.coreboot.org/c/flashrom/+/51967 has not landed yet nor
the equivalent change in Chromium OS flashrom fork. This revert fixes
the breakage until that happens.
2021-04-15 08:21:09 -06:00
Peter Marheine
53c61754b3 flashrom/lspcon: avoid parsing sysfs paths
sysfs paths don't have strong guarantees about semantics, so attempting
to parse an I2C bus number out of a sysfs path of some device is likely
to be fragile. Instead take advantage of the device layout to find the
I2C bus an LSPCON is on without trying to parse it out of paths.

The bus the device is on is a sibling device of type i2c-dev, so by
locating an i2c-dev device that is a sibling of the detected LSPCON
device, the /dev path of the bus can be found robustly.

Support for specifying an I2C bus by path rather than number is also
required in flashrom, implemented at
https://review.coreboot.org/c/flashrom/+/51967

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2021-04-15 06:53:06 +01:00
Daniel Campello
3426d5788c flashrom: lspcon-i2c-spi: add reload method
Re-read the flag and version flash regions after an update to get the
new device status.
2021-04-14 12:09:11 -06:00
Daniel Campello
9f77608ef7 trivial: flashrom: verify write to flag region
Disable verification on sub-block-size write was not needed after all.
2021-04-14 06:51:51 +01:00
Mario Limonciello
61ef63addc trivial: correct parsing of sample flashrom xml file 2021-04-09 16:02:20 +01:00
Daniel Campello
4483f609f1 flashrom: lspcon-i2c-spi: add write_firmware
Added firmware flash logic.
2021-04-08 18:12:16 -06:00
Daniel Campello
314b94b41f flashrom: lspcon-i2c-spi: read active_partion and version
Reads the active_partition and firmware version from active_partition
2021-04-08 18:12:16 -06:00
Daniel Campello
fe073a304d flashrom: add lspcon-i2c-spi programmer support
Created lspcon-i2c-spi flashrom device that uses udev to detect i2c
devices that can be updated with the lspcon-i2c-spi flashrom programmer.

This change implements the logic from crrev.com/c/2792124 adapted to the
upstream flashrom plugin.
2021-04-08 18:12:16 -06:00
Daniel Campello
08236d839d flashrom: make fu-flashrom-device derive from fu-udev-device
This change allows the flashrom plugin to probe for udev devices.
2021-04-08 18:12:16 -06:00
Daniel Campello
f37dcd4fab flashrom: make fu-flashrom-device a derivable type
This change allows other device types to derive from common flashrom
code in the flashrom-device type.

Change-Id: Ic963fd586e0a73153c54889fce50055753a1bf5c
2021-04-08 15:40:41 +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
Daniel Campello
f82ce6ecb6 flashrom: Update plugin to support multiple devices
This change moves many of the logic at the plugin level to the device
level in order to support multiple devices updatable via libflashrom.
2021-04-01 16:40:09 +01:00
Sean Rhodes
e5c67b0cde Removed PciBcr Quirk 2021-03-15 18:56:54 +00:00
Richard Hughes
aa95f30390 Allow reading the PciBcrAddr quirk from flashrom devices 2021-03-15 18:30:05 +00:00
Sean-StarLabs
2bd7b62ee9
Correct L3 GUID (#2979) 2021-03-05 11:49:29 +00:00
Sean Rhodes
247f29ad47 Updated StarLabs guids 2021-03-04 17:56:43 +00:00
Richard Hughes
7d132b728c Simplify the quirk file format
The best way of not getting something wrong is to not require it in the first
place...

All plugins now use DeviceInstanceId-style quirk matches and we can just drop
the prefix in all files. We were treating HwId=, Guid= and DeviceInstanceId= in
exactly the same way -- they're just converted to GUIDs when building the silo!
2021-03-03 08:30:34 +00:00
Richard Hughes
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
b3f9841924 Support more than one protocol for a given device
Devices may want to support more than one protocol, and for some devices
(e.g. Unifying peripherals stuck in bootloader mode) you might not even be able
to query for the correct protocol anyway.
2021-03-01 16:14:36 +00:00
Richard Hughes
078beafb2d Add a new internal flag to opt-in to GUID matching
It is far too easy to forget to set FWUPD_DEVICE_FLAG_NO_GUID_MATCHING for new
plugins, and without it it all works really well *until* a user has two devices
of the same type installed at the same time and then one 'disappears' for hard
to explain reasons. Typically we only need it for replug anyway!

Explicitly opt-in to this rarely-required behaviour, with the default to just
use the physical and logical IDs. Also document the update behavior for each
plugin to explain why the flag is being used.

This allows you to have two identical Unifying plugged in without one of them
being hidden from the user, at the same time allowing a HIDRAW<->USB transition
when going to and from bootloader and runtime modes.

This removes the workaround added in 99eb3f06b6.

Fixes https://github.com/fwupd/fwupd/issues/2915
2021-02-25 15:47:25 +00:00
Richard Hughes
a22c13c637 Move the plugin build logic to the plugins themselves 2021-02-18 14:46:20 +00:00
Mario Limonciello
75835b4a0b Use FWUPD_COMPILATION define to indicate an in tree build
When this is done, include:
* Including the hash
* Including anything that is not ABI stable in plugins yet

Suggested-by: Simon McVittie <smcv@debian.org>
2021-01-22 14:01:25 -06:00
Richard Hughes
6101067f03 coreboot: Remove plugin and instead add metadata to flashrom devices
The coreboot plugin never actually gained the ability to write. As it stands a
coreboot system now adds *two* system-firmware devices (from both flashrom and
coreboot) which isn't ideal.

Just allow flashrom to enumerate quirked devices and add coreboot-specific
metadata as required. If we require some kind of cbfs parsing then we can do
that in FuFlashromDevice->prepare_firmware().
2021-01-19 21:32:59 +00:00
Richard Hughes
a512d91d43 Report the lockdown status from UEFI and SuperIO plugins
I was asked the other day how many machines would support a /dev/mem mmap'd
update mechanism, and I had to say that I didn't know. We use direct port IO in
the SuperIO plugin too, and it would be good to know how quickly we need to
port this to something else.
2021-01-19 14:57:10 +00:00
Richard Hughes
ae72b9b9f6 flashrom: Mark the device as requiring a reboot 2021-01-15 10:01:00 +00:00
Richard Hughes
568bb79ba0 flashrom: Spin the progress progressbar while flashrom is writing 2021-01-15 10:01:00 +00:00
Richard Hughes
e48fdff1c8 flashrom: Process the output of flashrom_flash_probe() correctly 2021-01-15 10:01:00 +00:00
Richard Hughes
5a53d0aeb0 flashrom: Do not show unhelpful debug output 2021-01-15 10:01:00 +00:00
Richard Hughes
99b7cf9c7f flashrom: Add a quirk entry for the Starlabs LabTop L4 2021-01-15 10:01:00 +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
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
Mario Limonciello
8aa5d41eb7 Add external interface messages 2020-10-26 12:05:20 -05:00
Richard Hughes
f50ff2c27e Decouple the version format from the version itself
If we say that the version format should be the same for the `version_lowest`
and the `version_bootloader` then it does not always make sense to set it at
the same time.

Moving the `version_format` to a standalone first-class property also means it
can be typically be set in the custom device `_init()` function, which means we
don't need to worry about *changing* ther version format as set by the USB and
UDev superclass helpers.
2020-02-25 14:00:09 +00:00
Richard Hughes
0cc22a5ff6 trivial: Document the use of vendor-id in each plugin 2019-12-11 18:10:44 +00:00
Richard Hughes
49eeca05d0 flashrom: Use the BIOS vendor as the vendor ID 2019-12-11 18:10:44 +00:00