Skip to content

Commit 5d20cb3

Browse files
authored
Merge pull request #2063 from tlaurion/show_ec_version
initrd/*functions : add logic to show ec version under System Information and recovery shell, populated in init Input for #2062
2 parents 9deb5bf + a16afdb commit 5d20cb3

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

initrd/bin/oem-system-info-xx30

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,14 @@ kernel=$(uname -s -r)
5050

5151
FB_OPTIONS=""
5252
if whiptail --version | grep "fbwhiptail"; then FB_OPTIONS="--text-size 12"; fi
53+
# make sure we know the EC version too, populate if not already set
54+
if [ -z "$EC_VER" ]; then
55+
EC_VER=$(ec_version)
56+
fi
57+
58+
# build optional EC_VER line like gui_functions does
59+
ec_ver_line=""
60+
[ -n "$EC_VER" ] && ec_ver_line="\nEC_VER: ${EC_VER}"
61+
5362
whiptail_type $BG_COLOR_MAIN_MENU $FB_OPTIONS --title 'System Info' \
54-
--msgbox "${BOARD_NAME}\nFW_VER: ${FW_VER}\nKernel: ${kernel}\nCPU: ${cpustr} RAM: ${memtotal} GB $battery_status\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')\n\n$(cat /tmp/devices_usb_pci)" 0 80
63+
--msgbox "${BOARD_NAME}\nFW_VER: ${FW_VER}${ec_ver_line}\nKernel: ${kernel}\nCPU: ${cpustr} RAM: ${memtotal} GB $battery_status\n$(fdisk -l | grep -e '/dev/sd.:' -e '/dev/nvme.*:' | sed 's/B,.*/B/')\n\n$(cat /tmp/devices_usb_pci)" 0 80

initrd/etc/functions

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ fw_version() {
102102
echo "${FW_VER::-10}"
103103
}
104104

105+
ec_version() {
106+
# EC firmware version from DMI type 11 OEM Strings (if present).
107+
# The raw sysfs entry has a 5-byte header followed by null-terminated strings.
108+
local raw="/sys/firmware/dmi/tables/DMI"
109+
[ -f "$raw" ] || return
110+
tail -c +6 "$raw" | tr '\0' '\n' | sed -n 's/^EC firmware version: *//p'
111+
}
112+
105113
preserve_rom() {
106114
TRACE_FUNC
107115
new_rom="$1"
@@ -313,7 +321,10 @@ recovery() {
313321
touch /tmp/config
314322
. /tmp/config
315323

316-
DEBUG "Board $CONFIG_BOARD - version $(fw_version)"
324+
# Log board and firmware/EC versions in one go. ec_version() will
325+
# return an empty string if nothing is available, so the output is still
326+
# well-formed even on systems without an EC version string.
327+
DEBUG "Board $CONFIG_BOARD - version $(fw_version) EC_VER: $(ec_version)"
317328

318329
if [ "$CONFIG_TPM" = "y" ]; then
319330
INFO "TPM: Extending PCR[4] to prevent any further secret unsealing"

initrd/etc/gui_functions

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,26 @@ file_selector() {
165165

166166
show_system_info() {
167167
TRACE_FUNC
168+
# ensure EC_VER is populated; this mirrors the behaviour of the
169+
# init script which exports EC_VER early, but calling the helper
170+
# here makes the GUI menu self‑contained.
171+
if [ -z "$EC_VER" ]; then
172+
EC_VER=$(ec_version)
173+
fi
168174
battery_status="$(print_battery_state)"
169175

170176
memtotal=$(cat /proc/meminfo | grep 'MemTotal' | tr -s ' ' | cut -f2 -d ' ')
171177
memtotal=$((${memtotal} / 1024 / 1024 + 1))
172178
cpustr=$(cat /proc/cpuinfo | grep 'model name' | uniq | sed -r 's/\(R\)//;s/\(TM\)//;s/CPU //;s/model name.*: //')
173179
kernel=$(uname -s -r)
174180

181+
local ec_ver_line=""
182+
[ -n "$EC_VER" ] && ec_ver_line="
183+
EC_VER: ${EC_VER}"
184+
175185
local msgbox="${BOARD_NAME}
176186
177-
FW_VER: ${FW_VER}
187+
FW_VER: ${FW_VER}${ec_ver_line}
178188
Kernel: ${kernel}
179189
180190
CPU: ${cpustr}

initrd/init

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ fi
222222

223223
# export firmware version
224224
export FW_VER=$(fw_version)
225+
# export EC firmware version (DMI type 11 OEM string)
226+
# `ec_version` returns an empty string if the field is missing.
227+
export EC_VER=$(ec_version)
225228

226229
# Add our boot devices into the /etc/fstab, if they are defined
227230
# in the configuration file.

0 commit comments

Comments
 (0)