embedded-trainings-2020/embedded-workshop-book/src/installation.md
Dave Hylands 172dbc17cd Update cross compilation target
Use the target actually mentioned in the .cargo/config file.

Updated the output in the troubleshooting page and
also updated the target for the board/dongle.
2020-09-16 17:45:40 -07:00

6.5 KiB

Installation Instructions

VS Code

Windows: Go to https://code.visualstudio.com and run the installer.

Linux: Check your Linux distribution package manager (example below). If it's not there, follow the instructions on https://code.visualstudio.com/docs/setup/linux.

$ # Arch Linux
$ sudo pacman -S code

macOS: Go to https://code.visualstudio.com and click on "Download for Mac"

OS specific dependencies

Linux only: USB

Some of our tools depend on pkg-config and libudev.pc. Ensure you have the proper packages installed; on Debian based distributions you can use:

$ sudo apt-get install libudev-dev libusb-1.0-0-dev

To access the USB devices as a non-root user, follow these steps:

  1. (Optional) Connect the dongle and check its permissions with these commands:
$ lsusb -d 1915:521f
Bus 001 Device 016: ID 1915:521f Nordic Semiconductor ASA USB Billboard
$ #   ^         ^^

$ # take note of the bus and device numbers that appear for you when run the next command
$ ls -l /dev/bus/usb/001/016
crw-rw-r-- 1 root root 189, 15 May 20 12:00 /dev/bus/usb/001/016

The root root part in crw-rw-r-- 1 root root indicates the device can only be accessed by the root user.

  1. Create the following file with the displayed contents. You'll need root permissions to create the file.
$ cat /etc/udev/rules.d/50-oxidize-global.rules
# udev rules to allow access to USB devices as a non-root user

# nRF52840 Dongle in bootloader mode
ATTRS{idVendor}=="1915", ATTRS{idProduct}=="521f", TAG+="uaccess"

# nRF52840 Dongle applications
ATTRS{idVendor}=="2020", TAG+="uaccess"

# nRF52840 Development Kit
ATTRS{idVendor}=="1366", ATTRS{idProduct}=="1015", TAG+="uaccess"
  1. Run the following command to make the new udev rules effective
$ sudo udevadm control --reload-rules
  1. (Optional) Disconnect and reconnect the dongle. Then check its permissions again.
$ lsusb
Bus 001 Device 017: ID 1915:521f Nordic Semiconductor ASA 4-Port USB 2.0 Hub

$ ls -l /dev/bus/usb/001/017
crw-rw-r--+ 1 root root 189, 16 May 20 12:11 /dev/bus/usb/001/017

The + part in crw-rw-r--+ indicates the device can be accessed without root permissions.

On Windows you'll need to associate the nRF52840 Development Kit's USB device to the WinUSB driver.

To do that connect the nRF52840 DK to your PC using micro-USB port J2 (as done before) then download and run the Zadig tool.

In Zadig's graphical user interface,

  1. Select the 'List all devices' option from the Options menu at the top.

  2. From the device (top) drop down menu select "BULK interface (Interface 2)"

  3. Once that device is selected, 1366 1015 should be displayed in the USB ID field. That's the Vendor ID - Product ID pair.

  4. Select 'WinUSB' as the target driver (right side)

  5. Click "Install WinUSB driver". The process may take a few minutes to complete.

You do not need to do anything for the nRF52840 Dongle device.

Rust and tooling

Base Rust installation

Go to https://rustup.rs and follow the instructions.

Windows: Do install the optional components of the C++ build tools package. The installation size may take up to 2 GB of disk space.

Rust Analyzer

All: Open VS Code and look for Rust Analyzer in the marketplace (bottom icon in the left panel). Then install it.

Windows: It's OK to ignore the message about git not being installed, if you get one!

Rust Cross compilation support

All: Run this command in a terminal:

$ rustup +stable target add thumbv7em-none-eabihf

ELF analysis tools

All: Run these commands in a terminal:

$ rustup +stable component add llvm-tools-preview

$ cargo install cargo-binutils

Cargo subcommands

Install version v0.8.0 of the cargo-flash and cargo-embed subcommands, as well as the cargo-binutils set of subcommands and the cargo-bloat subcommand using the following Cargo commands:

$ cargo install cargo-flash --version 0.8.0 -f
(..)
Installed package `cargo-flash v0.8.0` (..)

$ cargo install cargo-embed --version 0.8.0 -f
(..)
Installed package `cargo-embed v0.8.0` (..)

$ cargo install cargo-binutils
(..)
Installed package `cargo-binutils v0.3.0` (..)

$ cargo install cargo-bloat
(..)
Installed package `cargo-bloat v0.9.3` (..)

$ cargo install probe-run
(..)
Installed package `probe-run v0.1.3` (..)

Python

Windows: Go to https://www.python.org/downloads/ and run the Python 3 installer

  • in the installer check the "add Python 3.x to PATH" box
  • also run the "Disable path length limit" action at the end, if you are on Windows 10 and the option is displayed to you

Linux: Install pip using the package manager; this will also install Python.

$ # Arch Linux
$ sudo pacman -S python-pip

macOS: Ensure that you have python 3 and pip installed. Refer to the following link for Instructions on how to install python 3 and pip

$ python --version
Python 3.7.7
$ pip --version
pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

nrf tools

nrfutil

All: Open a terminal and install nrfutil as follows. If you are familiar with python, it is advised to do this in a virtual environment.

$ pip install nrfutil
(..)

$ nrfutil version
nrfutil version 6.1.0

nrf-recover

Some nRF52840 devices, specially older revisions, may have parts of their Flash memory locked. To unlock the memory use the nrf-recover tool.

This is only relevant to the nRF52840 Development Kit. First connect the nRF52840 DK to your PC using micro-USB J2 (as done before) then run the following commands:

$ cargo install nrf-recover

$ nrf-recover -y
Starting mass erase...
Mass erase completed, chip unlocked