Skip to content

Commit 811f8ac

Browse files
authored
Merge pull request #305 from Dasharo/option-lib
Use DCU for UEFI settings on platforms w/o serial console
2 parents 714d73e + b3352d1 commit 811f8ac

File tree

8 files changed

+152
-44
lines changed

8 files changed

+152
-44
lines changed

dasharo-security/me-neuter.robot

+5-36
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Suite Setup Run Keywords
2424
... AND
2525
... Skip If not ${DASHARO_INTEL_ME_MENU_SUPPORT} Dasharo Intel ME menu not supported
2626
... AND
27-
... Set Intel ME Mode Enabled
27+
... Set UEFI Option MeMode Enabled
2828
Suite Teardown Run Keyword
2929
... Log Out And Close Connection
3030

@@ -45,12 +45,7 @@ MNE002.001 Intel ME mode option Enabled works correctly (Ubuntu 22.04)
4545
[Documentation] Check whether the Intel ME mode option in state Enabled
4646
... works correctly.
4747
Skip If not ${TESTS_IN_UBUNTU_SUPPORT} MNE002.001 not supported
48-
Power On
49-
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
50-
${dasharo_menu}= Enter Dasharo System Features ${setup_menu}
51-
${me_menu}= Enter Dasharo Submenu ${dasharo_menu} Intel Management Engine Options
52-
Set Option State ${me_menu} Intel ME mode Enabled
53-
Save Changes And Reset
48+
Set UEFI Option MeMode Enabled
5449
Boot System Or From Connected Disk ubuntu
5550
Login To Linux
5651
Switch To Root User
@@ -61,12 +56,7 @@ MNE003.001 Intel ME mode option Disabled (Soft) works correctly (Ubuntu 22.04)
6156
[Documentation] Check whether the Intel ME mode option in state
6257
... Disabled (Soft) works correctly
6358
Skip If not ${TESTS_IN_UBUNTU_SUPPORT} MNE003.001 not supported
64-
Power On
65-
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
66-
${dasharo_menu}= Enter Dasharo System Features ${setup_menu}
67-
${me_menu}= Enter Dasharo Submenu ${dasharo_menu} Intel Management Engine Options
68-
Set Option State ${me_menu} Intel ME mode Disabled (Soft)
69-
Save Changes And Reset
59+
Set UEFI Option MeMode Disabled (Soft)
7060
Boot System Or From Connected Disk ubuntu
7161
Login To Linux
7262
Switch To Root User
@@ -77,12 +67,7 @@ MNE004.001 Intel ME mode option Disabled (HAP) works correctly (Ubuntu 22.04)
7767
[Documentation] Check whether the Intel ME mode option in state
7868
... Disabled (HAP) works correctly.
7969
Skip If not ${TESTS_IN_UBUNTU_SUPPORT} MNE004.001 not supported
80-
Power On
81-
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
82-
${dasharo_menu}= Enter Dasharo System Features ${setup_menu}
83-
${me_menu}= Enter Dasharo Submenu ${dasharo_menu} Intel Management Engine Options
84-
Set Option State ${me_menu} Intel ME mode Disabled (HAP)
85-
Save Changes And Reset
70+
Set UEFI Option MeMode Disabled (HAP)
8671
Boot System Or From Connected Disk ubuntu
8772
Login To Linux
8873
Switch To Root User
@@ -94,26 +79,10 @@ MNE006.001 Check Intel ME version (Ubuntu 22.04)
9479
... be read on the Operating System level. The read version should be
9580
... the same as in the release notes.
9681
Skip If not ${TESTS_IN_UBUNTU_SUPPORT} MNE006.001 not supported
97-
Power On
98-
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
99-
${dasharo_menu}= Enter Dasharo System Features ${setup_menu}
100-
${me_menu}= Enter Dasharo Submenu ${dasharo_menu} Intel Management Engine Options
101-
Set Option State ${me_menu} Intel ME mode Enabled
102-
Save Changes And Reset
82+
Set UEFI Option MeMode Enabled
10383
Power On
10484
Boot System Or From Connected Disk ubuntu
10585
Login To Linux
10686
Switch To Root User
10787
${out}= Execute Command In Terminal cat /sys/class/mei/mei0/fw_ver
10888
Should Not Be Empty ${out}
109-
110-
111-
*** Keywords ***
112-
Set Intel ME Mode
113-
[Arguments] ${mode}
114-
Power On
115-
${setup_menu}= Enter Setup Menu Tianocore And Return Construction
116-
${dasharo_menu}= Enter Dasharo System Features ${setup_menu}
117-
${me_menu}= Enter Dasharo Submenu ${dasharo_menu} Intel Management Engine Options
118-
Set Option State ${me_menu} Intel ME mode ${mode}
119-
Save Changes And Reset

keywords.robot

+6-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Login To Linux Via SSH
142142
... height=100
143143
... escape_ansi=True
144144
... newline=LF
145-
Wait Until Keyword Succeeds 12x 10s
145+
Wait Until Keyword Succeeds 120x 1s
146146
... SSHLibrary.Login ${username} ${password}
147147

