DEV Community

Cover image for Rewrite Teensy with Docker
Daisuke Mino
Daisuke Mino

Posted on • Edited on

Rewrite Teensy with Docker

Using dockerized Teensy Loader CLI makes it easier to rewrite programs to Teensy.
qmk/qmk_firmware is already dockerized. By using minodisk/teensy_loader together, all processes such as building .hex, loading it into Teensy, and rebooting Teensy can be completed with Docker.

Motivation

I do not want to install various things on my local machine.

Premise

  • qmk/qmk_firmware has been pulled
  • Docker is already installed in your local machine
  • In Linux (Docker for Mac or Win might be difficult or not be able to mount USB)

Demo

asciicast

How to use

Step 1. Prepare YAML for Docker Compose

Add qmk_firmware/docker-compose.yml:

version: '2'
services:
  qmk_firmware:
    build: .
    environment:
      keyboard: ergodox_ez
      subproject:
      keymap: <Your Keymap Name>
    volumes:
      - .:/qmk
      - /qmk/.build
  teensy_loader:
    image: minodisk/teensy_loader:0.0.1
    depends_on:
      - qmk_firmware
    privileged: true
    environment:
      hex: ergodox_ez_<Your Keymap Name>
    volumes:
      - /dev/bus/usb:/dev/bus/usb
    volumes_from:
      - qmk_firmware
Enter fullscreen mode Exit fullscreen mode

Step 2. Build and up

docker-compose build
docker-compose up
Enter fullscreen mode Exit fullscreen mode

Step 3. Press reset button

When the terminal outputs Waiting for Teensy device..., press the reset button on Teensy.

How to work

  1. In teensy_loader container, waits for the .hex to be generated on the volume shared with the qmk_firmaware container
  2. In qmk_firmware container, builds .hex
  3. In teensy_loader container, finds .hex on the volume shared with the qmk_firmware container and runs teensy_loader_cli with wait option
  4. In real world, you press reset button on Teensy (if it maps to a key, press that key)
  5. In teensy_loader container, teensy_loader_cli writes .hex to Teensy and reboots it

Top comments (0)