blob: 273a44582182abb8d0554116ce0a667d308345a8 [file] [log] [blame]
David Lattimore60e282a2021-05-26 11:27:48 +10001#!/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
10set -e
11
12PROJECT_ROOT=$(git rev-parse --show-toplevel)
13ROM="${PROJECT_ROOT}/build/hps_platform/soc_rom.bin"
14
David Lattimore8df36762021-11-24 16:07:01 +110015FEATURES=image-transfer,debug-commands
David Lattimoree36e52a2021-11-22 16:49:51 +110016if [ "$TFLM" != "0" ]; then
David Lattimoreeeb31152021-11-24 17:34:48 +110017 FEATURES+=,tflm
David Lattimoree36e52a2021-11-22 16:49:51 +110018fi
19
David Lattimore28a33812021-11-17 09:26:31 +110020cd "${PROJECT_ROOT}/rust/riscv"
David Lattimoree36e52a2021-11-22 16:49:51 +110021BUILD_FLAGS=(
22 -p fpga_rom
23 --release
24 --no-default-features
25 --features "${FEATURES}")
David Lattimore60e282a2021-05-26 11:27:48 +100026# Build first, since if there are errors, `cargo objcopy` won't report them in a
27# useful way.
David Lattimore1d6660f2021-11-16 22:07:34 +110028cargo build "${BUILD_FLAGS[@]}"
29cargo objcopy "${BUILD_FLAGS[@]}" -- -O binary "${ROM}"
David Lattimore60e282a2021-05-26 11:27:48 +100030"${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 "$@"