Commit Graph

11 Commits

Author SHA1 Message Date
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
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
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
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