Skip to content

Commit b0f7562

Browse files
Add pages for every Cortex-M target
Now explains how to, for example, support a Cortex-M55 with FPU and Integer Helium.
1 parent 865808b commit b0f7562

9 files changed

+646
-39
lines changed

src/doc/rustc/src/platform-support.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ target | std | notes
178178
`riscv64imac-unknown-none-elf` | * | Bare RISC-V (RV64IMAC ISA)
179179
`sparc64-unknown-linux-gnu` | ✓ | SPARC Linux (kernel 4.4, glibc 2.23)
180180
`sparcv9-sun-solaris` | ✓ | SPARC Solaris 11, illumos
181-
[`thumbv6m-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare ARMv6-M
182-
[`thumbv7em-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare ARMv7E-M
183-
[`thumbv7em-none-eabihf`](platform-support/arm-none-eabi.md) | * | Bare ARMV7E-M, hardfloat
184-
[`thumbv7m-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare ARMv7-M
181+
[`thumbv6m-none-eabi`](platform-support/thumbv6m-none-eabi.md) | * | Bare ARMv6-M
182+
[`thumbv7em-none-eabi`](platform-support/thumbv7em-none-eabi.md) | * | Bare ARMv7E-M
183+
[`thumbv7em-none-eabihf`](platform-support/thumbv7em-none-eabihf.md) | * | Bare ARMV7E-M, hardfloat
184+
[`thumbv7m-none-eabi`](platform-support/thumbv7m-none-eabi.md) | * | Bare ARMv7-M
185185
[`thumbv7neon-linux-androideabi`](platform-support/android.md) | ✓ | Thumb2-mode ARMv7-A Android with NEON
186186
`thumbv7neon-unknown-linux-gnueabihf` | ✓ | Thumb2-mode ARMv7-A Linux with NEON (kernel 4.4, glibc 2.23)
187-
[`thumbv8m.base-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare ARMv8-M Baseline
188-
[`thumbv8m.main-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare ARMv8-M Mainline
189-
[`thumbv8m.main-none-eabihf`](platform-support/arm-none-eabi.md) | * | Bare ARMv8-M Mainline, hardfloat
187+
[`thumbv8m.base-none-eabi`](platform-support/thumbv8m.base-none-eabi.md) | * | Bare ARMv8-M Baseline
188+
[`thumbv8m.main-none-eabi`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare ARMv8-M Mainline
189+
[`thumbv8m.main-none-eabihf`](platform-support/thumbv8m.main-none-eabihf.md) | * | Bare ARMv8-M Mainline, hardfloat
190190
`wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten
191191
`wasm32-unknown-unknown` | ✓ | WebAssembly
192192
`wasm32-wasi` | ✓ | WebAssembly with WASI (undergoing a [rename to `wasm32-wasip1`][wasi-rename])

src/doc/rustc/src/platform-support/arm-none-eabi.md

Lines changed: 115 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,96 @@
11
# `{arm,thumb}*-none-eabi(hf)?`
22

3-
**Tier: 2**
4-
- [arm(eb)?v7r-none-eabi(hf)?](armv7r-none-eabi.md)
5-
- armv7a-none-eabi
6-
- thumbv6m-none-eabi
7-
- thumbv7m-none-eabi
8-
- thumbv7em-none-eabi(hf)?
9-
- thumbv8m.base-none-eabi
10-
- thumbv8m.main-none-eabi(hf)?
11-
12-
**Tier: 3**
13-
- [{arm,thumb}v4t-none-eabi](armv4t-none-eabi.md)
14-
- [{arm,thumb}v5te-none-eabi](armv5te-none-eabi.md)
15-
- armv7a-none-eabihf
16-
- [armv8r-none-eabihf](armv8r-none-eabihf.md)
17-
18-
Bare-metal target for 32-bit ARM CPUs.
19-
20-
If a target has a `*hf` variant, that variant uses the hardware floating-point
21-
ABI and enables some minimum set of floating-point features based on the FPU(s)
22-
available in that processor family.
3+
## Tier 2 Target List
4+
5+
- Arm A-Profile Architectures
6+
- `armv7a-none-eabi`
7+
- Arm R-Profile Architectures
8+
- [`armv7r-none-eabi` and `armv7r-none-eabihf`](armv7r-none-eabi.md)
9+
- [`armebv7r-none-eabi` and `armebv7r-none-eabihf`](armv7r-none-eabi.md)
10+
- Arm M-Profile Architectures
11+
- [`thumbv6m-none-eabi`](thumbv6m-none-eabi.md)
12+
- [`thumbv7m-none-eabi`](thumbv7m-none-eabi.md)
13+
- [`thumbv7em-none-eabi`](thumbv7em-none-eabi.md) and [`thumbv7em-none-eabihf`](thumbv7em-none-eabihf.md)
14+
- [`thumbv8m.base-none-eabi`](thumbv8m.base-none-eabi.md)
15+
- [`thumbv8m.main-none-eabi`](thumbv8m.main-none-eabi.md) and [`thumbv8m.main-none-eabihf`](thumbv8m.main-none-eabihf.md)
16+
- *Legacy* Arm Architectures
17+
- None
18+
19+
## Tier 3 Target List
20+
21+
- Arm A-Profile Architectures
22+
- `armv7a-none-eabihf`
23+
- Arm R-Profile Architectures
24+
- [`armv8r-none-eabihf`](armv8r-none-eabihf.md)
25+
- Arm M-Profile Architectures
26+
- None
27+
- *Legacy* Arm Architectures
28+
- [`armv4t-none-eabi` and `thumbv4t-none-eabi`](armv4t-none-eabi.md)
29+
- [`armv5te-none-eabi` and `thumbv5te-none-eabi`](armv5te-none-eabi.md)
30+
31+
## Common Target Details
32+
33+
This documentation covers details that apply to a range of bare-metal target for
34+
32-bit ARM CPUs. In addition, target specific details may be covered in their
35+
own document.
36+
37+
If a target ends in `eabi`, that target uses the so-called *soft-float ABI*:
38+
functions which take `f32` or `f64` as arguments will have those values packed
39+
into integer registers. This means that an FPU is not required from an ABI
40+
perspective, but within a function FPU instructions may still be used if the
41+
code is compiled with a `target-cpu` or `target-feature` option that enables
42+
FPU support.
43+
44+
If a target ends if `eabihf`, that target uses the so-called *hard-float ABI*:
45+
functions which take `f32` or `f64` as arguments will have them passed via FPU
46+
registers. These target therefore require the use of an FPU and will assume the
47+
minimum support FPU for that architecture is available. More advanced FPU
48+
instructions (e.g. ones that work on double-precision `f64` values) may be
49+
generated if the code is compiled with a `target-cpu` or `target-feature` option
50+
that enables such additional FPU support.
51+
52+
## Target CPU and Target Feature options
53+
54+
It is possible to tell Rust (or LLVM) that you have a specific model of Arm
55+
processor, using the [`-C target-cpu`][target-cpu] option. You can also control
56+
whether Rust (or LLVM) will include instructions that target optional hardware
57+
features, e.g. hardware floating point, or vector maths operations, using [`-C
58+
target-feature`][target-feature].
59+
60+
It is important to note that selecting a *target-cpu* will typically enable
61+
*all* the optional features available from Arm on that model of CPU and your
62+
particular implementation of that CPU may not have those features available. In
63+
that case, you can use `-C target-feature=-option` to turn off the specific CPU
64+
features you do not have available, leaving you with the optimised instruction
65+
scheduling and support for the features you do have. More details are available
66+
in the detailed target-specific documentation.
67+
68+
**Note:** Many target-features are currently unstable and subject to change, and
69+
if you use them you should dissassmble the compiler output and manually inspect
70+
it to ensure only appropriate instructions for your CPU have been generated.
71+
72+
If do you wish to use the *target-cpu* and *target-feature* options, you can add
73+
them to your `.cargo/config.toml` file alongside any other flags your project
74+
uses (likely linker related ones):
75+
76+
```toml
77+
rustflags = [
78+
# Usual Arm bare-metal linker setup
79+
"-C", "link-arg=-Tlink.x",
80+
"-C", "link-arg=--nmagic",
81+
# tell Rust we have a Cortex-M55
82+
"-C", "target-cpu=cortex-m55",
83+
# tell Rust our Cortex-M55 doesn't have Floating-Point M-Profile Vector
84+
# Extensions (but it does have everything else a Cortex-M55 could have).
85+
"-C", "target-feature=-mve.fp"
86+
]
87+
88+
[build]
89+
target = "thumbv8m.main-none-eabihf"
90+
```
91+
92+
[target-cpu]: https://doc.rust-lang.org/rustc/codegen-options/index.html#target-cpu
93+
[target-feature]: https://doc.rust-lang.org/rustc/codegen-options/index.html#target-feature
2394

2495
## Requirements
2596

@@ -45,14 +116,15 @@ according to the specific device you are using. Pass
45116
`-Clink-arg=-Tyour_script.ld` as a rustc argument to make the linker use
46117
`your_script.ld` during linking.
47118

48-
Targets named `thumb*` instead of `arm*`
49-
generate Thumb-mode code by default. M-profile processors (`thumbv*m*-*`
50-
targets) only support Thumb-mode code.
51-
For the `arm*` targets, Thumb-mode code generation can be enabled by using
52-
`-C target-feature=+thumb-mode`. Using the unstable
53-
`#![feature(arm_target_feature)]`, the attribute
54-
`#[target_feature(enable = "thumb-mode")]` can be applied to individual
55-
`unsafe` functions to cause those functions to be compiled to Thumb-mode code.
119+
Targets named `thumb*` instead of `arm*` generate Thumb (T32) code by default
120+
instead of Arm (A32) code. Most Arm chips support both Thumb mode and Arm mode,
121+
except that M-profile processors (`thumbv*m*-*` targets) only support Thumb-mode.
122+
123+
For the `arm*` targets, Thumb-mode code generation can be enabled by using `-C
124+
target-feature=+thumb-mode`. Using the unstable
125+
`#![feature(arm_target_feature)]`, the attribute `#[target_feature(enable =
126+
"thumb-mode")]` can be applied to individual `unsafe` functions to cause those
127+
functions to be compiled to Thumb-mode code.
56128

57129
## Building Rust Programs
58130

@@ -69,16 +141,27 @@ build-std = ["core"]
69141
```
70142

71143
Most of `core` should work as expected, with the following notes:
72-
* If the target is not `*hf`, then floating-point operations are emulated in
73-
software.
144+
145+
* Floating-point operations are emulated in software unless LLVM is told to
146+
enable FPU support (either by using an `eabihf` target, specifying a
147+
`target-cpu` with FPU support, or using a `target-feature` to support for a
148+
specific kind of FPU)
74149
* Integer division is also emulated in software on some targets, depending on
75-
the CPU.
76-
* Architectures prior to ARMv7 don't have atomic instructions.
150+
the target, `target-cpu` and `target-feature`s.
151+
* Older Arm architectures (e.g. Armv4, Armv5TE and Armv6-M) are limited to basic
152+
[`load`][atomic-load] and [`store`][atomic-store] operations, and not more
153+
advanced operations like [`fetch_add`][fetch-add] or
154+
[`compare_exchange`][compare-exchange].
77155

78156
`alloc` is also supported, as long as you provide your own global allocator.
79157

80158
Rust programs are output as ELF files.
81159

160+
[atomic-load]: https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicU32.html#method.load
161+
[atomic-store]: https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicU32.html#method.store
162+
[fetch-add]: https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicU32.html#method.fetch_add
163+
[compare-exchange]: https://doc.rust-lang.org/stable/std/sync/atomic/struct.AtomicU32.html#method.compare_exchange
164+
82165
## Testing
83166

84167
This is a cross-compiled target that you will need to emulate during testing.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# `thumbv6m-none-eabi`
2+
3+
**Tier: 2**
4+
5+
Bare-metal target for CPUs in the [ARMv6-M] architecture family, supporting a
6+
subset of the [T32 ISA][t32-isa].
7+
8+
Processors in this family include the:
9+
10+
* [Arm Cortex-M0][cortex-m0]
11+
* [Arm Cortex-M0+][cortex-m0plus]
12+
* [Arm Cortex-M1][cortex-m1]
13+
14+
See [`arm-none-eabi`](arm-none-eabi.md) for information applicable to all
15+
`arm-none-eabi` targets.
16+
17+
This target uses the soft-float ABI: functions which take `f32` or `f64` as
18+
arguments will have those values packed into an integer registers. This is the
19+
only option because there is no FPU support in [ARMv6-M].
20+
21+
[t32-isa]: https://developer.arm.com/Architectures/T32%20Instruction%20Set%20Architecture
22+
[ARMv6-M]: https://developer.arm.com/documentation/ddi0419/latest/
23+
[cortex-m0]: https://developer.arm.com/Processors/Cortex-M0
24+
[cortex-m0plus]: https://developer.arm.com/Processors/Cortex-M0+
25+
[cortex-m1]: https://developer.arm.com/Processors/Cortex-M1
26+
27+
## Target maintainers
28+
29+
* [Rust Embedded Devices Working Group Cortex-M
30+
Team](https://github.com/rust-embedded), `[email protected]`
31+
32+
## Target CPU and Target Feature options
33+
34+
See [the bare-metal Arm
35+
docs](arm-none-eabi.md#target-cpu-and-target-feature-options) for details on how
36+
to use these flags.
37+
38+
### Table of supported CPUs
39+
40+
| CPU | FPU | Target CPU | Target Features |
41+
| ---------- | --- | --------------- | --------------------- |
42+
| Cortex-M0 | No | `cortex-m0` | None |
43+
| Cortex-M0+ | No | `cortex-m0plus` | None |
44+
| Cortex-M1 | No | `cortex-m1` | None |
45+
46+
### Arm Cortex-M0
47+
48+
The target CPU option is `cortex-m0`.
49+
50+
There are no relevant feature flags, and the FPU is not available.
51+
52+
### Arm Cortex-M0+
53+
54+
The target CPU option is `cortex-m0plus`.
55+
56+
There are no relevant feature flags, and the FPU is not available.
57+
58+
### Arm Cortex-M1
59+
60+
The target CPU option is `cortex-m1`.
61+
62+
There are no relevant feature flags, and the FPU is not available.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# `thumbv7em-none-eabi`
2+
3+
**Tier: 2**
4+
5+
Bare-metal target for CPUs in the [ARMv7E-M] architecture family, supporting a
6+
subset of the [T32 ISA][t32-isa].
7+
8+
Processors in this family include the:
9+
10+
* [Arm Cortex-M4][cortex-m4] and Arm Cortex-M4F
11+
* [Arm Cortex-M7][cortex-m7] and Arm Cortex-M7F
12+
13+
See [`arm-none-eabi`](arm-none-eabi.md) for information applicable to all
14+
`arm-none-eabi` targets.
15+
16+
This target uses the soft-float ABI: functions which take `f32` or `f64` as
17+
arguments will have those values packed into an integer registers. This target
18+
therefore does not require the use of an FPU (which is optional on Cortex-M4 and
19+
Cortex-M7), but an FPU can be optionally enabled if desired. See also the
20+
hard-float ABI version of this target
21+
[`thumbv7em-none-eabihf`](thumbv7em-none-eabihf.md).
22+
23+
[t32-isa]: https://developer.arm.com/Architectures/T32%20Instruction%20Set%20Architecture
24+
[ARMv7E-M]: https://developer.arm.com/documentation/ddi0403/latest/
25+
[cortex-m4]: https://developer.arm.com/Processors/Cortex-M4
26+
[cortex-m7]: https://developer.arm.com/Processors/Cortex-M7
27+
28+
## Target maintainers
29+
30+
* [Rust Embedded Devices Working Group Cortex-M
31+
Team](https://github.com/rust-embedded), `[email protected]`
32+
33+
## Target CPU and Target Feature options
34+
35+
See [the bare-metal Arm
36+
docs](arm-none-eabi.md#target-cpu-and-target-feature-options) for details on how
37+
to use these flags.
38+
39+
### Table of supported CPUs
40+
41+
| CPU | FPU | DSP | Target CPU | Target Features |
42+
| ---------- | --- | --- | ----------- | --------------- |
43+
| Cortex-M4 | No | Yes | `cortex-m4` | `+soft-float` |
44+
| Cortex-M4F | SP | Yes | `cortex-m4` | None |
45+
| Cortex-M7 | No | Yes | `cortex-m7` | `+soft-float` |
46+
| Cortex-M7F | SP | Yes | `cortex-m7` | `-fp64` |
47+
| Cortex-M7F | DP | Yes | `cortex-m7` | None |
48+
49+
### Arm Cortex-M4 and Arm Cortex-M4F
50+
51+
The target CPU is `cortex-m4`.
52+
53+
* All Cortex-M4 have DSP extensions
54+
* support is controlled by the `dsp` *target-feature*
55+
* enabled by default with this *target-cpu*
56+
* Cortex-M4F has a single precision FPU
57+
* support is enabled by default with this *target-cpu*
58+
* disable support using the `+soft-float` feature
59+
60+
### Arm Cortex-M7 and Arm Cortex-M7F
61+
62+
The target CPU is `cortex-m7`.
63+
64+
* All Cortex-M7 have DSP extensions
65+
* support is controlled by the `dsp` *target-feature*
66+
* enabled by default with this *target-cpu*
67+
* Cortex-M7F have either a single-precision or double-precision FPU
68+
* double-precision support is enabled by default with this *target-cpu*
69+
* opt-out by using the `-f64` *target-feature*
70+
* disable support entirely using the `+soft-float` feature
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# `thumbv7em-none-eabihf`
2+
3+
**Tier: 2**
4+
5+
Bare-metal target for CPUs in the [ARMv7E-M] architecture family that have an
6+
FPU, supporting a subset of the [T32 ISA][t32-isa].
7+
8+
Processors in this family include the:
9+
10+
* [Arm Cortex-M4F][cortex-m4]
11+
* [Arm Cortex-M7F][cortex-m7]
12+
13+
See [`arm-none-eabi`](arm-none-eabi.md) for information applicable to all
14+
`arm-none-eabi` targets.
15+
16+
This target uses the hard-float ABI: functions which take `f32` or `f64` as
17+
arguments will have them passed via FPU registers. This target therefore
18+
requires the use of an FPU (which is optional on Cortex-M4 and Cortex-M7). See
19+
also the soft-float ABI version of this target
20+
[`thumbv7em-none-eabi`](thumbv7em-none-eabi.md).
21+
22+
[t32-isa]: https://developer.arm.com/Architectures/T32%20Instruction%20Set%20Architecture
23+
[ARMv7E-M]: https://developer.arm.com/documentation/ddi0403/latest/
24+
[cortex-m4]: https://developer.arm.com/Processors/Cortex-M4
25+
[cortex-m7]: https://developer.arm.com/Processors/Cortex-M7
26+
27+
## Target maintainers
28+
29+
* [Rust Embedded Devices Working Group Cortex-M
30+
Team](https://github.com/rust-embedded), `[email protected]`
31+
32+
## Target CPU and Target Feature options
33+
34+
See [the bare-metal Arm
35+
docs](arm-none-eabi.md#target-cpu-and-target-feature-options) for details on how
36+
to use these flags.
37+
38+
### Table of supported CPUs
39+
40+
| CPU | FPU | DSP | Target CPU | Target Features |
41+
| ---------- | --- | --- | ----------- | --------------- |
42+
| Cortex-M4F | SP | Yes | `cortex-m4` | None |
43+
| Cortex-M7F | SP | Yes | `cortex-m7` | `-fp64` |
44+
| Cortex-M7F | DP | Yes | `cortex-m7` | None |
45+
46+
### Arm Cortex-M4 and Arm Cortex-M4F
47+
48+
The target CPU is `cortex-m4`.
49+
50+
* All Cortex-M4 have DSP extensions
51+
* support is controlled by the `dsp` *target-feature*
52+
* enabled by default with this *target-cpu*
53+
* Cortex-M4F has a single precision FPU
54+
* support is enabled by default with this *target*
55+
* support is required when using the hard-float ABI
56+
57+
### Arm Cortex-M7 and Arm Cortex-M7F
58+
59+
The target CPU is `cortex-m7`.
60+
61+
* All Cortex-M7 have DSP extensions
62+
* support is controlled by the `dsp` *target-feature*
63+
* enabled by default with this *target-cpu*
64+
* Cortex-M7F have either a single-precision or double-precision FPU
65+
* single precision support is enabled by default with this *target*
66+
* double-precision support is enabled by default with this *target-cpu*
67+
* opt-out by using the `-f64` *target-feature*

0 commit comments

Comments
 (0)