diff options
Diffstat (limited to 'scripts/image_signing/set_gbb_flags.sh')
-rwxr-xr-x | scripts/image_signing/set_gbb_flags.sh | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/image_signing/set_gbb_flags.sh b/scripts/image_signing/set_gbb_flags.sh index 7a22b85f..3057da57 100755 --- a/scripts/image_signing/set_gbb_flags.sh +++ b/scripts/image_signing/set_gbb_flags.sh @@ -13,6 +13,8 @@ SCRIPT_BASE="$(dirname "$0")" # DEFINE_string name default_value description flag DEFINE_string file "" "Path to firmware image. Default to system firmware." "f" DEFINE_boolean check_wp ${FLAGS_TRUE} "Check write protection states first." "" +DEFINE_string programmer "host" "Programmer to use when setting GBB flags" "p" +DEFINE_boolean servo "${FLAGS_FALSE}" "Determine programmer using servo" "" set -e @@ -20,12 +22,13 @@ set -e # ---------------------------------------------------------------------------- check_write_protection() { local hw_wp="" sw_wp="" - if ! crossystem "wpsw_cur?0"; then + local programmer="$1" + if [ "${programmer}" = "host" ] && ! crossystem "wpsw_cur?0"; then hw_wp="on" fi # Keep 'local' declaration split from assignment so return code is checked. local wp_states - wp_states="$(flashrom -p host --wp-status 2>/dev/null | grep WP)" + wp_states="$(flashrom -p "${programmer}" --wp-status 2>/dev/null | grep WP)" local wp_disabled="$(echo "${wp_states}" | grep "WP:.*is disabled.")" local wp_zero_len="$(echo "${wp_states}" | grep "WP:.*, len=0x00000000")" if [ -z "${wp_disabled}" -a -z "${wp_zero_len}" ]; then @@ -47,10 +50,15 @@ main() { local value="$(($1))" local image_file="${FLAGS_file}" + local programmer="${FLAGS_programmer}" if [ -z "${FLAGS_file}" ]; then image_file="$(make_temp_file)" - flashrom_read "${image_file}" + if [ "${FLAGS_servo}" = "${FLAGS_TRUE}" ]; then + programmer=$(get_programmer_for_servo) + fi + + flashrom_read "${image_file}" "${programmer}" fi # Process file @@ -62,14 +70,14 @@ main() { if [ -z "${FLAGS_file}" ]; then if [ "${FLAGS_check_wp}" = "${FLAGS_TRUE}" ]; then - if ! check_write_protection; then + if ! check_write_protection "${programmer}"; then echo "" echo "WARNING: System GBB Flags are NOT changed!!!" echo "ERROR: You must disable write protection before setting flags." exit 1 fi fi - flashrom_write "$image_file" + flashrom_write "${image_file}" "${programmer}" fi } |