-
Notifications
You must be signed in to change notification settings - Fork 3
dasharo-deploy: Add sanity check before flash #139
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
base: fd_first
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||
| locked_regions+=("FD") | ||||||
| fi | ||||||
|
|
||||||
| if [ "$BOARD_ME_REGION_RW" -eq 0 ]; then | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| 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!" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
| 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 | ||||||
|
|
@@ -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 | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -978,6 +980,11 @@ deploy_firmware() { | |
| fi | ||
| done | ||
|
|
||
| # Last restort check before flashing | ||
| if ! flashrom_sanity_check; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like it should check what really is flashed by parsing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can ignore this comment if you think it's OK.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. optiplex-7010 UEFI Update - DPP.profile:35:flashrom -p internal -N --fmap -i COREBOOT -w /tmp/biosupdateNot 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 | ||
|
|
@@ -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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.