Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Installation

MacOS / Linux

...

Clone repo

...

Install docker

...

Run Docker Desktop

...

Open a terminal in the repo directory

...

Build sample STM dockerfile: sudo docker build -f ./Dockerfile -t ner-gcc-arm .

  1. Note that you only have to do this once really or if the environment was updated, not every time you want to develop

...

Overview

Data & Controls

For D&C, we are going to be using a central docker container for all projects just to try and make development a bit easier. This docker container is specialized for embedded development to replace the awful and bloated embedded tools and IDE’s we would otherwise have to work with (*cough cough STM32 Microchip TI cough cough*).

Installation

  1. Install docker

  2. Create a Docker account and sign in locally

  3. If Windows follow two more steps because Docker for Windows runs on WSL (Windows Subsystem for Linux):

    1. Update WSL by running wsl --update

    2. Set the default WSL version to 2 by running wsl --set-default-version 2

    3. Install the Ubuntu WSL distro by running wsl --install

    4. If you want to install a different distribution, I think you can set flags but Ubuntu is easier imo

    5. Running exit will get you out of WSL if you are in the distro

Usage

MacOS

  1. Make sure Docker Desktop is started

  2. Pull down the Docker container you are using by running docker pull <CONTAINER_NAME> where CONTAINER_NAME can be nwdepatie/ner-gcc-arm for microcontroller development

  3. Start the container by running docker run --rm -it --privileged -v "$PWD:/home/app" <CONTAINER_NAME>:latest bash using the same container you just pulled.

    1. Make sure you are running it in whatever directory you want to operate on

  4. Any flashing hardware should be mounted to container automatically

Linux

  1. Make sure Docker is started (I just run docker and it works but results may vary)

  2. Pull down the Docker container you are using by running docker pull <CONTAINER_NAME> where CONTAINER_NAME can be nwdepatie/ner-gcc-arm for microcontroller development

  3. Start the container by running sudo docker run --rm -it --privileged -v "$PWD:/home/app" ner-gcc-arm<CONTAINER_NAME>:latest bash using the same container you just pulled.

    1. Make sure you are running it in whatever directory you want to operate on

  4. Any flashing hardware should be mounted onto container automatically

Windows

Installation of this environment is a bit more annoying in Windows smh

  1. Clone repo

  2. Install docker

  3. Update wsl2 stuff https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package and install a distro (do Ubuntu, makes it much easier, I was just able to run wsl --install and it worked)

  4. Open a Windows terminal Make sure Docker Desktop is started

  5. Pull down the Docker container you are using by running docker pull <CONTAINER_NAME> where CONTAINER_NAME can be nwdepatie/ner-gcc-arm for microcontroller development

  6. Start the container by running docker run --rm -it --privileged -v "$(PWD):/home/app" <CONTAINER_NAME>:latest bash using the same container you just pulled.

    1. Make sure you are running it in whatever directory you want to operate on

  7. To mount any flashing hardware (this may be condensed into a script in the future):

    1. Open a Windows terminal with admin privileges and run winget install usbipd

    2. Open a WSL terminal (wsl -d ubuntu) and run the following commands to enable mounting Windows USB devices in the Docker container

      1. sudo apt update

      2. sudo apt install linux-tools-virtual hwdata

    and
      1. sudo update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1`

    2 (might need to run sudo update-alternatives before running that last command ?)
    1. If the first command produces errors, try running sudo apt-get update and then rerun the command

  8. Open Docker Desktop

  9. Open a terminal in the repo directory

  10. Build sample STM dockerfile with docker build -f ./Dockerfile -t ner-gcc-arm .

    1. Note that you only have to do this once really or if the environment was updated, not every time you want to develop

  11. Start sample STM dockerfile with
      1. 20

    1. Start Docker container by running docker run --rm -it --privileged -v "$(PWD):/home/app"

    ner-gcc-arm
    1. <CONTAINER_NAME>:latest bash

    Start the Ubuntu WSL client with wsl -d ubuntu
    1. replacing CONTAINER_NAME with the container name in one terminal

    2. (If interacting with hardware) Mount the Raspberry Pi probe by finding the device in another Windows terminal with usbipd wsl list and mount the device in a Windows terminal window (with admin privileges the first time you do this) with usbipd wsl attach --distribution=ubuntu --busid=<BUSID>

Usage

Start Container on MacOS/Linux

In any terminal that is in the directory:

Code Block
# if need to rebuild image
sudo docker build -f ./Dockerfile -t ner-gcc-arm .
sudo docker run --rm -it --privileged -v "$(PWD):/home/app" ner-gcc-arm:latest bash

Start Container on Windows

In any terminal that is in the directory:

Code Block
# if need to rebuild image
# docker build -f ./Dockerfile -t ner-gcc-arm .
docker run --rm -it --privileged -v "$(PWD):/home/app" ner-gcc-arm:latest bash

# mounting probe
# in another terminal run wsl -d ubuntu
usbipd wsl list
usbipd wsl attach --distribution=ubuntu --busid=<BUSID>
# close the other wsl window, the device should be mounted to any wsl instance
      1. You’re looking for the CMSIS-DAP v2 Interface device

        Image Added

Tools / Utils

Code Block
# to build project
make all

# to open a serial port (make sure /dev/tty0/ACM0 exists first)
minicom -b 115200 -o -D /dev/ttyACM0

# to flash STM board with Raspberry Pi Probe (WIP)
openocd -f interface/cmsis-dap.cfg -f target/stm32f4x.cfg -c "adapter speed 5000" -c "program ./build/cerberus.elf verify reset exit"