148148
Login To Windows Via SSH
@@ -559,7 +559,6 @@ Prepare To SSH Connection
559559
# tu leci zmiana, musimy brać platformy zgodnie z tym co zostało pobrane w dasharo
560560
Set Global Variable ${PLATFORM} ${CONFIG}
561561
SSHLibrary.Set Default Configuration timeout=60 seconds
562-
# Sonoff API Setup ${sonoff_ip}
563562
IF '${SNIPEIT}'=='no' RETURN
564563
SnipeIt Checkout ${RTE_IP}
565564

@@ -728,7 +727,11 @@ Sonoff Power Cycle On
728727
... Sonoff
729728
Sonoff Power Off
730729
Sleep 10
731-
Telnet.Read
730+
TRY
731+
Telnet.Read
732+
EXCEPT
733+
Log Could not clear Telnet buffer
734+
END
732735
Sonoff Power On
733736

734737
Power Cycle Off

lib/bios/menus.py

+63
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,66 @@ def merge_lists(list1, list2):
128128
final_list.add(i2)
129129

130130
return final_list
131+
132+
133+
getoptionpath = {
134+
"LockBios": [
135+
"Dasharo System Features",
136+
"Dasharo Security Features",
137+
"Lock the BIOS boot medium",
138+
],
139+
"NetworkBoot": [
140+
"Dasharo System Features",
141+
"Networking Options",
142+
"Enable network boot",
143+
],
144+
"UsbDriverStack": [
145+
"Dasharo System Features",
146+
"USB Configuration",
147+
"Enable USB stack",
148+
],
149+
"UsbMassStorage": [
150+
"Dasharo System Features",
151+
"USB Configuration",
152+
"Enable USB Mass Storage driver",
153+
],
154+
"SmmBwp": [
155+
"Dasharo System Features",
156+
"Dasharo Security Features",
157+
"Enable SMM BIOS write protection",
158+
],
159+
"MeMode": [
160+
"Dasharo System Features",
161+
"Intel Management Engine Options",
162+
"Intel ME mode",
163+
],
164+
"FanCurveOption": [
165+
"Dasharo System Features",
166+
"Power Management Options",
167+
"Fan profile",
168+
],
169+
"EnableCamera": [
170+
"Dasharo System Features",
171+
"Dasharo Security Features",
172+
"Enable Camera",
173+
],
174+
"EnableWifiBt": [
175+
"Dasharo System Features",
176+
"Dasharo Security Features",
177+
"Enable Wi-Fi + BT radios",
178+
],
179+
"SerialRedirection": [
180+
"Dasharo System Features",
181+
"Serial Port Configuration",
182+
"Enable Serial Port Console Redirection",
183+
],
184+
}
185+
186+
187+
@keyword("Option Name To UEFI Path")
188+
def option_name_to_uefi_path(name):
189+
"""
190+
This keyword converts an option name to a UEFI menu path. This path can be
191+
used to navigate to the option in the UEFI Setup Menu app.
192+
"""
193+
return getoptionpath[name]

lib/options/dcu.robot

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
*** Settings ***
2+
Documentation Library for UEFI configuration using Dasharo Configuration
3+
... Utility tool. Commonly used when serial port is not
4+
... available.
5+
6+
Library Collections
7+
Library OperatingSystem
8+
Library String
9+
Resource ../terminal.robot
10+
11+
12+
*** Keywords ***
13+
Set UEFI Option
14+
[Documentation] Set an UEFI option to a value.
15+
[Arguments] ${option_name} ${value}
16+
Run git clone https://github.com/Dasharo/dcu
17+
Boot System Or From Connected Disk ubuntu
18+
Login To Linux
19+
Switch To Root User
20+
Get Flashrom From Cloud
21+
Execute Command In Terminal flashrom -p internal -r coreboot.rom --fmap -i FMAP -i SMMSTORE &> /dev/null
22+
SSHLibrary.Get File coreboot.rom dcu/coreboot.rom
23+
# TODO error handling
24+
Run cd dcu && ./dcu v coreboot.rom --set "${option_name}" --value "${value}"
25+
SSHLibrary.Put File dcu/coreboot.rom coreboot.rom
26+
Execute Command In Terminal flashrom -p internal -w coreboot.rom --fmap -i SMMSTORE --noverify-all &> /dev/null
27+
Execute Reboot Command
28+
# Assume we don't have serial to tell us that we've rebooted, so just wait
29+
# 20s for shutdown to finish, to prevent subsequent kwds from running before
30+
# reboot.
31+
Sleep 20s

