Skip to content

mmalabanan-iav/docker-demo

Repository files navigation

Docker Demo Application Example

Prerequesites

Tools Description Environment
USB/IP (usbipd) This connects USB devices into WSL (Win11). Latest version is good to use. host
usbutils provides commands such as lsusb (WSL). host (WSL)
openocd debugging client host (WSL)
gdb-multiarch debugging server host (WSL)
docker Install docker desktop host
minicom serial communication via UART host (WSL)

Guides

Building Docker image

At the root of the project folder:

docker build -t docker-demo .

Running Docker image

Again, at the root of the project folder:

docker run -it --rm --privileged -v "$PWD":/workspace docker-demo

NOTE: You may add --hostname <name you want> to distinguish container vs. host.

Getting out of the docker container

To exit out of the container, Ctrl+D.

Building the application

  1. Spin up the docker-demo container.

  2. To have CMake generate the build files, use the following command:

    cmake -B build -G Ninja

    NOTE: If the build directory exists prior, delete the whole folder.

  3. To build the application, use the following command:

    cmake --build build
  4. Now that the application has been built, you may exit out of the container by pressing Ctrl + D.

  5. To flash the application, use the following command:

    make flash

Controlling the LED

  1. Open minicom via terminal

    minicom -b 115200 -D /dev/<device ID>
  2. Select from the following:

Command Description
on Turns on LED
off Turns off LED
blink Blinks LED at 200ms rate
stop Stops blinking or turns off LED

Connecting microcontroller into WSL

The following is required when host is Windows 11.

  1. Install USB/IP (usbipd), may require admins rights.

  2. Once installed, run usbipd list in PowerShell.

    usbipd list

  3. Run usbipd bind --busid <BUS ID> to allow the device to be shared with WSL, may require admin rights.

    For example, using the ID in the previous image:

    usbipd bind --busid 1-3

    Then executing usbipd list,

    usbipd bind

  4. Run usbipd attach --wsl --busid <BUS ID> to attach the USB device to WSL.

    usbipd attach

    NOTE: Sometimes the binding fails when attaching the USB device, if this happends, usbipd bind --force --busid <BUS ID> must be used.

  5. In WSL, run lsusb to find the USB device.

    lsusb

Using OpenOCD without sudo

In WSL or in Linux environment, sometimes sudo is required to execute openocd since it will be dealing with USB.

Execute ./scripts/setup-stlink.sh, so using openOCD with the USB will not require sudo.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors