Compile and flash the Teensy firmware
Build and upload the microcontroller firmware for closed‑loop control.
The closed‑loop motor controller firmware for the robot runs on a Teensy 4.0 microcontroller. Follow these steps to compile and upload the firmware using arduino-cli and teensy_loader_cli.
bash
cd ~/repos/common_platform/firmware/closed_loop
rm -rf build
mkdir build
bash
arduino-cli compile --fqbn teensy:avr:teensy40 --build-property build.usbtype=USB_DUAL_SERIAL --build-path . ../closed_loop.ino
bash
SERIAL_TEENSY_DEVICE=$(find /dev/serial/by-id/ -name "usb-Teensyduino*if00" | head -1)
echo $SERIAL_TEENSY_DEVICE
bash
sudo stty -F $SERIAL_TEENSY_DEVICE 9600
sudo stty -F $SERIAL_TEENSY_DEVICE 134
bash
lsusb | grep Teensy
bash
sudo teensy_loader_cli -v --mcu=TEENSY40 closed_loop.ino.hex