lib/options/uefi-setup-menu.robot

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
*** Settings ***
2+
Documentation Library for UEFI configuration using the UEFI setup menu
3+
... app (e.g. over serial port)
4+
5+
Library Collections
6+
Library String
7+
Resource ../bios/menus.robot
8+
9+
10+
*** Keywords ***
11+
Set UEFI Option
12+
[Documentation] Set an UEFI option to a value.
13+
... TODO: Only works with options following the submenu/submenu/option
14+
... pattern (e.g. all Dasharo System Features options).
15+
[Arguments] ${option_name} ${value}
16+
Skip If not ${TESTS_IN_FIRMWARE_SUPPORT} Can not configure UEFI settings on this platform.
17+
18+
TRY
19+
@{option_path}= Option Name To UEFI Path ${option_name}
20+
EXCEPT
21+
Skip Setting option ${option_name} is currently unimplemented.
22+
END
23+
24+
Power On
25+
${menu}= Enter Setup Menu Tianocore And Return Construction
26+
27+
${path_len}= Get Length ${option_path}
28+
FOR ${i} IN RANGE ${path_len} - 1
29+
${menu}= Enter Submenu From Snapshot And Return Construction
30+
... ${menu}
31+
... ${option_path[${i}]}
32+
END
33+
34+
Set Option State ${menu} ${option_path[${path_len}-1]} ${value}
35+
Save Changes And Reset

platform-configs/include/default.robot

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*** Settings ***
22
Resource ../../os-config/ubuntu-credentials.robot
3+
Resource ../../lib/options/${OPTIONS_LIB}.robot
34

45

56
*** Variables ***
@@ -27,6 +28,12 @@ ${INTERNAL_PROGRAMMER_CHIPNAME}= Opaque flash chip
2728
# See: https://github.com/Dasharo/dasharo-issues/issues/614
2829
${LAPTOP_EC_SERIAL_WORKAROUND}= ${FALSE}
2930

31+
# Library config
32+
# Option library: UEFI configuration variable backend.
33+
# - uefi-setup-menu: Will set options via the UEFI Setup menu (serial)
34+
# - dcu: Will use Dasharo Configuration Utility to configure options.
35+
${OPTIONS_LIB}= uefi-setup-menu
36+
3037
# OS config
3138
${DEVICE_WINDOWS_USERNAME}= user
3239
${DEVICE_WINDOWS_PASSWORD}= windows

platform-configs/include/novacustom-common.robot

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ Resource default.robot
66
# For the pikvm connection, we switch between pikvm/SSH when in firmware/OS.
77
# We need to go back to the initial method (pikvm) when switching back from
88
# OS to firmware (e.g. when rebooting inside a single test case).
9-
${INITIAL_DUT_CONNECTION_METHOD}= pikvm
9+
${INITIAL_DUT_CONNECTION_METHOD}= SSH
1010
${DUT_CONNECTION_METHOD}= ${INITIAL_DUT_CONNECTION_METHOD}
1111
${PAYLOAD}= tianocore
12-
${RTE_S2_N_PORT}= 13541
1312
${TIANOCORE_STRING}= to boot directly
1413
${BOOT_MENU_KEY}= F7
1514
${SETUP_MENU_KEY}= F2
@@ -30,11 +29,13 @@ ${DMIDECODE_VENDOR}= 3mdeb
3029
${DMIDECODE_FAMILY}= Not Applicable
3130
${DMIDECODE_TYPE}= Notebook
3231

32+
${OPTIONS_LIB}= dcu
33+
3334
${DEVICE_USB_KEYBOARD}= Logitech, Inc. Keyboard K120
3435
${CLEVO_USB_C_HUB}= 4-port
3536
${3_MDEB_WIFI_NETWORK}= 3mdeb_abr
3637
# Supported test environments
37-
${TESTS_IN_FIRMWARE_SUPPORT}= ${TRUE}
38+
${TESTS_IN_FIRMWARE_SUPPORT}= ${FALSE}
3839
${TESTS_IN_UBUNTU_SUPPORT}= ${TRUE}
3940
${TESTS_IN_WINDOWS_SUPPORT}= ${FALSE}
4041

@@ -133,7 +134,6 @@ Power On
133134
... into Power On state from Mechanical Off. (coldboot) For example:
134135
... sonoff, RTE relays.
135136
Restore Initial DUT Connection Method
136-
IF '${DUT_CONNECTION_METHOD}' == 'SSH' RETURN
137137
Power Cycle On
138138
Sleep 2s
139139
RteCtrl Set OC GPIO 12 low

scripts/check-unused-variables.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ fi
3333
# Loop through each provided robot variable file
3434
for robot_variable_file in "$@"; do
3535
# Specify the file paths to search for variable usage
36-
file_paths=("dasharo-compatibility" "dasharo-security" "dasharo-performance" "dasharo-stability" "lib" "keywords.robot")
36+
file_paths=("dasharo-compatibility" "dasharo-security" "dasharo-performance" "dasharo-stability" "lib" "keywords.robot" "platform-configs")
3737

3838
# Read variables from the specified robot variable file (only consider the leftmost variable on each line)
3939
mapfile -t variables < <(awk -F'=' '/^\$\{[^}]+\}=/{gsub(/[[:space:]]/, "", $1); print $1}' "$robot_variable_file" | sort -u)

0 commit comments

Comments
 (0)