Bug 11468 - integrate firmware update into system update
Summary: integrate firmware update into system update
Status: RESOLVED FIXED
Alias: None
Product: IoT Reference OS Kit
Classification: Yocto Project Subprojects
Component: intel-iot-refkit-software-update (show other bugs)
Version: 2.4
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: Future
Assignee: Patrick Ohly
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2017-05-05 07:28 UTC by Patrick Ohly
Modified: 2017-11-07 16:45 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Ohly 2017-05-05 07:28:15 UTC
The implementation will be based on UEFI-based capsule update capabilities in the firmware.

There are two projects that we should consider for integration:
https://github.com/rhinstaller/fwupdate 
http://fwupd.org.s3-website-eu-west-1.amazonaws.com/ 

This issue is about:
- providing recipes for either fwupdate or fwupd
- support for firmware updates as part of the system update (bug #11467), i.e. 
  getting new firmware onto a device and triggering its installation, including
  a reboot

Testing whether the actual firmware gets installed by fwupdate or fwupd is out of scope of this issue, because it is hardware-specific.
Comment 1 Patrick Ohly 2017-07-18 13:59:51 UTC
swupd uses swupdate for the UEFI capsule support. So both will be integrated.

Current status is that I have recipe for both plus several new dependencies. I found one problem in OE-core (bug #11792) which I could work around, but a fix in OE-core would be better.

Biggest gaps right now are:
- review of the new upstream components (requested, unknown ETA)
- removal of the swupd -> polkit dependency - we really don't want to drag
  that into a build
- delivery of firmware updates via system update (at the moment,
  only direct downloads via http work, and that depends on gpg for
  verification, which we don't want in an image either)
- installation and updates of swupdate in the EFI system partition
Comment 2 Patrick Ohly 2017-07-25 10:06:28 UTC
I've patched polkit so that we just build the client library and implement the policy checking with groupcheck.

Regarding UEFI capsule support: I suggest that we defer this until we actually have hardware that supports it. A quick check for support is to look for
/sys/firmware/efi/esrt/entries/ - it must exist.

Regarding integration into OSTree (the system update mechanism currently used in refkit): again, lack of a suitable test makes this hard to do now.

My plan for integration is this:
- disable the default Linux Vendor Firmware Service remote
- patch fwupd so that it supports remotes with a file:// url
  and without GPG signing
- enable such a remote which points to a directory that is
  part of the OS
- populate that directory as part of update building with
  a firmware.xml.gz and actual firmware files, as configured
  by the device manufacturer for his hardware
- in an OSTree post-update hook, trigger fwupd such that
  it gets these files and applies them

This way, we don't need to install gnupg, which is otherwise required to validate the normal LVFS files.

Regarding patching, a quick check of the source points to a few places that needed patching:
- fwupd_client_update_metadata_with_id - signature file must be optional
- fu_util_download_file - must support file:// urls or calls to it
  for file:// urls must be avoided (whatever is easier)
- UpdateMetadataWithId - signature file must be optional
- fu_engine_update_metadata - skip signature check

Such a patch might be upstreamable, if we explain the use case (updating small devices which do not have access to the LVFS web server and/or can't deal with the full XML file hosted there).
Comment 3 Patrick Ohly 2017-07-25 15:25:08 UTC
(In reply to comment #2)
> I've patched polkit so that we just build the client library and implement
> the policy checking with groupcheck.

See https://github.com/pohly/intel-iot-refkit/commits/firmware-update

This also depends on a patch I just sent to OE-core: "[PATCH] gettext.bbclass: also search for files in target sysroot".

I sent patches for appstream-glib and fwupd, so if we wait a bit, we might be able to get rid of those patches in my branch.
Comment 4 Patrick Ohly 2017-07-26 13:34:41 UTC
Upstream discussion around fwupd integration into system update is now here:
https://github.com/hughsie/fwupd/issues/162
Comment 5 Patrick Ohly 2017-07-27 12:07:51 UTC
(In reply to comment #4)
> Upstream discussion around fwupd integration into system update is now here:
> https://github.com/hughsie/fwupd/issues/162

And upstream has developed a solution, see https://github.com/hughsie/fwupd/pull/163#issuecomment-318340508

Regarding testing, upstream is using Logitech unifying dongles. This looks like something that we should be able to replicate. However, each dongle can only be used for a while before the EEPROM wears out. So we should integrate this into our master build testing, but not PRs.

See https://github.com/hughsie/appstream-glib/pull/182#issuecomment-318042615
Comment 6 Patrick Ohly 2017-09-15 19:18:56 UTC
I was able to start updating a Logitech Unifying Receive with firmware bundled into the image where it could be delivered via a system update. See https://bugzilla.yoctoproject.org/show_bug.cgi?id=11468

Minimal documentation is in the fwupd recipe README.

This is only a partial solution. Missing:
- fwupd is completely untested
- automated QA tests
- automatically starting fwupd update after a system update
Comment 7 Patrick Ohly 2017-11-07 15:26:06 UTC
https://github.com/intel/intel-iot-refkit/pull/311 was merged into refkit.

Automated testing is missing, but as it was excluded from the scope of the issue anyway, I closing this one here as "resolved".