Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 36 additions & 2 deletions include/dts-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,41 @@ set_flashrom_update_params() {
fi
}

# A final check for locked regions before flashing via flashrom.
# Decide whether we can proceed if any regions are locked.
flashrom_sanity_check() {
local locked_regions=()
local region_list verb

if [ "$BOARD_FD_REGION_RW" -eq 0 ]; then
Copy link
Contributor

@m-iwanicki m-iwanicki Dec 16, 2025

Choose a reason for hiding this comment

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

Suggested change
if [ "$BOARD_FD_REGION_RW" -eq 0 ]; then
if [[ "$BOARD_HAS_FD_REGION" -eq 1 && "$BOARD_FD_REGION_RW" -eq 0 ]]; then

locked_regions+=("FD")
fi

if [ "$BOARD_ME_REGION_RW" -eq 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if [ "$BOARD_ME_REGION_RW" -eq 0 ]; then
if [[ "$BOARD_HAS_ME_REGION" -eq 1 && "$BOARD_ME_REGION_RW" -eq 0 ]]; then

locked_regions+=("ME")
fi

if [ "${#locked_regions[@]}" -eq 0 ]; then
return 0
fi

if [ "${#locked_regions[@]}" -eq 1 ]; then
region_list="${locked_regions[0]}"
verb="is"
else
region_list="${locked_regions[0]} and ${locked_regions[1]}"
verb="are"
fi

if [[ "$SWITCHING_TO" == "heads" ]]; then
print_error "Cannot proceed with heads update when $region_list $verb locked!"
Copy link
Contributor

Choose a reason for hiding this comment

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

Add link to docs with information what should be done (if it doesn't exists then add it). Maybe: https://docs.dasharo.com/guides/firmware-update/#known-issues.
For MSI (locked FD): The following warnings appear when updating Dasharo: should be good enough.
For ME you could add generic: Make sure ME is set to HAP disabled. If this doesn't work then try with ME Soft Disabled.

return 1
fi

print_warning "Proceeding without $region_list $verb flashing, as they $verb not critical."
return 0
}

set_intel_regions_update_params() {
local fd_me_locked="no"
if [ $BOARD_HAS_FD_REGION -eq 0 ]; then
Expand All @@ -705,8 +740,7 @@ set_intel_regions_update_params() {
FLASHROM_ADD_OPT_REGIONS+=" -i fd"
else
fd_me_locked="yes"
print_error "The firmware binary to be flashed contains Flash Descriptor (FD), but FD is not writable!"
print_warning "Proceeding without FD flashing, as it is not critical."
print_warning "The firmware binary to be flashed contains Flash Descriptor (FD), but FD is not writable!"
echo "The firmware binary contains Flash Descriptor (FD), but FD is not writable!" >>$ERR_LOG_FILE
fi
fi
Expand Down
14 changes: 12 additions & 2 deletions scripts/dasharo-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,9 @@ deploy_firmware() {
if [ $UPDATE_ME -eq 0 ]; then
UPDATE_STRING+="Management Engine"
fi
echo "Scheduling $UPDATE_STRING update..."
if [ -n "$UPDATE_STRING" ]; then
echo "Scheduling $UPDATE_STRING update..."
fi
_messages+=("Failed to update $UPDATE_STRING")
_jobs+=("-p $PROGRAMMER_BIOS ${FLASH_CHIP_SELECT} ${FLASHROM_ADD_OPT_REGIONS} -w $BIOS_UPDATE_FILE")
fi
Expand Down Expand Up @@ -978,6 +980,11 @@ deploy_firmware() {
fi
done

# Last restort check before flashing
if ! flashrom_sanity_check; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it should check what really is flashed by parsing _jobs.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can ignore this comment if you think it's OK.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about correctness of this implementation, will need to check cases where we only flash e.g. COREBOOT like every PC Engines. There is also Optiplex:

optiplex-7010 UEFI Update - DPP.profile:35:flashrom -p internal -N --fmap -i COREBOOT -w /tmp/biosupdate

Not sure if we should warn in this case if we are not even flashing FD (because it's identical). If we are currently printing warning then it's ok.

return 1
fi

_jobs_total=${#_jobs[@]}

# Execute scheduled tasks
Expand Down Expand Up @@ -1140,7 +1147,10 @@ update_workflow() {
display_warning
fi

deploy_firmware update
# Check if update succeeded
if ! deploy_firmware update; then
return 1
fi

# TODO: Could it be placed somewhere else?
if [ ! -z "$SWITCHING_TO" ]; then
Expand Down