Debian Codegraph @

src/vendorcode/google/chromeos/build-snow.sh

raw symbols SCIP
1 #!/bin/sh
2
3 SCRIPT="$0"
4 SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
5
6 OUTPUT="build/coreboot.rom"
7 TMP_DIFF="$SCRIPT_DIR/.image-diff.bin"
8 FLASHROM="/usr/local/sbin/flashrom"
9
10 BL1_NAME="E5250.nbl1.bin"
11 BL1_PATH="3rdparty/blobs/cpu/samsung/exynos5250/"
12 BL1_URL="http://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/exynos-pre-boot-0.0.2-r8.tbz2"
13
14 die() {
15 echo "$*" >&2
16 exit 1
17 }
18
19 create_diff_192k() {
20 local image_file="$1"
21 local diff_file="$2"
22 cp -f "$image_file" "$diff_file"
23 dd if=/dev/zero of=$diff_file bs=1 count=$((192*1024)) conv=notrunc
24 }
25
26 fast_flash_image() {
27 local image_file="$1"
28 local diff_file="$2"
29 dut-control spi2_buf_en:on spi2_buf_on_flex_en:on spi2_vref:pp1800
30 sudo ${FLASHROM} -p ft2232_spi:type=servo-v2,port=a -w "$image_file" -V \
31 --noverify --flash-contents "$diff_file"
32 dut-control spi2_buf_en:off spi2_buf_on_flex_en:off spi2_vref:off
33 }
34
35 get_bl1() {
36 wget "${BL1_URL}" -O /tmp/bl1.tbz2
37 tar jxvf /tmp/bl1.tbz2
38 mkdir -p "${BL1_PATH}"
39 mv "exynos-pre-boot/firmware/${BL1_NAME}" "${BL1_PATH}"
40 rm -rf exynos-pre-boot
41 if [ ! -e "${BL1_PATH}/${BL1_NAME}" ]; then
42 echo "Error getting BL1"
43 exit 1
44 fi
45 }
46
47 is_servod_ready() {
48 ps -C servod >/dev/null 2>&1
49 }
50
51 main() {
52 if [ ! -e "$bl1" ]; then
53 get_bl1
54 fi
55
56 make
57 create_diff_192k "$OUTPUT" "$TMP_DIFF"
58 echo "OK: Generated image (with BL1) in $OUTPUT"
59 if is_servod_ready; then
60 echo "servod detected - flashing into device."
61 fast_flash_image "$OUTPUT" "$TMP_DIFF"
62 echo "OK: Generated and flashed 128k of image into device via servo."
63 else
64 echo "(servod is not running, flashing into device is skipped)"
65 fi
66 }
67
68 set -e
69 main "$@"