Skip to content

Commit 3d2319b

Browse files
committed
Cortex A addition
- Add armv7a architecture handling to the crate. - Add new `cortex-a-rt` reference run time crate. - Add basic armv7a checks to CI - `kmain` renamed to `boot_core` for Cortex-A where multi-processor systems are common. - Add armv7a to examples for basic verification with QEMU - Split example code into dedicated folders for QEMU targets - Build examples in CI as well
1 parent ee704d6 commit 3d2319b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1496
-162
lines changed

.cargo/config.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ runner = "qemu-system-arm -machine mps3-an536 -cpu cortex-r52 -semihosting -nogr
66
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5f -semihosting -nographic -kernel"
77

88
[target.armv7r-none-eabi]
9-
# change to '-mcpu=cortex-r5' to '-mcpu=cortex-r5f' if you use eabi-fpu feature, otherwise
9+
# change '-mcpu=cortex-r5' to '-mcpu=cortex-r5f' if you use eabi-fpu feature, otherwise
1010
# qemu-system-arm will lock up
1111
runner = "qemu-system-arm -machine versatileab -cpu cortex-r5 -semihosting -nographic -kernel"
12+
13+
[target.armv7a-none-eabihf]
14+
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -kernel"
15+
16+
[target.armv7a-none-eabi]
17+
runner = "qemu-system-arm -machine versatileab -cpu cortex-a8 -semihosting -nographic -kernel"
18+
19+
[unstable]
20+
build-std = ["core", "alloc"]

.github/workflows/build.yml

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,29 @@ on:
66
name: Build
77

88
jobs:
9+
# Define Rust versions dynamically
10+
setup:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
matrix: ${{ steps.set-matrix.outputs.rust_versions }}
14+
steps:
15+
- id: set-matrix
16+
run: |
17+
echo 'rust_versions={"rust": ["stable", "1.82"]}' >> "$GITHUB_OUTPUT"
18+
919
# Build the workspace for a target architecture
1020
build:
1121
runs-on: ubuntu-24.04
22+
needs: setup
1223
strategy:
1324
matrix:
14-
rust: [stable, 1.82]
25+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
1526
target:
1627
- armebv7r-none-eabi
1728
- armebv7r-none-eabihf
1829
- armv7r-none-eabi
1930
- armv7r-none-eabihf
31+
- armv7a-none-eabi
2032
steps:
2133
- name: Checkout
2234
uses: actions/checkout@v4
@@ -29,11 +41,51 @@ jobs:
2941
run: |
3042
cargo build --target ${{ matrix.target }}
3143
cargo build --target ${{ matrix.target }} --no-default-features
32-
cargo build --target ${{ matrix.target }} --all-features
44+
45+
build-versatileab:
46+
runs-on: ubuntu-24.04
47+
needs: setup
48+
strategy:
49+
matrix:
50+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
- name: Install rust
55+
run: |
56+
rustup install ${{ matrix.rust }}
57+
rustup default ${{ matrix.rust }}
58+
rustup target add armv7a-none-eabi
59+
rustup target add armv7r-none-eabi
60+
rustup target add armv7r-none-eabihf
61+
- name: Build
62+
run: |
63+
cargo build --manifest-path ./examples/versatileab/Cargo.toml --target armv7a-none-eabi
64+
cargo build --manifest-path ./examples/versatileab/Cargo.toml --target armv7r-none-eabi
65+
cargo build --manifest-path ./examples/versatileab/Cargo.toml --target armv7r-none-eabihf
66+
67+
build-mps3-an536:
68+
runs-on: ubuntu-24.04
69+
needs: setup
70+
strategy:
71+
matrix:
72+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v4
76+
- name: Install rust
77+
run: |
78+
rustup install nightly
79+
rustup default nightly
80+
rustup component add rust-src --toolchain nightly
81+
- name: Build
82+
run: |
83+
cargo build --manifest-path ./examples/mps3-an536/Cargo.toml --target armv8r-none-eabihf -Zbuild-std=core
3384
3485
# Build the host tools
3586
build-host:
3687
runs-on: ubuntu-24.04
88+
needs: setup
3789
strategy:
3890
matrix:
3991
rust: [stable, 1.59]
@@ -58,6 +110,8 @@ jobs:
58110
- armebv7r-none-eabi
59111
- armebv7r-none-eabihf
60112
- armv7r-none-eabi
113+
- armv7a-none-eabi
114+
- armv7a-none-eabihf
61115
- armv7r-none-eabihf
62116
- armv8r-none-eabihf
63117
steps:
@@ -72,22 +126,23 @@ jobs:
72126
run: |
73127
cargo build --target ${{ matrix.target }} -Zbuild-std=core
74128
cargo build --target ${{ matrix.target }} -Zbuild-std=core --no-default-features
75-
cargo build --target ${{ matrix.target }} -Zbuild-std=core --all-features
76129
77130
# Gather all the above build jobs together for the purposes of getting an overall pass-fail
78131
build-all:
79132
runs-on: ubuntu-24.04
80-
needs: [build, build-tier3, build-host]
133+
needs: [build, build-tier3, build-host, build-versatileab, build-mps3-an536]
81134
steps:
82135
- run: /bin/true
83136

