summaryrefslogtreecommitdiff
path: root/util/chromeos/gen_test_hwid.sh
blob: 8f3b948a966fb44ca6086e859961ead87d5cb30b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env sh
#
# SPDX-License-Identifier: GPL-2.0-only

main() {
  if [ "$#" != 1 ]; then
    echo "Usage: $0 MAINBOARD_PARTNUMBER" >&2
    exit 1
  fi

  # Generate a test-only ChromeOS HWID v2 string
  local board="$1"
  local prefix="$(echo "${board}" | tr a-z A-Z) TEST"
  # gzip has second-to-last 4 bytes in CRC32.
  local crc32="$(printf "${prefix}" | gzip -1 | tail -c 8 | head -c 4 | \
		 od -An -vtu4 | tr -d '\n' | tail -c 4)"

  echo "${prefix}" "${crc32}"
}
main "$@"