|
| 1 | +# armv4t-none-eabi |
| 2 | + |
| 3 | +Tier 3 |
| 4 | + |
| 5 | +Bare-metal target for any cpu in the ARMv4T architecture family, supporting |
| 6 | +ARM/Thumb code interworking (aka `a32`/`t32`), with ARM code as the default code |
| 7 | +generation. |
| 8 | + |
| 9 | +In particular this supports the Gameboy Advance (GBA), but there's nothing GBA |
| 10 | +specific with this target, so any ARMv4T device should work fine. |
| 11 | + |
| 12 | +## Target Maintainers |
| 13 | + |
| 14 | +* [@Lokathor](https://github.com/lokathor) |
| 15 | + |
| 16 | +## Requirements |
| 17 | + |
| 18 | +The target is cross-compiled, and uses static linking. |
| 19 | + |
| 20 | +The linker that comes with rustc cannot link for this platform (the platform is |
| 21 | +too old). You will need the `arm-none-eabi-ld` linker from a GNU Binutils |
| 22 | +targeting ARM. This can be obtained for Windows/Mac/Linux from the [ARM |
| 23 | +Developer Website][arm-dev], or possibly from your OS's package manager. |
| 24 | + |
| 25 | +[arm-dev]: https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain |
| 26 | + |
| 27 | +This target doesn't provide a linker script, you'll need to bring your own |
| 28 | +according to the specific device you want to target. Pass |
| 29 | +`-Clink-arg=-Tyour_script.ld` as a rustc argument to make the linker use |
| 30 | +`your_script.ld` during linking. |
| 31 | + |
| 32 | +## Building Rust Programs |
| 33 | + |
| 34 | +Because it is Tier 3, rust does not yet ship pre-compiled artifacts for this target. |
| 35 | + |
| 36 | +Just use the `build-std` nightly cargo feature to build the `core` library. You |
| 37 | +can pass this as a command line argument to cargo, or your `.cargo/config.toml` |
| 38 | +file might include the following lines: |
| 39 | + |
| 40 | +```toml |
| 41 | +[unstable] |
| 42 | +build-std = ["core"] |
| 43 | +``` |
| 44 | + |
| 45 | +Most of `core` should work as expected, with the following notes: |
| 46 | +* the target is "soft float", so `f32` and `f64` operations are emulated in |
| 47 | + software. |
| 48 | +* integer division is also emulated in software. |
| 49 | +* the target is old enough that it doesn't have atomic instructions. |
| 50 | + |
| 51 | +Rust programs are output as ELF files. |
| 52 | + |
| 53 | +For running on hardware, you'll generally need to extract the "raw" program code |
| 54 | +out of the ELF and into a file of its own. The `objcopy` program provided as |
| 55 | +part of the GNU Binutils can do this: |
| 56 | + |
| 57 | +```shell |
| 58 | +arm-none-eabi-objcopy --output-target binary [in_file] [out_file] |
| 59 | +``` |
| 60 | + |
| 61 | +## Testing |
| 62 | + |
| 63 | +This is a cross-compiled target that you will need to emulate during testing. |
| 64 | + |
| 65 | +Because this is a device-agnostic target, and the exact emulator that you'll |
| 66 | +need depends on the specific device you want to run your code on. |
| 67 | + |
| 68 | +For example, when programming for the Gameboy Advance, the |
| 69 | +[mgba-test-runner](https://github.com/agbrs/agb) program could be used to make a |
| 70 | +normal set of rust tests be run within the `mgba` emulator. |
0 commit comments