David Lattimore | 42b2bb1 | 2022-01-06 08:58:29 +1100 | [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 the Rust FPGA ROM. |
| 8 | |
| 9 | set -e |
| 10 | |
| 11 | PROJECT_ROOT=$(git rev-parse --show-toplevel) |
| 12 | ROM="${PROJECT_ROOT}/build/hps_platform/fpga_rom.bin" |
| 13 | |
David Lattimore | 3e6d4f1 | 2022-07-18 11:58:13 +1000 | [diff] [blame^] | 14 | # If we're outside the chroot, rerun inside. |
| 15 | if [ ! -e /etc/cros_chroot_version ] ; then |
| 16 | exec "${PROJECT_ROOT}/scripts/run-tool" "$0" "$@" |
| 17 | fi |
| 18 | |
David Lattimore | 42b2bb1 | 2022-01-06 08:58:29 +1100 | [diff] [blame] | 19 | FEATURES="${FEATURES-tflm}" |
| 20 | |
Dan Callaghan | 30a4ee2 | 2022-01-10 19:16:25 +1100 | [diff] [blame] | 21 | source "${PROJECT_ROOT}/environment" |
| 22 | |
David Lattimore | 42b2bb1 | 2022-01-06 08:58:29 +1100 | [diff] [blame] | 23 | cd "${PROJECT_ROOT}/rust/riscv" |
| 24 | BUILD_FLAGS=( |
| 25 | -p fpga_rom |
| 26 | --release |
| 27 | --no-default-features |
| 28 | --features "${FEATURES}") |
| 29 | |
| 30 | cargo build "${BUILD_FLAGS[@]}" |
| 31 | |
Dan Callaghan | 30a4ee2 | 2022-01-10 19:16:25 +1100 | [diff] [blame] | 32 | "${OBJCOPY-llvm-objcopy}" \ |
David Lattimore | 42b2bb1 | 2022-01-06 08:58:29 +1100 | [diff] [blame] | 33 | "target/riscv32i-unknown-none-elf/release/fpga_rom" \ |
| 34 | -O binary \ |
| 35 | "${ROM}" |