Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # | 2 # |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 # | 6 # |
| 7 # This script can change key (usually developer keys) in a firmware binary | 7 # This script can change key (usually developer keys) in a firmware binary |
| 8 # image or system live firmware (EEPROM), and assign proper HWID, BMPFV as well. | 8 # image or system live firmware (EEPROM), and assign proper HWID, BMPFV as well. |
| 9 | 9 |
| 10 SCRIPT_BASE="$(dirname "$0")" | 10 SCRIPT_BASE="$(dirname "$0")" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 # TODO(hungte) compare if the image really needs to be changed. | 193 # TODO(hungte) compare if the image really needs to be changed. |
| 194 | 194 |
| 195 debug_msg "Check if we need to make backup file(s)" | 195 debug_msg "Check if we need to make backup file(s)" |
| 196 if [ -n "$backup_image" ]; then | 196 if [ -n "$backup_image" ]; then |
| 197 local backup_hwid_name="$(echo "$old_hwid" | sed 's/ /_/g')" | 197 local backup_hwid_name="$(echo "$old_hwid" | sed 's/ /_/g')" |
| 198 local backup_date_time="$(date +'%Y%m%d_%H%M%S')" | 198 local backup_date_time="$(date +'%Y%m%d_%H%M%S')" |
| 199 local backup_file_name="firmware_${backup_hwid_name}_${backup_date_time}.fd" | 199 local backup_file_name="firmware_${backup_hwid_name}_${backup_date_time}.fd" |
| 200 local backup_file_path="$FLAGS_backup_dir/$backup_file_name" | 200 local backup_file_path="$FLAGS_backup_dir/$backup_file_name" |
| 201 if mkdir -p "$FLAGS_backup_dir" && | 201 if mkdir -p "$FLAGS_backup_dir" && |
| 202 cp -f "$backup_image" "$backup_file_path"; then | 202 cp -f "$backup_image" "$backup_file_path"; then |
| 203 echo "Backup of current firmware image is stored in: $backup_file_path" | 203 true |
| 204 elif cp -f "$backup_image" "/tmp/$backup_file_name"; then | |
| 205 backup_file_path="/tmp/$backup_file_name" | |
| 206 else | |
| 207 backup_file_path='' | |
| 208 fi | |
| 209 if [ -n "$backup_file_path" -a -s "$backup_file_path" ]; then | |
| 210 # TODO(hungte) maybe we can wrap the flashrom by 'make_dev_firmware.sh -r' | |
| 211 # so that the only command to remember would be make_dev_firmware.sh. | |
|
Randall Spangler
2010/10/18 15:34:32
Good idea.
| |
| 212 echo " | |
| 213 Backup of current firmware image is stored in: | |
| 214 $backup_file_path | |
| 215 Please copy the backup file to a safe place ASAP. | |
| 216 | |
| 217 To stop using devkeys and restore original firmware, execute command: | |
| 218 flashrom -w [PATH_TO_BACKUP_IMAGE] | |
| 219 Ex: flashrom -w $backup_file_path | |
| 220 " | |
| 204 else | 221 else |
| 205 echo "WARNING: Cannot create file in $FLAGS_backup_dir... Ignore backups." | 222 echo "WARNING: Cannot create file in $FLAGS_backup_dir... Ignore backups." |
| 206 fi | 223 fi |
| 207 fi | 224 fi |
| 208 | 225 |
| 209 # TODO(hungte) use vbutil_firmware to check if the new firmware is valid. | 226 # TODO(hungte) use vbutil_firmware to check if the new firmware is valid. |
| 210 # Or, do verification in resign_firmwarefd.sh and trust it. | 227 # Or, do verification in resign_firmwarefd.sh and trust it. |
| 211 | 228 |
| 212 debug_msg "Write the image" | 229 debug_msg "Write the image" |
| 213 write_image || | 230 write_image || |
| 214 err_die "Failed to write image. Error message: $(cat "$EXEC_LOG")" | 231 err_die "Failed to write image. Error message: $(cat "$EXEC_LOG")" |
| 215 | 232 |
| 216 debug_msg "Complete." | 233 debug_msg "Complete." |
| 217 if [ -z "$FLAGS_to" ]; then | 234 if [ -z "$FLAGS_to" ]; then |
| 218 echo "Successfully changed firmware to Developer Keys. New HWID: $new_hwid" | 235 echo "Successfully changed firmware to Developer Keys. New HWID: $new_hwid" |
| 219 else | 236 else |
| 220 echo "Firmware '$FLAGS_to' now uses Developer Keys. New HWID: $new_hwid" | 237 echo "Firmware '$FLAGS_to' now uses Developer Keys. New HWID: $new_hwid" |
| 221 fi | 238 fi |
| 222 } | 239 } |
| 223 | 240 |
| 224 main | 241 main |
| OLD | NEW |