From 17e13c88096a33273ef935a249639da2ddd81f6a Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Fri, 1 Nov 2024 10:02:39 +0100 Subject: [PATCH] feat: add thumbv7em-none-eabihf for cortex-m floating point processors (#625) --- .devcontainer/rust/Dockerfile | 3 +- .../rust/test/cortex-mf/.cargo/config.toml | 2 + .devcontainer/rust/test/cortex-mf/Cargo.lock | 257 ++++++++++++++++++ .devcontainer/rust/test/cortex-mf/Cargo.toml | 9 + .devcontainer/rust/test/cortex-mf/src/main.rs | 15 + .devcontainer/rust/test/testsuite.bats | 13 + 6 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/rust/test/cortex-mf/.cargo/config.toml create mode 100644 .devcontainer/rust/test/cortex-mf/Cargo.lock create mode 100644 .devcontainer/rust/test/cortex-mf/Cargo.toml create mode 100644 .devcontainer/rust/test/cortex-mf/src/main.rs diff --git a/.devcontainer/rust/Dockerfile b/.devcontainer/rust/Dockerfile index 4a2acd98..ad802601 100644 --- a/.devcontainer/rust/Dockerfile +++ b/.devcontainer/rust/Dockerfile @@ -28,7 +28,8 @@ ENV CARGO_HOME=/usr/local/cargo \ RUN rustup set profile minimal \ && rustup default ${RUST_VERSION} \ && rustup component add clippy llvm-tools rustfmt \ - && rustup target add thumbv7em-none-eabi + && rustup target add thumbv7em-none-eabi \ + && rustup target add thumbv7em-none-eabihf # Install bats RUN batstmp="$(mktemp -d /tmp/bats-core-${BATS_VERSION}.XXXX)" \ diff --git a/.devcontainer/rust/test/cortex-mf/.cargo/config.toml b/.devcontainer/rust/test/cortex-mf/.cargo/config.toml new file mode 100644 index 00000000..5d10902a --- /dev/null +++ b/.devcontainer/rust/test/cortex-mf/.cargo/config.toml @@ -0,0 +1,2 @@ +[build] +target = "thumbv7em-none-eabihf" diff --git a/.devcontainer/rust/test/cortex-mf/Cargo.lock b/.devcontainer/rust/test/cortex-mf/Cargo.lock new file mode 100644 index 00000000..68116912 --- /dev/null +++ b/.devcontainer/rust/test/cortex-mf/Cargo.lock @@ -0,0 +1,257 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aligned" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a785a543aea40f5e4e2e93bb2655d31bc21bb391fff65697150973e383f16bb" +dependencies = [ + "as-slice", +] + +[[package]] +name = "as-slice" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45403b49e3954a4b8428a0ac21a4b7afadccf92bfd96273f1a58cd4812496ae0" +dependencies = [ + "generic-array 0.12.4", + "generic-array 0.13.3", + "generic-array 0.14.7", + "stable_deref_trait", +] + +[[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" + +[[package]] +name = "cortex-m" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9075300b07c6a56263b9b582c214d0ff037b00d45ec9fde1cc711490c56f1bb9" +dependencies = [ + "aligned", + "bare-metal", + "bitfield", + "cortex-m 0.7.7", + "volatile-register", +] + +[[package]] +name = "cortex-m" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ec610d8f49840a5b376c69663b6369e71f4b34484b9b2eb29fb918d92516cb9" +dependencies = [ + "bare-metal", + "bitfield", + "embedded-hal", + "volatile-register", +] + +[[package]] +name = "cortex-m-rt" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "454f278bf469e2de0a4d22ea019d169d8944f86957c8207a39e3f66c32be2fc6" +dependencies = [ + "cortex-m-rt-macros", + "r0", +] + +[[package]] +name = "cortex-m-rt-macros" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3aa52243e26f5922fa522b0814019e0c98fc567e2756d715dce7ad7a81f49" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "embedded-hal" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35949884794ad573cf46071e41c9b60efb0cb311e3ca01f7af807af1debc66ff" +dependencies = [ + "nb 0.1.3", + "void", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f797e67af32588215eaaab8327027ee8e71b9dd0b2b26996aedf20c030fce309" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "hello-cortex" +version = "0.1.0" +dependencies = [ + "cortex-m 0.6.7", + "cortex-m-rt", + "panic-halt", +] + +[[package]] +name = "nb" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +dependencies = [ + "nb 1.1.0", +] + +[[package]] +name = "nb" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" + +[[package]] +name = "panic-halt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r0" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "volatile-register" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de437e2a6208b014ab52972a27e59b33fa2920d3e00fe05026167a1c509d19cc" +dependencies = [ + "vcell", +] diff --git a/.devcontainer/rust/test/cortex-mf/Cargo.toml b/.devcontainer/rust/test/cortex-mf/Cargo.toml new file mode 100644 index 00000000..66cb5e18 --- /dev/null +++ b/.devcontainer/rust/test/cortex-mf/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "hello-cortex" +version = "0.1.0" +edition = "2021" + +[dependencies] +cortex-m = "0.6.0" +cortex-m-rt = "0.6.10" +panic-halt = "0.2.0" diff --git a/.devcontainer/rust/test/cortex-mf/src/main.rs b/.devcontainer/rust/test/cortex-mf/src/main.rs new file mode 100644 index 00000000..f48a83a5 --- /dev/null +++ b/.devcontainer/rust/test/cortex-mf/src/main.rs @@ -0,0 +1,15 @@ +#![no_std] +#![no_main] + +use panic_halt as _; + +use cortex_m::asm; +use cortex_m_rt::entry; + +#[entry] +fn main() -> ! { + asm::nop(); + + loop { + } +} diff --git a/.devcontainer/rust/test/testsuite.bats b/.devcontainer/rust/test/testsuite.bats index d6edb1c1..37c88d2a 100644 --- a/.devcontainer/rust/test/testsuite.bats +++ b/.devcontainer/rust/test/testsuite.bats @@ -32,6 +32,19 @@ teardown() { popd } +@test "valid code input should result in working elf executable targeting the cortex-mf architecture" { + pushd cortex-mf + + cargo build + + run cargo readobj --bin hello-cortex -- --file-headers + assert_output --partial "Class: ELF32" + assert_output --partial "Type: EXEC" + assert_output --partial "Machine: ARM" + + popd +} + @test "using cargo run should result in working executable" { pushd cargo