Skip to content

Novacustom capsule tests #800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
54ec2ad
prepare_capsule_update_tests_drive.sh: Add script
philipanda Apr 14, 2025
9491a75
capsule-update-files/Shell.efi: Add UEFI shell executable
philipanda Apr 14, 2025
e11eca0
capsule-update-files: Add nsh scripts
philipanda Apr 14, 2025
fd8c3e3
options-lib_dcu: turn off lock bios instead of failing
philipanda Apr 17, 2025
90ece87
novacustom-mtl.robot: Add capsule update support to config
philipanda Apr 17, 2025
f48e75e
dasharo-stability/capsule-update.robot: Allow running without serial
philipanda Apr 17, 2025
6becd58
keywords.robot: Identify Path To USB: Only get partition if it exists
philipanda Apr 24, 2025
c3831ee
lib/flash: Fail if flashing fails instead of ignoring it
philipanda Apr 24, 2025
a7a160d
options-lib_dcu: Fix catching missing bootentry
philipanda Apr 24, 2025
3a64a45
prepare_capsule_update_tests_drive: Dynamically find drive mountpoint
philipanda Apr 24, 2025
f25b110
capsule-update-startup.nsh: Remove setting STEP variable file
philipanda Apr 24, 2025
b5301c8
scripts/lib/robot.sh: Comment-out-back the full command debug print
philipanda Apr 24, 2025
736c98a
capsule-update.robot: adapt the tests for no uefi shell and no serial
philipanda Apr 25, 2025
f00b978
options-lib_dcu: Set Nextboot Bootentry: convert to lowercase
philipanda May 7, 2025
444c0d2
capsule-update.robot: Check whether the version changed
philipanda May 23, 2025
1c3cc9b
capsule-update.robot: Update preparation instructions
philipanda May 26, 2025
46f9fb8
prepare_capsule_update_tests_drive: Add FW to drive
philipanda Jun 30, 2025
2ded105
capsule-update.robot: Fix wrong capsule filename
philipanda Jun 30, 2025
d6b42dd
capsule-update.robot: Fix checking if version changed
philipanda Jun 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added dasharo-stability/capsule-update-files/Shell.efi
Binary file not shown.
3 changes: 3 additions & 0 deletions dasharo-stability/capsule-update-files/Shell.efi.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 3mdeb <contact@3mdeb.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use https://github.com/Dasharo/osfv-test-data/tree/master/uefi-shell?

Also, this isn't proper license for something that came from edk2 code.


SPDX-License-Identifier: Apache-2.0
26 changes: 26 additions & 0 deletions dasharo-stability/capsule-update-files/capsule-update-startup.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2025 3mdeb <contact@3mdeb.com>
#
# SPDX-License-Identifier: Apache-2.0

set LOG_FILE fs0:\logs.txt

# load variables to allow saving state between runs

fs0:\variable_capsule_file.nsh
fs0:\variable_step.nsh

# Variables expected to be loaded:
# - STEP - integer flag for choosing operation mode
# - CAPSULE_FILE - path to the capsule file

# Step 0 - launch capsule update
if "%STEP%" == "0" then
fs0:\CapsuleApp.efi "%CAPSULE_FILE%" -NR
reset
endif

# Step 1 - check update status
if "%STEP%" == "1" then
fs0:\CapsuleApp.efi -S > "%LOG_FILE%"
reset
endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2025 3mdeb <contact@3mdeb.com>
#
# SPDX-License-Identifier: Apache-2.0
set CAPSULE_FILE fs0:\wrong_cert.cap
4 changes: 4 additions & 0 deletions dasharo-stability/capsule-update-files/variable_step.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2025 3mdeb <contact@3mdeb.com>
#
# SPDX-License-Identifier: Apache-2.0
set STEP 0
375 changes: 242 additions & 133 deletions dasharo-stability/capsule-update.robot

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -1419,20 +1419,23 @@ Get Hash Of File
RETURN ${hash}

Identify Path To USB
[Documentation] Identifies path to USB storage. Setting ${usb_model}
... variable in .config file is required to correctly work
... this keyword.
[Documentation] Identifies path to USB storage. Setting ${USB_MODEL}
... variable in .config file is required.
[Arguments] ${usb_model}=${USB_MODEL}
${out}= Execute Linux Command lsblk --nodeps --output NAME
@{disks}= Get Regexp Matches ${out} sd.
FOR ${disk} IN @{disks}
${model}= Execute Linux Command cat /sys/class/block/${disk}/device/model
${model_name}= Fetch From Left ${model} \r\n
${model_name}= Fetch From Right ${model_name} \r
Set Local Variable ${usb_disk} ${disk}
IF '${model_name}' == '${USB_MODEL}' BREAK
IF '${usb_model}' in '${model_name}' BREAK
END
${out}= Execute Linux Command
... lsblk --list --noheadings --output NAME,TYPE,PATH | grep ${usb_disk} | grep part
... lsblk --list --noheadings --output NAME,TYPE,PATH | grep ${usb_disk}
IF 'part' in '${out}'
${out}= Get Regexp Matches ${out} part
END
${split}= Split String ${out}
${path_to_usb}= Get From List ${split} 2
RETURN ${path_to_usb}
Expand Down
2 changes: 1 addition & 1 deletion lib/flash.robot
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Flash Via Internal Programmer With Args
Log Retry flashing once again in case of failure
${out_flash}= Execute Command In Terminal flashrom -p internal -w ${fw_file_path} ${args} 300s
IF "Warning: Chip content is identical to the requested image." in """${out_flash}"""
RETURN
Fail Couldn't flash firmware
END
# Should Contain ${out_flash} VERIFIED
END
Expand Down
18 changes: 13 additions & 5 deletions lib/options/options-lib_dcu.robot
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ Make Sure That Flash Locks Are Disabled
Login To Linux
Switch To Root User
${out_flashrom}= Execute Command In Terminal flashrom -p internal
Should Not Contain ${out_flashrom} read-only
${ro}= Run Keyword And Return Status Should Not Contain ${out_flashrom} read-only
IF not ${ro} Set UEFI Option LockBios Disabled

