summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorRuben Rodriguez Buchillon <coconutruben@chromium.org>2021-01-29 20:21:34 -0800
committerCommit Bot <commit-bot@chromium.org>2021-02-12 19:35:55 +0000
commiteddea1320c3733c17b56bbd57313fe9bcc1ee451 (patch)
tree1f9154847507ee151a28393dea4b996602eb7bf1 /extra
parent09ed2b339206cedf791a4728d234b34581580367 (diff)
downloadchrome-ec-eddea1320c3733c17b56bbd57313fe9bcc1ee451.tar.gz
servo_updater: firmware channel retrieval as a library service
This change introduces the ability of using servo_updater as a library to check whether a firmware string (e.g. the one currently read out from the servo device) belongs to a known channel. If so, the channel will be returned. If not, None is returned to indicate this is an unknown firmware string. This can then be used to warn the user to update, or inform them what channel they are currently running. BRANCH=None BUG=b:179310743 // This is performed with the CL that uses this: chromium:2661015 TEST=sudo servod -b soraka dut-control servo_micro_firmware_channel servo_micro_firmware_channel:stable Change-Id: I49e920c7c7977b7c05828f8464af973f538f7aeb Signed-off-by: Ruben Rodriguez Buchillon <coconutruben@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2661021 Reviewed-by: Brian Nemec <bnemec@chromium.org>
Diffstat (limited to 'extra')
-rwxr-xr-xextra/usb_updater/servo_updater.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/extra/usb_updater/servo_updater.py b/extra/usb_updater/servo_updater.py
index 89f3f651ad..575f4dbbdb 100755
--- a/extra/usb_updater/servo_updater.py
+++ b/extra/usb_updater/servo_updater.py
@@ -251,8 +251,26 @@ def _extract_version(boardname, binfile):
return newvers
+def get_firmware_channel(bname, version):
+ """Find out which channel |version| for |bname| came from.
-def get_files_and_version(cname, fname, channel=DEFAULT_CHANNEL):
+ Args:
+ bname: board name
+ version: current version string
+
+ Returns:
+ one of the channel names if |version| came from one of those, or None
+ """
+ for channel in CHANNELS:
+ # Pass |bname| as cname to find the board specific file, and pass None as
+ # fname to ensure the default directory is searched
+ _, _, vers = get_files_and_version(bname, None, channel=channel)
+ if version == vers:
+ return channel
+ # None of the channels matched. This firmware is currently unknown.
+ return None
+
+def get_files_and_version(cname, fname=None, channel=DEFAULT_CHANNEL):
"""Select config and firmware binary files.
This checks default file names and paths.