84137
# Build the docs for the workspace
85138
docs:
86139
runs-on: ubuntu-24.04
140+
needs: setup
87141
strategy:
88142
matrix:
89-
rust: [stable, 1.82]
143+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
90144
target:
145+
- armv7a-none-eabi
91146
- armebv7r-none-eabi
92147
- armebv7r-none-eabihf
93148
- armv7r-none-eabi
@@ -109,9 +164,10 @@ jobs:
109164
# Build the docs for the host tools
110165
docs-host:
111166
runs-on: ubuntu-24.04
167+
needs: setup
112168
strategy:
113169
matrix:
114-
rust: [stable, 1.82]
170+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
115171
steps:
116172
- name: Checkout
117173
uses: actions/checkout@v4
@@ -170,14 +226,16 @@ jobs:
170226
# Run clippy on the workpace
171227
clippy:
172228
runs-on: ubuntu-24.04
229+
needs: setup
173230
strategy:
174231
matrix:
175-
rust: [stable, 1.82]
232+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
176233
target:
177234
- armebv7r-none-eabi
178235
- armebv7r-none-eabihf
179236
- armv7r-none-eabi
180237
- armv7r-none-eabihf
238+
- armv7a-none-eabi
181239
steps:
182240
- name: Checkout
183241
uses: actions/checkout@v4
@@ -196,9 +254,10 @@ jobs:
196254
# Run clippy on the host tools
197255
clippy-host:
198256
runs-on: ubuntu-24.04
257+
needs: setup
199258
strategy:
200259
matrix:
201-
rust: [stable, 1.82]
260+
rust: ${{ fromJSON(needs.setup.outputs.matrix).rust }}
202261
steps:
203262
- name: Checkout
204263
uses: actions/checkout@v4

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[workspace]
22
exclude = [
33
"arm-targets",
4+
"examples/versatileab",
5+
"examples/mps3-an536",
46
]
57
members = [
68
"cortex-ar",
7-
"cortex-r-examples",
89
"cortex-r-rt",
10+
"cortex-a-rt",
911
]
1012
resolver = "2"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Rust on Arm Cortex-R
1+
# Rust on Arm Cortex-R and Cortex-A
22

33
This repository provides support for:
44

@@ -17,9 +17,10 @@ There are currently three libraries here:
1717

1818
* [cortex-ar](./cortex-ar/) - support library for Cortex-R and Cortex-A CPUs (like [cortex-m])
1919
* [cortex-r-rt](./cortex-r-rt/) - run-time library for Cortex-R CPUs (like [cortex-m-rt])
20+
* [cortex-a-rt](./cortex-a-rt/) - run-time library for Cortex-A CPUs (like [cortex-m-rt])
2021
* [arm-targets](./arm-targets/) - a helper library for your build.rs that sets various `--cfg` flags according to the current target
2122

22-
There are also example programs for QEMU in the [cortex-r-examples](./cortex-r-examples/) folder.
23+
There are also example programs for QEMU in the [examples](./-examples/) folder.
2324

2425
[cortex-m]: https://crates.io/crates/cortex-m
2526
[cortex-m-rt]: https://crates.io/crates/cortex-m-rt

arm-targets/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ edition = "2021"
99
license = "MIT OR Apache-2.0"
1010
name = "arm-targets"
1111
readme = "README.md"
12-
repository = "https://github.com/rust-embedded/cortex-r.git"
12+
repository = "https://github.com/rust-embedded/cortex-ar.git"
13+
homepage = "https://github.com/rust-embedded/cortex-ar.git"
1314
rust-version = "1.59"
1415
version = "0.1.0"
1516

