|
| 1 | +# `armv5te-none-eabi` |
| 2 | + |
| 3 | +**Tier: 3** |
| 4 | + |
| 5 | +Bare-metal target for any cpu in the ARMv5TE architecture family, supporting |
| 6 | +ARM/Thumb code interworking (aka `a32`/`t32`), with ARM code as the default code |
| 7 | +generation. |
| 8 | + |
| 9 | +The `thumbv5te-none-eabi` target is the same as this one, but with THUMB code as the default. |
| 10 | + |
| 11 | +In particular this supports the main CPU of the Nintendo DS, but there's nothing DS |
| 12 | +specific with this target, so any ARMv5TE device should work fine. |
| 13 | + |
| 14 | +## Target Maintainers |
| 15 | + |
| 16 | +* [@QuinnPainter](https://github.com/QuinnPainter) |
| 17 | + |
| 18 | +## Requirements |
| 19 | + |
| 20 | +The target is cross-compiled, and uses static linking. |
| 21 | + |
| 22 | +By default, the `lld` linker included with Rust will be used. |
| 23 | + |
| 24 | +However, you may want to use the `arm-none-eabi-ld` linker instead. This can be obtained for Windows/Mac/Linux from the [ARM |
| 25 | +Developer Website][arm-dev], or possibly from your OS's package manager. To use it, add the following to your `.cargo/config.toml`: |
| 26 | + |
| 27 | +```toml |
| 28 | +[target.armv5te-none-eabi] |
| 29 | +linker = "arm-none-eabi-ld" |
| 30 | +``` |
| 31 | + |
| 32 | +[arm-dev]: https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain |
| 33 | + |
| 34 | +This target doesn't provide a linker script, you'll need to bring your own |
| 35 | +according to the specific device you want to target. Pass |
| 36 | +`-Clink-arg=-Tyour_script.ld` as a rustc argument to make the linker use |
| 37 | +`your_script.ld` during linking. |
| 38 | + |
| 39 | +## Building Rust Programs |
| 40 | + |
| 41 | +Because it is Tier 3, rust does not yet ship pre-compiled artifacts for this target. |
| 42 | + |
| 43 | +Just use the `build-std` nightly cargo feature to build the `core` library. You |
| 44 | +can pass this as a command line argument to cargo, or your `.cargo/config.toml` |
| 45 | +file might include the following lines: |
| 46 | + |
| 47 | +```toml |
| 48 | +[unstable] |
| 49 | +build-std = ["core"] |
| 50 | +``` |
| 51 | + |
| 52 | +Most of `core` should work as expected, with the following notes: |
| 53 | +* the target is "soft float", so `f32` and `f64` operations are emulated in |
| 54 | + software. |
| 55 | +* integer division is also emulated in software. |
| 56 | +* the target is old enough that it doesn't have atomic instructions. |
| 57 | + |
| 58 | +`alloc` is also supported, as long as you provide your own global allocator. |
| 59 | + |
| 60 | +Rust programs are output as ELF files. |
| 61 | + |
| 62 | +For running on DS hardware, you'll need to use an external tool to bundle this ELF file into an NDS binary. The `ndstool` utility included with devkitARM is one such tool that can do this for you: |
| 63 | + |
| 64 | +```shell |
| 65 | +ndstool -c [out_nds] -9 [in_elf] |
| 66 | +``` |
| 67 | + |
| 68 | +## Testing |
| 69 | + |
| 70 | +This is a cross-compiled target that you will need to emulate during testing. |
| 71 | + |
| 72 | +Because this is a device-agnostic target, and the exact emulator that you'll |
| 73 | +need depends on the specific device you want to run your code on. |
| 74 | + |
| 75 | +For example, when programming for the DS, you can use one of the several available DS emulators, such as [melonDS](https://melonds.kuribo64.net/). |
0 commit comments