Hung-Te Lin | 117453e | 2019-09-27 12:23:20 +0800 | [diff] [blame] | 1 | #!/bin/sh |
Hung-Te Lin | 117453e | 2019-09-27 12:23:20 +0800 | [diff] [blame] | 2 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
Hung-Te Lin | 117453e | 2019-09-27 12:23:20 +0800 | [diff] [blame] | 4 | |
| 5 | main() { |
| 6 | if [ "$#" != 1 ]; then |
| 7 | echo "Usage: $0 MAINBOARD_PARTNUMBER" >&2 |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | # Generate a test-only Chrome OS HWID v2 string |
| 12 | local board="$1" |
| 13 | local prefix="$(echo "${board}" | tr a-z A-Z) TEST" |
| 14 | # gzip has second-to-last 4 bytes in CRC32. |
| 15 | local crc32="$(printf "${prefix}" | gzip -1 | tail -c 8 | head -c 4 | \ |
| 16 | hexdump -e '1/4 "%04u" ""' | tail -c 4)" |
| 17 | |
| 18 | echo "${prefix}" "${crc32}" |
| 19 | } |
| 20 | main "$@" |