summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/image_signing/gbb_flags_common.sh45
-rwxr-xr-xscripts/image_signing/get_gbb_flags.sh8
-rwxr-xr-xscripts/image_signing/set_gbb_flags.sh18
3 files changed, 63 insertions, 8 deletions
diff --git a/scripts/image_signing/gbb_flags_common.sh b/scripts/image_signing/gbb_flags_common.sh
index 63c3f12a..ed51f153 100755
--- a/scripts/image_signing/gbb_flags_common.sh
+++ b/scripts/image_signing/gbb_flags_common.sh
@@ -51,9 +51,50 @@ FLAGS_HELP="Manages Chrome OS Firmware GBB Flags value.
${GBBFLAGS_DESCRIPTION}"
flashrom_read() {
- flashrom -p host -i GBB -r "$@"
+ local file="$1"
+ local programmer="$2"
+ flashrom -p "${programmer}" -i GBB -i FMAP -r "${file}"
}
flashrom_write() {
- flashrom -p host -i GBB --noverify-all -w "$@"
+ local file="$1"
+ local programmer="$2"
+ flashrom -p "${programmer}" -i GBB --noverify-all -w "${file}"
+}
+
+get_programmer_for_servo() {
+ local servo_type
+ local serial
+ local programmer
+ servo_type=$(dut-control -o servo_type 2>/dev/null) || \
+ die "Failed to get servo information. Is servod running?"
+ case "${servo_type}" in
+ *with_servo_micro*)
+ serial=$(dut-control -o servo_micro_serialname 2>/dev/null)
+ ;;
+ *with_c2d2*)
+ serial=$(dut-control -o c2d2_serialname 2>/dev/null)
+ ;;
+ *with_ccd*)
+ serial=$(dut-control -o ccd_serialname 2>/dev/null)
+ ;;
+ *)
+ serial=$(dut-control -o serialname 2>/dev/null)
+ ;;
+ esac
+ case "${servo_type}" in
+ *servo_micro*|*c2d2*)
+ # TODO(sammc): Support servo micro, servo v2 and C2D2. This requires
+ # toggling cpu_fw_spi via dut-control before and after running flashrom.
+ # C2D2 additionally requires a working cpu_fw_spi implementation.
+ die "Unsupported servo type ${servo_type}"
+ ;;
+ *ccd_cr50*|*ccd_gsc*)
+ programmer="raiden_debug_spi:target=AP,serial=${serial}"
+ ;;
+ *)
+ die "Unsupported servo type ${servo_type}"
+ ;;
+ esac
+ echo "${programmer}"
}
diff --git a/scripts/image_signing/get_gbb_flags.sh b/scripts/image_signing/get_gbb_flags.sh
index 2b78af61..1191e9f7 100755
--- a/scripts/image_signing/get_gbb_flags.sh
+++ b/scripts/image_signing/get_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 explicit ${FLAGS_FALSE} "Print list of what flags are set." "e"
+DEFINE_string programmer "host" "Programmer to use when setting GBB flags" "p"
+DEFINE_boolean servo "${FLAGS_FALSE}" "Determine programmer using servo" ""
set -e
@@ -23,10 +25,14 @@ main() {
fi
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.
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
}