Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"rust-analyzer.cargo.features": [
"rt",
"stm32h503"
"stm32h503",
"async",
],
"rust-analyzer.check.allTargets": false,
"rust-analyzer.check.targets": "thumbv8m.main-none-eabihf",
}
}
10 changes: 10 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Cross doesn't seem to look for package specific configurations when invoked in a workspace so
# we put the default target in Cross.toml

# Allow usage of locally built version of the cross docker image that matches the host architecture
# e.g. Building a linux/arm64 image for an AARCH64 host allows native execution of the image.
# Specifying the toolchain for a linux/arm64 image means the correct toolchain is used on that
# platform (it defaults to x86_64).
[target.aarch64-unknown-linux-gnu.image]
name = "ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main"
toolchain = ["linux/arm64=aarch64-unknown-linux-gnu"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ a number of fantastic resources available to help.
- [Rust Embedded FAQ](https://docs.rust-embedded.org/faq.html)
- [rust-embedded/awesome-embedded-rust](https://github.com/rust-embedded/awesome-embedded-rust)

## Running unit tests

First, you'll need to install the `aarch64-unknown-linux-gnu` target to run unit tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would I need that target specifically? Does x86_64 not work for the tests? Also why would I need to cross compile in the first place for running tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry. That's incorrect. Updated


If you're on a linux host, you can to run unit tests with `cargo test`.

If you're not, you'll need to install [`cross`](https://github.com/cross-rs/cross), which is a cross compilation tool. See the `cross` instructions for details of installation and use. Once that is installed, using `cross test` will run the unit tests within a docker image.

Running tests with `cross`:

cross test --target x86_64-unknown-linux-gnu --tests --features stm32h503
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by the

[target.aarch64-unknown-linux-gnu.image]

line in Cross.toml is there something special to do on that arch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you can run it on either architecture. That directive in Cross.toml is to allow you to run tests for the aarch64-unknown-linux-gnu in a cross aarch64-unknown-linux-gnu image that is built for arm64 hosts (ie. no cross-compilation), which makes building a lot faster on an arm64 Macs (and probably Windows too). Unfortunately building that cross image for arm64 hosts is currently broken (this PR will fix it I believe: https://github.com/japaric/xargo/pull/349/files), so including instructions for use is kinda awkward. Without that directive, cross will download the aarch64-unknown-linux-gnu image built for x86_64 and run the tests on that, which does involve cross compilation and provides no benefit over running the x86_64-unknown-linux-gnu cross image.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, okay

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add some instructions for building with a guest image that matches the host architecture when it's more accessible with cross!


`cross` will automatically download the relevant docker image and install the correct rust toolchain.

## Changelog

See [CHANGELOG.md](CHANGELOG.md). Note: this will be populated once the first crates have been
Expand Down