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 | |
| 14 | FEATURES="${FEATURES-tflm}" |
| 15 | |
| 16 | cd "${PROJECT_ROOT}/rust/riscv" |
| 17 | BUILD_FLAGS=( |
| 18 | -p fpga_rom |
| 19 | --release |
| 20 | --no-default-features |
| 21 | --features "${FEATURES}") |
| 22 | |
| 23 | cargo build "${BUILD_FLAGS[@]}" |
| 24 | |
| 25 | # We use our own version of objcopy rather than `cargo objcopy` because the |
| 26 | # objcopy that comes with rust 1.55.0 seems to result in a non-functional 2.7MB |
| 27 | # binary rather than a functional 0.7MB binary. Most likely the binary is |
| 28 | # starting from address 0 rather than address 2M like it's supposed to. This |
| 29 | # appears to have been fixed with rust 1.56, but we're not using that yet. |
| 30 | "${PROJECT_ROOT}/third_party/installed/bin/riscv64-unknown-elf-objcopy" \ |
| 31 | "target/riscv32i-unknown-none-elf/release/fpga_rom" \ |
| 32 | -O binary \ |
| 33 | "${ROM}" |