blob: 44f3ce8482ab4abed4f507e70a41e09740295da8 [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
14FEATURES="${FEATURES-tflm}"
15
16cd "${PROJECT_ROOT}/rust/riscv"
17BUILD_FLAGS=(
18 -p fpga_rom
19 --release
20 --no-default-features
21 --features "${FEATURES}")
22
23cargo 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}"