You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/rustc/src/platform-support/armv7a-vex-v5.md
+94-9Lines changed: 94 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,14 @@
4
4
5
5
Allows compiling user programs for the [VEX V5 Brain](https://www.vexrobotics.com/276-4810.html), a microcontroller for educational and competitive robotics.
6
6
7
-
Rust support for this target is not affiliated with VEX Robotics or IFI, and does not link to any official VEX SDK.
7
+
Rust support for this target is not affiliated with VEX Robotics or IFI, and does not link against any official VEX SDK.
8
8
9
9
## Target maintainers
10
10
11
11
This target is maintained by members of the [vexide](https://github.com/vexide) organization:
@@ -22,27 +22,37 @@ This target is cross-compiled. Dynamic linking is unsupported.
22
22
`#![no_std]` crates can be built using `build-std` to build `core` and `panic_abort` and optionally `alloc`. Unwinding panics are not yet supported on this target.
23
23
24
24
`std` has only partial support due to platform limitations. Notably:
25
+
25
26
-`std::process` and `std::net` are unimplemented. `std::thread` only supports sleeping and yielding, as this is a single-threaded environment.
26
27
-`std::time` has full support for `Instant`, but no support for `SystemTime`.
27
28
-`std::io` has full support for `stdin`/`stdout`/`stderr`. `stdout` and `stderr` both write to USB channel 1 on this platform and are not differentiated.
28
-
-`std::fs` has limited support for reading or writing to files. Directory operations, file deletion, and some file opening features are unsupported and will return errors.
29
+
-`std::fs` has limited support for reading or writing to files. The following features are unsupported:
30
+
- All directory operations (including `mkdir` and `readdir`), although reading directories is possible through [third-party crates](https://docs.rs/vex-sdk/latest/vex_sdk/file/fn.vexFileDirectoryGet.html)
31
+
- Deleting files and directories
32
+
- File metadata other than file size and type (that is, file vs. directory)
33
+
- Opening files with an uncommon combination of open options, such as read + write at the same time.
34
+
The supported modes for opening files are in read-only mode, append mode, or write mode (with or without truncation).
29
35
- A global allocator implemented on top of `dlmalloc` is provided.
30
-
- Modules that do not need to interact with the OS beyond allocation such as `std::collections`, `std::hash`, `std::future`, `std::sync`, etc are fully supported.
36
+
- Modules that do not need to interact with the OS beyond allocation, such as `std::collections`, `std::hash`, `std::future`, `std::sync`, etc., are fully supported.
31
37
- Random number generation and hashing is insecure, as there is no reliable source of entropy on this platform.
32
38
33
-
In order to support some APIs, users are expected to provide a supporting runtime SDK for `libstd` to link against. This library may be provided either by [`vex-sdk-build`](https://github.com/vexide/vex-sdk/tree/main/packages/vex-sdk-build) (which will download an official SDK from VEX) or through an open-source implementation such as [`vex-sdk-jumptable`](https://crates.io/crates/vex-sdk-jumptable).
34
-
35
39
When compiling for this target, the "C" calling convention maps to AAPCS with VFP registers (hard float ABI) and the "system" calling convention maps to AAPCS without VFP registers (softfp ABI).
36
40
37
41
This target generates binaries in the ELF format that may be uploaded to the brain with external tools.
38
42
43
+
### Platform SDKs
44
+
45
+
To use most platform-specific APIs, users must configure a supporting runtime SDK for `libstd` to link against. Official *VEXcode* SDKs from VEX can be downloaded and linked via the [`vex-sdk-vexcode`](https://crates.io/crates/vex-sdk-vexcode) crate, but they have a restrictive redistribution policy that might not be suitable for all projects. The suggested SDK for open-source projects is the community-supported [`vex-sdk-jumptable`](https://crates.io/crates/vex-sdk-jumptable) crate. SDK implementations are generally thin wrappers over system calls, so projects should not expect to see significant differences in behavior depending on which SDK they use.
46
+
47
+
Libraries may access symbols from the active VEX SDK without depending on a specific implementation by using the [`vex-sdk`](https://crates.io/crates/vex-sdk) crate.
48
+
39
49
## Building the target
40
50
41
51
You can build Rust with support for this target by adding it to the `target` list in `bootstrap.toml`, and then running `./x build --target armv7a-vex-v5 compiler`.
42
52
43
53
## Building Rust programs
44
54
45
-
Rust does not yet ship pre-compiled artifacts for this target. To compile for this target, you will either need to build Rust with the target enabled (see "Building the target" above), or build your own copy of `core` by using `build-std` or similar.
55
+
Rust does not yet ship pre-compiled artifacts for this target. To compile for this target, you will either need to build Rust with the target enabled (see "Building the target" above), or build your own copy of `std` using `build-std` or similar.
46
56
47
57
When the compiler builds a binary, an ELF build artifact will be produced. Additional tools are required for this artifact to be recognizable to VEXos as a user program.
48
58
@@ -78,9 +88,19 @@ Programs can also be directly uploaded to the brain over a USB connection immedi
78
88
cargo v5 upload --release
79
89
```
80
90
91
+
### Hello World program
92
+
93
+
```rs
94
+
use::vex_sdk_jumptable as _; // Bring VEX SDK symbols into scope
95
+
96
+
fnmain() {
97
+
println!("Hello, world");
98
+
}
99
+
```
100
+
81
101
## Testing
82
102
83
-
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 physical device over a serial (USB) connection.
103
+
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 physical device over a USB serial connection.
84
104
85
105
The default Rust test runner is not supported.
86
106
@@ -90,4 +110,69 @@ The Rust test suite for `library/std` is not yet supported.
90
110
91
111
This target can be cross-compiled from any host.
92
112
93
-
Linking to C libraries is not supported.
113
+
The recommended configuration for compiling compatible C code is to use the [Arm Toolchain for Embedded](https://github.com/arm/arm-toolchain/tree/arm-software/arm-software/embedded#readme) with the following compilation flags:
You may have to implement [certain system support functions](https://github.com/picolibc/picolibc/blob/main/doc/os.md) for some parts of libc to work properly.
0 commit comments