Login To Windows
Power On
Expand All @@ -145,18 +146,25 @@ Set Nextboot

${os_boot_id}= Set Variable ${EMPTY}
${os_bootentry_name}= Get From Dictionary ${ENV_ID_OS_BOOTMENU_NAMES} ${env_id}
${os_bootentry_name}= Convert To Lower Case ${os_bootentry_name}

Set Nextboot Bootentry ${os_bootentry_name}

Set Nextboot Bootentry
[Documentation] Sets the botentry name of choice to be booted first on
... the next reboot. Not persistent, only changes the first boot
... option for one boot.
[Arguments] ${bootentry_name}
${bootentry_name}= Convert To Lower Case ${bootentry_name}
${boot_entries}= Execute Command In Terminal efibootmgr

@{lines}= Split To Lines ${boot_entries}

${os_boot_id}= Set Variable ${EMPTY}
FOR ${line} IN @{lines}
${tmp}= Encode String To Bytes ${line} ASCII errors=replace
${line}= Decode Bytes To String ${tmp} ASCII errors=replace
${line}= Get Substring ${line} 0 150
${line}= Convert To Lower Case ${line}

IF '${os_bootentry_name}' in '${line}'
IF '${bootentry_name}' in '${line}'
${os_boot_id}= Set Variable ${line}
BREAK
END
Expand Down
1 change: 1 addition & 0 deletions lib/terminal.robot
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ Execute Command In Terminal
Telnet.Read
${output}= Telnet.Execute Command ${command} strip_prompt=True
ELSE
Read From Terminal
Write Into Terminal ${command}
${output}= Read From Terminal Until Prompt
END
Expand Down
2 changes: 2 additions & 0 deletions platform-configs/include/novacustom-mtl.robot
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ ${L3_CACHE_SUPPORT}= ${TRUE}

# Only S0ix is available on MTL
${DASHARO_POWER_MGMT_MENU_SUPPORT}= ${FALSE}

${CAPSULE_UPDATE_SUPPORT}= ${TRUE}
71 changes: 71 additions & 0 deletions scripts/capsules/prepare_capsule_update_tests_drive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2025 3mdeb <contact@3mdeb.com>
#
# SPDX-License-Identifier: Apache-2.0

DRIVE=$1
DRIVE_LABEL=CAPSULE_USB
FILES_DIR=dasharo-stability/capsule-update-files
CAPSULE_FILES_DIR=dl-cache/edk2


if [[ -z $1 ]]; then
echo "Usage:
$0 <flash_drive_device_file>
Example:
sudo -E $0 /dev/sdc
Note:
must be run as super user"
exit 1
fi

if [[ $USER != 'root' ]]; then
echo "$0 has to be run as root"
echo "Example:"
echo " sudo -E $0 /dev/sdc"
exit 1
fi

if [[ ! -f $CAPSULE_FW_FILE ]]; then
echo "CAPSULE_FW_FILE must be a valid capsule, right now CAPSULE_FW_FILE=$CAPSULE_FW_FILE"
exit 1
fi

if ! [ -b $DRIVE ]; then
echo "drive $DRIVE doesn't exist"
exit 1
fi

# try to unmount, fails if not mounted
udisksctl unmount -b $DRIVE || true
# format to fat32
mkfs.vfat $DRIVE # requires root privilege
fatlabel $DRIVE $DRIVE_LABEL
sleep 1
# mount drive
udisksctl mount -b $DRIVE
mount_point=$(udisksctl info -b $DRIVE | grep -Po '^ *MountPoints: *\K.*')

# create boot directories
mkdir -p "$mount_point"/EFI/BOOT

CAPSULE_BASENAME=$(realpath "$CAPSULE_FW_FILE")
CAPSULE_BASENAME=$(basename "$CAPSULE_BASENAME")
CAPSULE_BASENAME="${CAPSULE_BASENAME%.*}"

# copy files
cp $FILES_DIR/Shell.efi "$mount_point"/EFI/BOOT/bootx64.efi
cp $FILES_DIR/CapsuleApp.efi "$mount_point"/CapsuleApp.efi
cp $FILES_DIR/capsule-update-startup.nsh "$mount_point"/startup.nsh
cp $FILES_DIR/variable_capsule_file.nsh "$mount_point"/variable_capsule_file.nsh
cp $FILES_DIR/variable_step.nsh "$mount_point"/variable_step.nsh
cp $CAPSULE_FILES_DIR/${CAPSULE_BASENAME}_wrong_cert.cap "$mount_point"/wrong_cert.cap
cp $CAPSULE_FILES_DIR/${CAPSULE_BASENAME}_invalid_guid.cap "$mount_point"/invalid_guid.cap
cp $CAPSULE_FW_FILE "$mount_point"/valid_capsule.cap
cp $FW_FILE "$mount_point"/pre-capsule.rom

# cleanup
udisksctl unmount -b $DRIVE

echo "Done"
2 changes: 1 addition & 1 deletion scripts/lib/robot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ execute_robot() {
${_robot_args[*]} \
${_test_name}
"
echo "$command"
# echo "$command"
eval "$command"
done
}
Loading