Commit Graph

88 Commits

Author SHA1 Message Date
Richard Hughes
bc43adf020 Fix build error when sys/io.h is not available 2021-10-06 20:38:43 +01:00
Sean Rhodes
2bd8e80d03
plugins/flashrom: Always shutdown after flashing (#3831)
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
2021-10-05 08:57:20 +01:00
Sean Rhodes
71b52abb66
plugins/flashrom: Reset CMOS aftering writing region (#3814)
Resetting the CMOS before a write when switching branch will cause a lock on\
reboot which requires hard power off.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
2021-10-01 14:32:19 +01:00
Sean Rhodes
49c08f436f
plugins/uefi-capsule: Disable ux-capsule for all StarLabs laptops (#3815)
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
2021-09-30 08:52:02 +01:00
Richard Hughes
a3cd497bd1 flashrom: Ensure internal devices get an assigned context
This makes the quirks work correctly. Fixes a warning seen in the logs.
2021-09-27 11:06:13 +01:00
Sean Rhodes
2694abeb71 plugins/flashrom: Update StarBook GUID
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
2021-09-27 08:24:26 +01:00
Richard Hughes
40cd18fa97 Allow using a per-device global percentage completion
It's actually quite hard to build a front-end for fwupd at the moment
as you're never sure when the progress bar is going to zip back to 0%
and start all over again. Some plugins go 0..100% for write, others
go 0..100% for erase, then again for write, then *again* for verify.

By creating a helper object we can easily split up the progress of the
specific task, e.g. write_firmware().

We can encode at the plugin level "the erase takes 50% of the time, the
write takes 40% and the read takes 10%". This means we can have a
progressbar which goes up just once at a consistent speed.
2021-09-13 14:28:15 +01:00
Sean Rhodes
f959b198d2 plugins/flashrom: Fix logic in reset cmos
ioperm returns -1 for an error and 0 for success
2021-09-13 12:09:37 +01:00
Sean Rhodes
8cc158bda4 plugins/flashrom: Add reset-cmos flag to Star Labs laptops 2021-09-11 07:47:14 -05:00
Sean Rhodes
af9d9b3ffd plugins/flashrom: Add private flag to reset CMOS
Reset the CMOS based on a private flag. Tested on coreboot using an
offset of 123. Required when a CMOS layout or default option has
changed as the resulting flash will have 0's for the modified option.
2021-09-10 16:25:32 +01:00
Sean Rhodes
bcf6253134 plguins/flashrom: Add GUID for StarBook coreboot 2021-09-09 22:31:56 +01:00
Sean Rhodes
33e850dea5 plugins/{superio,flashrom}: Add GUIDs for StarBook Mk V 2021-09-09 14:26:36 -05:00
Sean Rhodes
2e856d21e0 plugins/flashrom: Only backup BIOS region
As we are only writing to the BIOS region, we only need to backup the BIOS
region. The will avoid the error "failed to back up original firmware" if
regions such as the ME can't be read.
2021-09-03 12:04:20 +01:00
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Richard Hughes
c1ff02f055 trivial: Make the quirk style more consistent 2021-08-23 18:10:12 +01:00
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