| # Copyright 2016 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| # |
| # This script processes exit values of the gsctool utility ran by |
| # cr50-update.conf. See it for details of exit code values. |
| |
| description "Startup file to process cr50 firmware updater exit status" |
| author "chromium-os-dev@chromium.org" |
| |
| start on stopped cr50-update |
| |
| script |
| |
| logit() { |
| logger -t ${UPSTART_JOB} "$*" |
| } |
| |
| case ${EXIT_STATUS} in |
| (0) |
| ;; |
| (10[12]) |
| logit "reboot required ${EXIT_STATUS}" |
| reboot |
| ;; |
| (*) |
| logit "unexpected cr50-update exit code ${EXIT_STATUS}" |
| ;; |
| esac |
| |
| |
| # Only check and set Board ID in normal mode without debug features turned on. |
| if ! crossystem 'mainfw_type?normal' 'cros_debug?0'; then |
| exit 0 |
| fi |
| |
| # and only if the device has been finalized, as evidenced by the software |
| # write protect status. |
| exit_status=0 |
| flash_status="$(flashrom --wp-status)" || exit_status="$?" |
| if [ "${exit_status}" != "0" ]; then |
| logit "flashrom invocation failed: \"${flash_status}\"" |
| exit "${exit_status}" |
| fi |
| |
| if echo "${flash_status}" | grep -q 'write protect is disabled'; then |
| logit "write protection is disabled, not checking Board ID settings" |
| exit 0 |
| fi |
| |
| logit "Will check Board ID settings" |
| |
| # Set flag to 'unknown' if board ID hasen't been set. |
| # Note that this flag should normally be set in the factory flow. |
| logit "$(/usr/share/cros/cr50-set-board-id.sh 'unknown')" |
| end script |