Skip to content

initrd/*functions : add logic to show ec version under System Information and recovery shell, populated in init#2063

Merged
tlaurion merged 1 commit intolinuxboot:masterfrom
tlaurion:show_ec_version
Feb 27, 2026
Merged

initrd/*functions : add logic to show ec version under System Information and recovery shell, populated in init#2063
tlaurion merged 1 commit intolinuxboot:masterfrom
tlaurion:show_ec_version

Conversation

@tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Feb 27, 2026

repro from within Heads:
source /etc/functions
ec_version

v540tu:
2024-07-17_4ae73b9

v4x_adl:
1.07.02

  • Shows under /tmp/debug.log
  • Shows under System information

…tion and recovery shell, populated in init

repro from within Heads:
source /etc/functions
ec_version

v540tu:
2024-07-17_4ae73b9

v4x_adl:
1.07.02

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
Copilot AI review requested due to automatic review settings February 27, 2026 19:22
@tlaurion tlaurion merged commit 5d20cb3 into linuxboot:master Feb 27, 2026
3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Embedded Controller (EC) firmware version reporting alongside the existing BIOS/firmware version so it can be shown in Heads “System Info” UIs and logged during recovery.

Changes:

  • Export EC_VER early during init so it’s available to later scripts/menus.
  • Add ec_version() helper to extract EC version from SMBIOS/DMI data and log it in recovery.
  • Display EC_VER in GUI “System Information” and the oem-system-info-xx30 whiptail dialog when available.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
initrd/init Exports EC_VER during early init.
initrd/etc/functions Introduces ec_version() and logs EC version in recovery debug output.
initrd/etc/gui_functions Shows EC version under System Info in the GUI menu.
initrd/bin/oem-system-info-xx30 Shows EC version in the extended system info dialog.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +107 to +110
# The raw sysfs entry has a 5-byte header followed by null-terminated strings.
local raw="/sys/firmware/dmi/tables/DMI"
[ -f "$raw" ] || return
tail -c +6 "$raw" | tr '\0' '\n' | sed -n 's/^EC firmware version: *//p'
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ec_version() is parsing the raw SMBIOS/DMI table as if it were a simple 5-byte header followed by NUL-terminated strings. /sys/firmware/dmi/tables/DMI is a binary structure table, so tail | tr '\0' '\n' can be brittle (may emit non-text bytes, and the “5-byte header” assumption is incorrect). Consider extracting from /sys/firmware/dmi/entries/11-*/raw (SMBIOS type 11) or running strings on the table to filter printable data, and ensure the function returns a single line (e.g., first match).

Suggested change
# The raw sysfs entry has a 5-byte header followed by null-terminated strings.
local raw="/sys/firmware/dmi/tables/DMI"
[ -f "$raw" ] || return
tail -c +6 "$raw" | tr '\0' '\n' | sed -n 's/^EC firmware version: *//p'
# Prefer SMBIOS type 11 sysfs entries, fall back to running strings on the
# raw DMI table. Always return at most one matching line.
local entry
# Try SMBIOS type 11 entries first, if available.
if entry=$(ls /sys/firmware/dmi/entries/11-*/raw 2>/dev/null | head -n1); then
strings "$entry" | sed -n 's/^EC firmware version: *//p' | head -n1
return
fi
# Fallback: run strings on the full DMI table if present.
local raw="/sys/firmware/dmi/tables/DMI"
[ -r "$raw" ] || return
strings "$raw" | sed -n 's/^EC firmware version: *//p' | head -n1

Copilot uses AI. Check for mistakes.
export FW_VER=$(fw_version)
# export EC firmware version (DMI type 11 OEM string)
# `ec_version` returns an empty string if the field is missing.
export EC_VER=$(ec_version)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export EC_VER=$(ec_version) is unquoted, so if ec_version ever returns whitespace/glob characters it can be word-split into multiple export arguments (or be pathname-expanded). Quote the command substitution when exporting to keep the value intact.

Suggested change
export EC_VER=$(ec_version)
export EC_VER="$(ec_version)"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants