| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | SCRIPT="$0" |
| 4 | SCRIPT_DIR="$(dirnamescip-shell system . . dirname. "$(readlinkscip-shell system . . readlink. -f "$0")")" |
| 5 | |
| 6 | OUTPUT="build/coreboot.rom" |
| 7 | TMP_DIFF="$SCRIPT_DIR/.image-diff.bin" |
| 8 | FLASHROM="/usr/local/sbin/flashromscip-shell filesystem . . `/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 | diescip-shell shell coreboot 25.09+dfsg-1 die().() { |
| 15 | echoscip-shell system . . echo. "$*" >&2 |
| 16 | exit 1 |
| 17 | } |
| 18 | |
| 19 | create_diff_192kscip-shell shell coreboot 25.09+dfsg-1 create_diff_192k().() { |
| 20 | local image_file="$1" |
| 21 | local diff_file="$2" |
| 22 | cpscip-shell system . . cp. -f "$image_file" "$diff_file" |
| 23 | ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$diff_file bs=1 count=$((192*1024)) conv=notrunc |
| 24 | } |
| 25 | |
| 26 | fast_flash_imagescip-shell shell coreboot 25.09+dfsg-1 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 | sudoscip-shell system . . 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_bl1scip-shell shell coreboot 25.09+dfsg-1 get_bl1().() { |
| 36 | wget "${BL1_URL}" -O /tmp/bl1.tbz2scip-shell filesystem . . `/tmp/bl1.tbz2`. |
| 37 | tarscip-shell system . . tar. jxvf /tmp/bl1.tbz2scip-shell filesystem . . `/tmp/bl1.tbz2`. |
| 38 | mkdirscip-shell system . . mkdir. -p "${BL1_PATH}" |
| 39 | mvscip-shell system . . mv. "exynos-pre-boot/firmware/${BL1_NAME}" "${BL1_PATH}" |
| 40 | rmscip-shell system . . rm. -rf exynos-pre-boot |
| 41 | if [scip-shell system . . `[`. ! -e "${BL1_PATH}/${BL1_NAME}" ]; then |
| 42 | echoscip-shell system . . echo. "Error getting BL1" |
| 43 | exit 1 |
| 44 | fi |
| 45 | } |
| 46 | |
| 47 | is_servod_readyscip-shell shell coreboot 25.09+dfsg-1 is_servod_ready().() { |
| 48 | psscip-shell system . . ps. -C servod >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 49 | } |
| 50 | |
| 51 | mainscip-shell shell coreboot 25.09+dfsg-1 main().() { |
| 52 | if [scip-shell system . . `[`. ! -e "$bl1" ]; then |
| 53 | get_bl1scip-shell shell coreboot 25.09+dfsg-1 get_bl1(). |
| 54 | fi |
| 55 | |
| 56 | makescip-shell system . . make. |
| 57 | create_diff_192kscip-shell shell coreboot 25.09+dfsg-1 create_diff_192k(). "$OUTPUT" "$TMP_DIFF" |
| 58 | echoscip-shell system . . echo. "OK: Generated image (with BL1) in $OUTPUT" |
| 59 | if is_servod_readyscip-shell shell coreboot 25.09+dfsg-1 is_servod_ready().; then |
| 60 | echoscip-shell system . . echo. "servod detected - flashing into device." |
| 61 | fast_flash_imagescip-shell shell coreboot 25.09+dfsg-1 fast_flash_image(). "$OUTPUT" "$TMP_DIFF" |
| 62 | echoscip-shell system . . echo. "OK: Generated and flashed 128k of image into device via servo." |
| 63 | else |
| 64 | echoscip-shell system . . echo. "(servod is not running, flashing into device is skipped)" |
| 65 | fi |
| 66 | } |
| 67 | |
| 68 | set -e |
| 69 | mainscip-shell shell coreboot 25.09+dfsg-1 main(). "$@" |