blob: 1348e3db35c12a7ae59b2312d248fd03cc7e2927 [file] [log] [blame]
David Lattimore42b2bb12022-01-06 08:58:29 +11001#!/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 the Rust FPGA ROM.
8
9set -e
10
11PROJECT_ROOT=$(git rev-parse --show-toplevel)
12ROM="${PROJECT_ROOT}/build/hps_platform/fpga_rom.bin"
13
David Lattimore3e6d4f12022-07-18 11:58:13 +100014# If we're outside the chroot, rerun inside.
15if [ ! -e /etc/cros_chroot_version ] ; then
16 exec "${PROJECT_ROOT}/scripts/run-tool" "$0" "$@"
17fi
18
David Lattimore42b2bb12022-01-06 08:58:29 +110019FEATURES="${FEATURES-tflm}"
20
Dan Callaghan30a4ee22022-01-10 19:16:25 +110021source "${PROJECT_ROOT}/environment"
22
David Lattimore42b2bb12022-01-06 08:58:29 +110023cd "${PROJECT_ROOT}/rust/riscv"
24BUILD_FLAGS=(
25 -p fpga_rom
26 --release
27 --no-default-features
28 --features "${FEATURES}")
29
30cargo build "${BUILD_FLAGS[@]}"
31
Dan Callaghan30a4ee22022-01-10 19:16:25 +110032"${OBJCOPY-llvm-objcopy}" \
David Lattimore42b2bb12022-01-06 08:58:29 +110033 "target/riscv32i-unknown-none-elf/release/fpga_rom" \
34 -O binary \
35 "${ROM}"