blob: cc0e160203c14baab2eeb731db21805116250a08 [file] [log] [blame]
# Copyright 2018 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 gathers information about Cr50 Board ID and flags and reports it
# appropriately.
start on started trunksd
# 'cros_config / brand-code' generates a 4 ASCII symbols RLZ brand code.
ascii_rlz="$(cros_config / brand-code)" || status="$?"
if [ "${status}" != 0 ] || [ "${#ascii_rlz}" != 4 ]; then
logger -t "${UPSTART_JOB}" \
"Error: cros_config returned ${status}."
exit 1
# gsctool '-i' option generates output of the following format:
# Board ID space: <hex bid>:<inverted hex bid>:<hex flags>
bid_all="$(gsctool -t -i 2>&1)" || status="$?"
if [ "${status}" != 0 ]; then
logger -t "${UPSTART_JOB}" \
"Error: gsctool status $status, output \"${bid_all}\""
exit 1
# Hex representation of values of interest.
rlz="$(printf "${ascii_rlz}" |
od -tx4 -An --endian=big | awk '{printf "0x"$1}')"
bid="$(printf "${bid_all}" | awk -F': *' '{print "0x"$2}')"
flags="$(printf "${bid_all}" | awk -F: '{printf "0x"$4}')"
# Always report the Cr50 board id type and flags.
metrics_client -s "Platform.Cr50.BoardIdFlags" "${flags}"
metrics_client -s "Platform.Cr50.BoardIdType" "${bid}"
if [ "${bid}" != "${rlz}" ]; then
# Misprogrammed Board ID/RLZ
metrics_client -s "Platform.Cr50.BoardIdOfRlzMismatch" "${bid}"
metrics_client -s "Platform.Cr50.RlzOfBoardIdMismatch" "${rlz}"
metrics_client -s "Platform.Cr50.MatchingBoardId" "${bid}"
# Run the script to set up flash log time base and collect recent log
# entries, if any. This could fail if the currently running Cr50 version
# does not support flash log. Not a big deal, the message will be logged, we
# just ignore the issue here.
/usr/share/cros/ || true
logger -t "${UPSTART_JOB}" "Finished, flags ${flags}, RLZ ${rlz}, bid ${bid}"
end script