initrd/*functions : add logic to show ec version under System Information and recovery shell, populated in init#2063
Conversation
…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>
There was a problem hiding this comment.
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_VERearly 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_VERin GUI “System Information” and theoem-system-info-xx30whiptail 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.
| # 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' |
There was a problem hiding this comment.
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).
| # 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 |
| 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) |
There was a problem hiding this comment.
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.
| export EC_VER=$(ec_version) | |
| export EC_VER="$(ec_version)" |
repro from within Heads:
source /etc/functions
ec_version
v540tu:
2024-07-17_4ae73b9
v4x_adl:
1.07.02