9 releases (5 breaking)

0.15.0 Feb 11, 2022
0.14.0 Sep 27, 2021
0.12.2 May 31, 2021
0.12.1 Mar 4, 2021
0.11.0 Jul 12, 2020

#334 in Embedded development

Download history 3/week @ 2022-01-18 10/week @ 2022-01-25 10/week @ 2022-02-01 26/week @ 2022-02-08 8/week @ 2022-02-15 14/week @ 2022-02-22 5/week @ 2022-03-01 10/week @ 2022-03-08 33/week @ 2022-03-15 29/week @ 2022-03-22 8/week @ 2022-03-29 7/week @ 2022-04-05 7/week @ 2022-04-12 7/week @ 2022-04-19 72/week @ 2022-04-26 55/week @ 2022-05-03

143 downloads per month
Used in thingy-91-nrf9160-bsp

MIT/Apache

455KB
10K SLoC

Hardware Abstration Layer for the Nordic nRF9160

This crate is a Hardware Abstraction Layer (HAL) for the Nordic nRF9160. It wraps the PAC (nrf9160-pac) and provides high level wrappers for the chip's peripherals.

This crate knows nothing about your PCB layout, or which pins you have assigned to which functions. The only exception are the examples, which are written to run on the official nRF9160-DK developer kit.

Usage

You will require the thumbv8m.main-none-eabihf target installed.

$ rustup target add thumbv8m.main-none-eabihf

Secure vs Non-Secure

This HAL is designed to run in non-secure mode, as should most of your application code. You will therefore need a 'bootloader' which starts in secure mode, moves the required peripherals into 'non-secure' world, and then jumps to your application.

We have succesfully used Nordic's Secure Partition Manager from nRF SDK v1.5.1. SPM v1.5.1 is configured to expect your application at address 0x0005_0000 and so that is what memory.x must specify as the start of Flash.

Note: Other versions of SPM might expect a different start address - especially those compiled as a child image of another application (like at_sample)! You can see the start address on boot-up:

SPM: NS image at 0x50000

This tells you SPM is looking for a non-secure (NS) image at 0x0005_0000.

To build SPM, run:

$ west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.5.1 ncs
$ cd ncs
$ west update # This takes *ages*
$ cd nrf/examples/spm
$ west build --board=nrf9160dk_nrf9160
$ west flash

West is a Python tool supplied by Nordic for building the nRF Connect SDK. See Nordic's website for more details.

Your nRF9160-DK will now have SPM installed between 0x0000_0000 and 0x0004_FFFF. Flashing your application at 0x0005_0000 should not affect SPM, provided you do not select erase entire chip or somesuch!

If you want to change the flash address, supply your own memory.x file in your application crate (or your Board Support Crate) and write a build.rs file that copies your memory.x over the top of this one.

Licence

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~7.5MB
~216K SLoC