|
| 1 | +# `armv7a-vex-v5` |
| 2 | + |
| 3 | +**Tier: 3** |
| 4 | + |
| 5 | + |
| 6 | +Allows compiling user programs for the [VEX V5 Brain](https://www.vexrobotics.com/276-4810.html), a microcontroller for educational and competitive robotics. |
| 7 | + |
| 8 | +Rust support for this target is not affiliated with VEX Robotics or IFI, and is not derived from nor used with any official VEX SDK. |
| 9 | + |
| 10 | +## Target maintainers |
| 11 | + |
| 12 | +This target is maintained by members of the [vexide](https://github.com/vexide) organization: |
| 13 | + |
| 14 | +- [@Tropix126](https://github.com/Tropix126) |
| 15 | +- [@Gavin-Niederman](https://github.com/Gavin-Niederman) |
| 16 | +- [@max-niederman](https://github.com/max-niederman) |
| 17 | +- [@doinkythederp](https://github.com/doinkythederp) |
| 18 | + |
| 19 | +## Requirements |
| 20 | + |
| 21 | +This target is cross-compiled. Dynamic linking is unsupported. |
| 22 | + |
| 23 | +`#![no_std]` crates can be built using `build-std` to build `core` and optionally |
| 24 | +`alloc`. Unwinding panics are not yet supported. |
| 25 | + |
| 26 | +`std` is partially implemented, but many modules (such as `thread`, `process`, `net`, etc...) will return errors. An allocator is provided along with partial support for the `time`, `env` and `io` modules. Filesystem operations over SDCard through `std::fs` are partially supported within the restrictions of the user enviornment (e.g. directories cannot be created, filesystem objects cannot be removed). |
| 27 | + |
| 28 | +This target generates binaries in the ELF format that may uploaded to the brain with external tools. |
| 29 | + |
| 30 | +## Building the target |
| 31 | + |
| 32 | +Rust does not ship pre-compiled artifacts for this target. You can use `build-std` feature to build ELF binaries with `std` support. |
| 33 | + |
| 34 | +`.cargo/config.toml`: |
| 35 | + |
| 36 | +```toml |
| 37 | +[build] |
| 38 | +target = "armv7a-vex-v5" |
| 39 | + |
| 40 | +[unstable] |
| 41 | +build-std = ["std", "panic_abort"] |
| 42 | +build-std-features = ["compiler-builtins-mem"] |
| 43 | +``` |
| 44 | + |
| 45 | +## Building Rust programs |
| 46 | + |
| 47 | +The recommended way to build artifacts that can be installed and run on V5 Brain is by using the [cargo-v5](https://github.com/vexide/cargo-v5) tool. This tool wraps the `cargo build` command by supplying arguments necessary to build the target, while also providing uploading functionality. |
| 48 | + |
| 49 | +To install the tool run: |
| 50 | + |
| 51 | +```sh |
| 52 | +cargo install cargo-v5 |
| 53 | +``` |
| 54 | + |
| 55 | +The following fields in your project's `Cargo.toml` are read by `cargo-v5` to configure upload behavior: |
| 56 | + |
| 57 | +```toml |
| 58 | +[package.metadata.v5] |
| 59 | +# Slot number to upload the user program to. This should be from 1-8. |
| 60 | +slot = 1 |
| 61 | +# Program icon/thumbnail that will be displayed on the dashboard. |
| 62 | +icon = "cool-x" |
| 63 | +# Use gzip compression when uploading binaries. |
| 64 | +compress = true |
| 65 | +``` |
| 66 | + |
| 67 | +To build an uploadable BIN file using the release profile, run: |
| 68 | + |
| 69 | +```sh |
| 70 | +cargo v5 build --release |
| 71 | +``` |
| 72 | + |
| 73 | +Programs can also be directly uploaded to the brain over a USB connection after building: |
| 74 | + |
| 75 | +```sh |
| 76 | +cargo v5 upload --release |
| 77 | +``` |
| 78 | + |
| 79 | +## Testing |
| 80 | + |
| 81 | +Binaries built for this target can be run in an emulator (such as [vex-v5-qemu](https://github.com/vexide/vex-v5-qemu)), or uploaded to a device over a USB or bluetooth connection. |
| 82 | + |
| 83 | +The default Rust test runner is not supported. |
| 84 | + |
| 85 | +The Rust test suite for `library/std` is not yet supported. |
| 86 | + |
| 87 | +## Cross-compilation toolchains and C code |
| 88 | + |
| 89 | +This target can be cross-compiled from any host. |
| 90 | + |
| 91 | +This target does not link to C libraries. OS calls are implemented in rust through the [vex-sdk](https://github.com/vexide/vex-sdk) crate. No `libc` or crt0 implementation is present on this target. |
0 commit comments