forked from M-Labs/kirdy
add BSD build instructions
This commit is contained in:
parent
6b05b2d851
commit
4c331dd319
|
@ -0,0 +1,60 @@
|
|||
# Building Rust embedded firmware on BSD
|
||||
|
||||
Using the Rust stable compiler from the BSD ports is mostly a matter of removing the arbitrary limitations that have been built into the Rust toolchain.
|
||||
|
||||
Get rid of the "nightly toolchain" check in cargo-xbuild:
|
||||
```
|
||||
diff --git a/src/lib.rs b/src/lib.rs
|
||||
index 204ad8f..9c61e39 100644
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -157,28 +157,11 @@ pub fn build(args: Args, command_name: &str, crate_config: Option<Config>) -> Re
|
||||
})
|
||||
})?;
|
||||
|
||||
- // We can't build sysroot with stable or beta due to unstable features
|
||||
let sysroot = rustc::sysroot(verbose)?;
|
||||
- let src = match meta.channel {
|
||||
- Channel::Dev => rustc::Src::from_env().ok_or(anyhow!(
|
||||
+ let src = rustc::Src::from_env().ok_or(anyhow!(
|
||||
"The XARGO_RUST_SRC env variable must be set and point to the \
|
||||
- Rust source directory when working with the 'dev' channel",
|
||||
- ))?,
|
||||
- Channel::Nightly => {
|
||||
- if let Some(src) = rustc::Src::from_env() {
|
||||
- src
|
||||
- } else {
|
||||
- sysroot.src()?
|
||||
- }
|
||||
- }
|
||||
- Channel::Stable | Channel::Beta => {
|
||||
- bail!(
|
||||
- "The sysroot can't be built for the {:?} channel. \
|
||||
- Switch to nightly.",
|
||||
- meta.channel
|
||||
- );
|
||||
- }
|
||||
- };
|
||||
+ Rust source directory",
|
||||
+ ))?;
|
||||
|
||||
let cmode = if let Some(triple) = args.target() {
|
||||
if triple == meta.host {
|
||||
```
|
||||
|
||||
Run ``cargo install --path .`` to install the modified cargo-xbuild
|
||||
|
||||
Get a copy of the Rust sources that corresponds to the installed compiler binary, and set up the environment accordingly:
|
||||
```
|
||||
> rustc --version
|
||||
rustc 1.72.1 (d5c2e9c34 2023-09-13) (built from a source tarball)
|
||||
> git clone --depth=1 --recurse-submodules --shallow-submodules https://github.com/rust-lang/rust --branch 1.72.1
|
||||
> export XARGO_RUST_SRC=`pwd`/rust/library
|
||||
```
|
||||
|
||||
Disable other arbitrary checks in the Rust compiler:
|
||||
```
|
||||
> export RUSTC_BOOTSTRAP=1
|
||||
```
|
||||
|
||||
And you can now simply run ``cargo xbuild`` to build the firmware.
|
|
@ -23,6 +23,8 @@ The resulting ELF file will be located under `target/thumbv7em-none-eabihf/relea
|
|||
|
||||
Alternatively, you can install the Rust toolchain without Nix using rustup; see the Rust manifest file pulled in `flake.nix` to determine which Rust version to use.
|
||||
|
||||
For building on FreeBSD or OpenBSD, see BSD.md.
|
||||
|
||||
## Debugging
|
||||
|
||||
Connect SWDIO/SWCLK/RST/GND to a programmer such as ST-Link v2.1. Run OpenOCD:
|
||||
|
|
Loading…
Reference in New Issue