arm-targets/src/lib.rs

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,39 @@
22
//!
33
//! Hopefully Rust will stabilise these kinds of target features, and this won't
44
//! be required.
5+
#[derive(Default)]
6+
pub struct TargetInfo {
7+
profile: Option<Profile>,
8+
arch: Option<Arch>,
9+
isa: Option<Isa>,
10+
}
11+
12+
impl TargetInfo {
13+
pub fn profile(&self) -> Option<Profile> {
14+
self.profile
15+
}
516

17+
pub fn arch(&self) -> Option<Arch> {
18+
self.arch
19+
}
20+
21+
pub fn isa(&self) -> Option<Isa> {
22+
self.isa
23+
}
24+
}
625
/// Process the ${TARGET} environment variable, and emit cargo configuration to
726
/// standard out.
8-
pub fn process() {
27+
pub fn process() -> TargetInfo {
928
let target = std::env::var("TARGET").expect("build script TARGET variable");
10-
process_target(&target);
29+
process_target(&target)
1130
}
1231

1332
/// Process a given target string, and emit cargo configuration to standard out.
14-
pub fn process_target(target: &str) {
33+
pub fn process_target(target: &str) -> TargetInfo {
34+
let mut target_info = TargetInfo::default();
1535
if let Some(isa) = Isa::get(target) {
1636
println!(r#"cargo:rustc-cfg=arm_isa="{}""#, isa);
37+
target_info.isa = Some(isa);
1738
}
1839
println!(
1940
r#"cargo:rustc-check-cfg=cfg(arm_isa, values({}))"#,
@@ -22,6 +43,7 @@ pub fn process_target(target: &str) {
2243

2344
if let Some(arch) = Arch::get(target) {
2445
println!(r#"cargo:rustc-cfg=arm_architecture="{}""#, arch);
46+
target_info.arch = Some(arch);
2547
}
2648
println!(
2749
r#"cargo:rustc-check-cfg=cfg(arm_architecture, values({}))"#,
@@ -30,14 +52,17 @@ pub fn process_target(target: &str) {
3052

3153
if let Some(profile) = Profile::get(target) {
3254
println!(r#"cargo:rustc-cfg=arm_profile="{}""#, profile);
55+
target_info.profile = Some(profile);
3356
}
3457
println!(
3558
r#"cargo:rustc-check-cfg=cfg(arm_profile, values({}))"#,
3659
Profile::values()
3760
);
61+
target_info
3862
}
3963

4064
/// The Arm Instruction Set
65+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
4166
pub enum Isa {
4267
/// A64 instructions are executed by Arm processors in Aarch64 mode
4368
A64,
@@ -91,6 +116,7 @@ impl core::fmt::Display for Isa {
91116
/// The Arm Architecture
92117
///
93118
/// As defined by a particular revision of the Arm Architecture Reference Manual (ARM).
119+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
94120
pub enum Arch {
95121
/// Armv6-M (also known as ARMv6-M)
96122
Armv6M,
@@ -129,6 +155,8 @@ impl Arch {
129155
Some(Arch::Armv7R)
130156
} else if target.starts_with("armv8r-") {
131157
Some(Arch::Armv8R)
158+
} else if target.starts_with("armv7a-") {
159+
Some(Arch::Armv7A)
132160
} else if target.starts_with("aarch64-") || target.starts_with("aarch64be-") {
133161
Some(Arch::Armv8A)
134162
} else {
@@ -188,6 +216,7 @@ impl core::fmt::Display for Arch {
188216
}
189217

190218
/// The Arm Architecture Profile.
219+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
191220
pub enum Profile {
192221
/// Microcontrollers
193222
M,

cortex-a-rt/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
## [unreleased]
9+
10+
Initial release
11+
12+
[unreleased]: https://github.com/rust-embedded/cortex-ar/compare/cortex-a-rt-v0.1.0...HEAD
13+
[v0.1.0]: https://github.com/rust-embedded/cortex-ar/releases/tag/cortex-a-rt-v0.1.0

cortex-a-rt/Cargo.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[package]
2+
authors = [
3+
"Robin Mueller <[email protected]>",
4+
"Jonathan Pallant <[email protected]>",
5+
"The Cortex-R Team <[email protected]>"
6+
]
7+
description = "Run-Time support for Arm Cortex-A"
8+
edition = "2021"
9+
license = "MIT OR Apache-2.0"
10+
name = "cortex-a-rt"
11+
readme = "README.md"
12+
repository = "https://github.com/rust-embedded/cortex-ar.git"
13+
homepage = "https://github.com/rust-embedded/cortex-ar.git"
14+
rust-version = "1.82"
15+
version = "0.1.0"
16+
17+
[dependencies]
18+
cortex-ar = {version = "0.1.0", path = "../cortex-ar"}
19+
semihosting = {version = "0.1.18", features = ["stdio"]}
20+
21+
[features]
22+
# Enable the FPU on start-up, even on a soft-float EABI target
23+
eabi-fpu = []
24+
# Specify that the target VFP has double precision support. If the target has NEON support, it
25+
# also requires double precision support for the VFP.
26+
vfp-dp = []
27+
28+
[build-dependencies]
29+
arm-targets = {version = "0.1.0", path = "../arm-targets"}

cortex-a-rt/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Arm Cortex-A Run-Time
2+
3+
## Features
4+
5+
- `vfp-dp`: Enables support for the double-precision VFP floating point support. If your target
6+
CPU has this feature or support for NEON which also implies double-precision support, this
7+
feature should be activated.
8+
9+
## Minimum Supported Rust Version (MSRV)
10+
11+
This crate is guaranteed to compile on stable Rust 1.82.0 and up. It *might*
12+
compile with older versions but that may change in any new patch release.
13+
14+
## Licence
15+
16+
* Copyright (c) Ferrous Systems
17+
* Copyright (c) The Rust Embedded Devices Working Group developers
18+
19+
Licensed under either [MIT](./LICENSE-MIT) or [Apache-2.0](./LICENSE-APACHE) at
20+
your option.
21+
22+
## Contribution
23+
24+
Unless you explicitly state otherwise, any contribution intentionally submitted
25+
for inclusion in the work by you shall be licensed as above, without any
26+
additional terms or conditions.

0 commit comments

Comments
 (0)