Skip to content

Commit

Permalink
Merge pull request #8 from nerwalt/nrf9120-support
Browse files Browse the repository at this point in the history
nrf9120 support
  • Loading branch information
diondokter authored Aug 9, 2024
2 parents 2751088 + fecbfb3 commit 397522d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ jobs:
targets: thumbv8m.main-none-eabihf

- run: cargo fmt -- --check
- run: cargo clippy --target thumbv8m.main-none-eabihf
- run: cargo clippy --features nrf9160 --target thumbv8m.main-none-eabihf
- run: cargo clippy --features nrf9120 --target thumbv8m.main-none-eabihf
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "nrfxlib-sys"
version = "2.4.2"
version = "2.7.0"
authors = [
"Jonathan 'theJPster' Pallant <[email protected]>",
"42 Technology Ltd <[email protected]>",
"Dion Dokter <[email protected]>"
]
edition = "2021"
description = "Rust bindings to the Nordic nRF9160 Socket Library."
description = "Rust bindings to the Nordic nRF91* Socket Library."
readme = "README.md"
license-file = "LICENCE.md"
repository = "https://github.com/nrf-rs/nrfxlib-sys"
Expand Down Expand Up @@ -43,3 +43,10 @@ llvm-tools = { version = "0.1.1", optional = true }
default = ["llvm-objcopy"]
arm-none-eabi-objcopy = []
llvm-objcopy = ["dep:llvm-tools"]

nrf9160 = []
nrf9151 = ["nrf9120"]
nrf9161 = ["nrf9120"]
# The nrf9120 is the part number of the SoC internal to the nrf9151 and nrf9161 SiPs
nrf9120 = []

16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

This is a Rust wrapper for the Nordic
[nrfxlib](https://github.com/NordicPlayground/nrfxlib) set of libraries,
primarily `libmodem` and `liboberon` for the nRF9160.
primarily `libmodem` and `liboberon` for the nRF91* series chips (System-in-Packages). Supported chips are the following:

* nRF9160
* nRF9151
* nRF9161

Any binary which uses this crate is going to need to provide a bunch of C
library functions, because Nordic's library expects them. This includes, but
Expand All @@ -20,11 +24,14 @@ please - for now I'm using

## Using

**NOTE**: This crate does **not** follow [semver](https://doc.rust-lang.org/cargo/reference/semver.html). The version of this crate tracks the version of the underlying Nordic [libraries](https://github.com/nrfconnect/sdk-nrfxlib/tags).

In your own program or library, you can depend on this crate in the usual fashion:

```toml
[dependencies]
nrfxlib-sys = "2.1"
# A chip feature must be selected
nrfxlib-sys = { version = "2.7.0", feature = ["nrf9160"] }
```

Because the modem library has its debug sections compressed and Rust's tooling doesn't have support for
Expand Down Expand Up @@ -67,6 +74,11 @@ without any additional terms or conditions.

### Unreleased Changes ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/develop) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v2.4.2...develop))

### v2.7.0 ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/v2.7.0) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v2.4.2...v2.7.0))

* Updated to [nrfxlib v2.7.0](https://github.com/NordicPlayground/nrfxlib/tree/v2.7.0)
* Added support for the nRF9151 and nRF9161

### v2.4.2 ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/v2.4.2) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v2.1.0...v2.4.2))

* Updated to [nrfxlib v2.4.2](https://github.com/NordicPlayground/nrfxlib/tree/v2.4.2)
Expand Down
24 changes: 22 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
//! Calls out to bindgen to generate a Rust crate from the Nordic header
//! files.

#[cfg(not(any(
feature = "nrf9160",
feature = "nrf9120",
feature = "nrf9151",
feature = "nrf9161",
)))]
compile_error!(
"No chip feature selected. You must selected exactly one of the following features:
nrf9160,
nrf9151,
nrf9161,
"
);

fn main() {
use std::env;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -78,8 +92,14 @@ fn main() {
let bindings_out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs");
std::fs::write(bindings_out_path, rust_source).expect("Couldn't write updated bindgen output");

#[cfg(feature = "nrf9160")]
let libmodem_original_path =
Path::new(&nrfxlib_path).join("nrf_modem/lib/cellular/nrf9160/hard-float/libmodem.a");

#[cfg(feature = "nrf9120")]
let libmodem_original_path =
Path::new(&nrfxlib_path).join("nrf_modem/lib/cortex-m33/hard-float/libmodem.a");
Path::new(&nrfxlib_path).join("nrf_modem/lib/cellular/nrf9120/hard-float/libmodem.a");

let libmodem_changed_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("libmodem.a");

// The modem library now has compressed headers, but Rust cannot deal with that.
Expand Down Expand Up @@ -136,5 +156,5 @@ fn main() {
.display()
);
println!("cargo:rustc-link-lib=static=modem");
println!("cargo:rustc-link-lib=static=oberon_3.0.13");
println!("cargo:rustc-link-lib=static=oberon_3.0.15");
}
2 changes: 1 addition & 1 deletion third_party/nordic/nrfxlib
Submodule nrfxlib updated 1754 files

0 comments on commit 397522d

Please sign in to comment.