blob: fc458c7a7d3844cb55953728ea1c8d71fb0a2edf [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
15cd "${PROJECT_ROOT}/mcu_rom/riscv"
David Lattimore1d6660f2021-11-16 22:07:34 +110016BUILD_FLAGS=(-p fpga_rom --release --features image-transfer)
David Lattimore60e282a2021-05-26 11:27:48 +100017# Build first, since if there are errors, `cargo objcopy` won't report them in a
18# useful way.
David Lattimore1d6660f2021-11-16 22:07:34 +110019cargo build "${BUILD_FLAGS[@]}"
20cargo objcopy "${BUILD_FLAGS[@]}" -- -O binary "${ROM}"
David Lattimore60e282a2021-05-26 11:27:48 +100021"${PROJECT_ROOT}/scripts/hps-mon" \
22 --openocd-port 4444 \
23 --gateware "${PROJECT_ROOT}/build/hps_platform/gateware/hps_platform.bit" \
24 --soc-rom "${ROM}" \
25 --cmd 'reset_mcu; write_soc_rom; reset_fpga' \
26 "$@"