Patrick Williams | e7162a0 | 2021-03-16 00:06:54 -0500 | [diff] [blame] | 1 | #!/bin/bash |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 2 | |
| 3 | set -eu |
| 4 | set -x |
| 5 | |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 6 | ARTIFACT_DIR=$(mktemp -d) |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 7 | |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 8 | trap 'rm -rf ${ARTIFACT_DIR}' EXIT |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 9 | |
Patrick Williams | 476a7e9 | 2022-12-06 09:52:53 -0600 | [diff] [blame] | 10 | function acquire() { |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 11 | local target="$1" |
| 12 | wget --quiet --show-progress --directory-prefix="${ARTIFACT_DIR}" https://jenkins.openbmc.org/view/latest/job/latest-master/lastSuccessfulBuild/label=docker-builder,target="${target}"/artifact/openbmc/build/tmp/deploy/images/"${target}"/'*zip*'/"${target}".zip |
| 13 | unzip -qq -d "${ARTIFACT_DIR}" "${ARTIFACT_DIR}"/"${target}".zip |
| 14 | echo "${ARTIFACT_DIR}"/"${target}" |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 15 | } |
| 16 | |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 17 | # AST2400 |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 18 | PALMETTO_ARTIFACTS="$(acquire palmetto)" |
| 19 | PALMETTO_MTD="$(echo "${PALMETTO_ARTIFACTS}"/obmc-phosphor-image-palmetto-*.static.mtd)" |
Patrick Williams | e7162a0 | 2021-03-16 00:06:54 -0500 | [diff] [blame] | 20 | # shellcheck disable=SC2016 # 'expect' strings |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 21 | expect \ |
| 22 | -c "spawn qemu-system-arm \ |
| 23 | -M palmetto-bmc \ |
| 24 | -drive file=${PALMETTO_MTD},if=mtd,format=raw \ |
| 25 | -nographic \ |
| 26 | -net nic \ |
Patrick Williams | 476a7e9 | 2022-12-06 09:52:53 -0600 | [diff] [blame] | 27 | -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu" \ |
Andrew Jeffery | 7d6ee0b | 2022-05-02 10:04:48 +0930 | [diff] [blame] | 28 | -c 'set timeout 300' \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 29 | -c 'expect timeout { exit 1 } "login:"' \ |
Andrew Jeffery | 0e47d12 | 2022-05-02 10:08:11 +0930 | [diff] [blame] | 30 | -c 'spawn sshpass -p 0penBmc ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p2222 root@localhost journalctl -b' \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 31 | -c 'expect -i $spawn_id eof' |
| 32 | |
| 33 | # AST2500 |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 34 | WITHERSPOON_ARTIFACTS="$(acquire witherspoon)" |
| 35 | WITHERSPOON_MTD="$(echo "${WITHERSPOON_ARTIFACTS}"/obmc-phosphor-image-witherspoon-*.ubi.mtd)" |
Patrick Williams | e7162a0 | 2021-03-16 00:06:54 -0500 | [diff] [blame] | 36 | # shellcheck disable=SC2016 # 'expect' strings |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 37 | expect \ |
| 38 | -c "spawn qemu-system-arm \ |
| 39 | -M witherspoon-bmc \ |
| 40 | -drive file=${WITHERSPOON_MTD},if=mtd,format=raw \ |
| 41 | -nographic \ |
| 42 | -net nic \ |
Patrick Williams | 476a7e9 | 2022-12-06 09:52:53 -0600 | [diff] [blame] | 43 | -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu" \ |
Andrew Jeffery | 7d6ee0b | 2022-05-02 10:04:48 +0930 | [diff] [blame] | 44 | -c 'set timeout 300' \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 45 | -c 'expect timeout { exit 1 } "login:"' \ |
Andrew Jeffery | 0e47d12 | 2022-05-02 10:08:11 +0930 | [diff] [blame] | 46 | -c 'spawn sshpass -p 0penBmc ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p2222 root@localhost journalctl -b' \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 47 | -c 'expect -i $spawn_id eof' |
| 48 | |
| 49 | # AST2600 |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 50 | P10BMC_ARTIFACTS="$(acquire p10bmc)" |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 51 | |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 52 | P10BMC_WIC_XZ="$(echo "${P10BMC_ARTIFACTS}"/obmc-phosphor-image-p10bmc-*.wic.xz)" |
| 53 | P10BMC_MMC="${P10BMC_WIC_XZ%.xz}" |
| 54 | P10BMC_UBOOT_SPL="$(echo "${P10BMC_ARTIFACTS}"/u-boot-spl.bin-*)" |
| 55 | P10BMC_UBOOT="$(echo "${P10BMC_ARTIFACTS}"/u-boot-p10bmc-*.bin)" |
| 56 | |
| 57 | dd of="$P10BMC_MMC" if=/dev/zero bs=1M count=2 |
| 58 | dd of="$P10BMC_MMC" if="$P10BMC_UBOOT_SPL" conv=notrunc |
| 59 | dd of="$P10BMC_MMC" if="$P10BMC_UBOOT" conv=notrunc bs=1K seek=64 |
| 60 | |
| 61 | xz --decompress --stdout --keep "$P10BMC_WIC_XZ" | dd of="$P10BMC_MMC" conv=notrunc bs=1M seek=2 |
| 62 | |
| 63 | truncate -s 16G "$P10BMC_MMC" |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 64 | |
Patrick Williams | e7162a0 | 2021-03-16 00:06:54 -0500 | [diff] [blame] | 65 | # shellcheck disable=SC2016 # 'expect' strings |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 66 | expect \ |
Andrew Jeffery | 7d2c27f | 2022-05-02 10:11:20 +0930 | [diff] [blame] | 67 | -c "spawn qemu-system-arm -M rainier-bmc \ |
| 68 | -drive file=${P10BMC_MMC},if=sd,format=raw,index=2 \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 69 | -net nic \ |
| 70 | -net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu \ |
Patrick Williams | 476a7e9 | 2022-12-06 09:52:53 -0600 | [diff] [blame] | 71 | -nographic" \ |
Andrew Jeffery | 7d6ee0b | 2022-05-02 10:04:48 +0930 | [diff] [blame] | 72 | -c 'set timeout 300' \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 73 | -c 'expect timeout { exit 1 } "login:"' \ |
Andrew Jeffery | 0e47d12 | 2022-05-02 10:08:11 +0930 | [diff] [blame] | 74 | -c 'spawn sshpass -p 0penBmc ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p2222 root@localhost journalctl -b' \ |
Andrew Jeffery | 0eb7ce0 | 2021-01-15 22:47:22 +1030 | [diff] [blame] | 75 | -c 'expect -i $spawn_id eof' |