3 Software Setup
Levi Pearson edited this page 2022-03-09 10:24:55 +00:00

Software Setup

Prerequisites

If you don't have these set up beforehand, much time will be wasted:

  • Native Rust compiler managed by rustup
  • Basic native C development tools
  • A working git installation

Very helpful, but not strictly required, is an editor with good Language Server integration such as:

  • Visual Studio Code
  • Emacs + LSP Mode
  • Some vim/neovim variant with an LSP plugin

Configure to use the rust-analyzer LSP server rather than RLS.

Installing Rust Cross-compiling Components

> rustup target add thumbv7m-none-eabi

Flash/Debug Tools

Debian/Ubuntu Prerequisites

To build the Rust debugger tools, the following packages need to be installed:

> sudo apt install -y pkg-config libusb-1.0-0-dev libftdi1-dev

You may also need to remove old versions of libusb:

> sudo apt remove libusb-dev

Windows Prerequisites

If you don't have vcpkg, install that first:

> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat

Then use it to install libusb and libftdi

> vcpkg install libusb:x64-windows-static-md libftdi1:x64-windows-static-md

macOS Prerequisites

If you don't have brew installed, install that first:

> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install libftdi

> brew install libftdi

Install cargo plugins

These are the tools that interface cargo to the STLinkV2 clone:

> cargo install cargo-flash
> cargo install cargo-embed

If you are using Windows, you won't be able to use the STLinkV2 clone debugger without the STLink driver.

Linux udev rules

This udev rule lets you use the STLinkV2 clone without root privileges.

Create the file /etc/udev/rules.d/70-st-link.rules with the contents shown below.

# ST-LINK/V2
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", TAG+="uaccess"

# ST-LINK/V2-1
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", TAG+="uaccess"

Then reload all the udev rules with:

sudo udevadm control --reload-rules

Crate Setup

Get the first workshop crate ready to go:

> git clone https://cgit.pinealservo.com/BluePill_Rust/blue_pill_base.git
> cd blue_pill_base

You should be able to build successfully with cargo build even if you don't have the hardware handy.

> cargo build --release

If you do have the hardware handy and set up according to the Hardware Setup page, you can try pluggin the STLinkV2 into your computer and running the following to try it out:

> cargo embed --release

Resource Materials

You should clone this repo as well to have documentation near at hand whenever you need it:

> git clone https://cgit.pinealservo.com/BluePill_Rust/resources.git

This contains pinout diagrams (which you may want to print out for reference), schematics for the BluePill board and external peripherals, a collection of ST's reference PDFs relevant to the BluePill, etc.