David Lattimore | 60e282a | 2021-05-26 11:27:48 +1000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2021 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Builds and runs the Rust SOC ROM. ./scripts/proto2-run should already be |
| 8 | # running in a separate shell. |
| 9 | |
| 10 | set -e |
| 11 | |
| 12 | PROJECT_ROOT=$(git rev-parse --show-toplevel) |
| 13 | ROM="${PROJECT_ROOT}/build/hps_platform/soc_rom.bin" |
| 14 | |
David Lattimore | 8df3676 | 2021-11-24 16:07:01 +1100 | [diff] [blame] | 15 | FEATURES=image-transfer,debug-commands |
David Lattimore | e36e52a | 2021-11-22 16:49:51 +1100 | [diff] [blame] | 16 | if [ "$TFLM" != "0" ]; then |
David Lattimore | eeb3115 | 2021-11-24 17:34:48 +1100 | [diff] [blame^] | 17 | FEATURES+=,tflm |
David Lattimore | e36e52a | 2021-11-22 16:49:51 +1100 | [diff] [blame] | 18 | fi |
| 19 | |
David Lattimore | 28a3381 | 2021-11-17 09:26:31 +1100 | [diff] [blame] | 20 | cd "${PROJECT_ROOT}/rust/riscv" |
David Lattimore | e36e52a | 2021-11-22 16:49:51 +1100 | [diff] [blame] | 21 | BUILD_FLAGS=( |
| 22 | -p fpga_rom |
| 23 | --release |
| 24 | --no-default-features |
| 25 | --features "${FEATURES}") |
David Lattimore | 60e282a | 2021-05-26 11:27:48 +1000 | [diff] [blame] | 26 | # Build first, since if there are errors, `cargo objcopy` won't report them in a |
| 27 | # useful way. |
David Lattimore | 1d6660f | 2021-11-16 22:07:34 +1100 | [diff] [blame] | 28 | cargo build "${BUILD_FLAGS[@]}" |
| 29 | cargo objcopy "${BUILD_FLAGS[@]}" -- -O binary "${ROM}" |
David Lattimore | 60e282a | 2021-05-26 11:27:48 +1000 | [diff] [blame] | 30 | "${PROJECT_ROOT}/scripts/hps-mon" \ |
| 31 | --openocd-port 4444 \ |
| 32 | --gateware "${PROJECT_ROOT}/build/hps_platform/gateware/hps_platform.bit" \ |
| 33 | --soc-rom "${ROM}" \ |
| 34 | --cmd 'reset_mcu; write_soc_rom; reset_fpga' \ |
| 35 | "$@" |