Programming a Teensy 4.1 from within a VM successfully

kd5rxt-mark

Well-known member
Following discussion in another thread (<here>) regarding a lack of success running Arduino + TeensyLoader (including the ability to program the Teensy successfully) from within a virtual machine (VM), I can report that it is certainly possible & that it works successfully as follows:

VM manager: Oracle VirtualBox 6.1.36 running under a Windows 11 Pro 64-bit host
VM OS: Ubuntu 18.04.4 LTS
Teensy application: Teensy MIDI PolySynth Display controller (28569 SLOC)

Code:
Arduino IDE Configuration (last built with Arduino 1.8.19 + Teensyduino 1.57):
     Tools/Board:           "Teensy 4.1"
     Tools/USB Type:        "Serial + MIDI"
     Tools/CPU Speed:       "600MHz"
     Tools/Optimize:        "Smallest Code"
     Tools/Keyboard Layout: "US English"
     Tools/Port:            "/dev/ttyACM0 Serial+MIDI (Teensy 4.1)"

Here's the successful sequence of steps that I used to program the Teensy:

Code:
1) from within the IDE, initiate the source build process to successfully generate the intermediate HEX file

2) press the program button on the T4.1 (to activate the bootloader)

3) from the VBox host menu, to "claim" the T4.1 device as a local USB device
    (take ownership away from the Windows host & give it to the Ubuntu VM, where the USB type is HID for programming),
    select Devices / USB / Van Ooijen Technische Formatica Teensy Halfkay Bootloader [0107]
    { NOTE: after executing the claim, when the mouse is hovered over this device,
    it shows Vendor ID: 16C0, Product ID: 0478, Revision 0107, Serial No. 000D3131, State: Captured }

4) if/when the time is "short" between pressing the T4.1 program button & claiming the T4.1 device as a local USB device,
    TeensyLoader will immediately begin programming the T4.1 . . . if programming does not immediately begin,
    then simply press the program button a second time & TeensyLoader will immediately begin programming the T4.1

5) after programming is complete (as evidenced by the expected sequence of the RED LED on the T4.1,
    the TeensyLoader showing the programming progress bar, followed by the TeensyLoader showing "REBOOT OK"),
    the T4.1 changes its USB interface from HID for programming to the configured USB type

6) from the VBox host menu, to "claim" the programmed T4.1 device as a local USB device
    (take ownership away from the Windows host & give it to the Ubuntu VM, where the USB type is whatever type
    was selected in the Arduino IDE before building the source . . . for my application, it is MIDI+Serial,
    with the MIDI device name of "TMPS-12.3-v2.0"), select Devices / USB / Teensyduino TMPS-12.3-v2.0 [0280]
    { NOTE: after executing the claim, when the mouse is hovered over this device,
    it shows Vendor ID: 16C0, Product ID: 0489, Revision 0280, Serial No. 8645610, State: Captured }

7) Note that following the successful execution of the 15-second factory restore procedure,
    the T4.1 device will show up in the VBox host menu as Devices / USB / Teensyduino RawHID [0280]
    { NOTE: after executing the claim, when the mouse is hovered over this device,
    it shows Vendor ID: 16C0, Product ID: 0486, Revision 0280, Serial No. 8645610, State: Captured }

The OP in the other thread reported that his entire linux environment crashed whenever the Teensy programming button was pressed. I can successfully report that, from within the Ubuntu 18.04.4 VM, I have both repeatedly programmed the T.41 (successfully) & repeatedly pressed the program button (interrupting the programming, etc.), with absolutely no crashes. I also repeatedly physically plugged & unplugged the T4.1 (both while "claimed" & "not claimed"), likewise with absolutely no crashes.

I leave this post here just in case anyone in the future is looking for how to program the Teensy (at least the 4.x) from within a linux VM (Ubuntu under a Windows host in this particular case) . . .

Mark J Culross
KD5RXT
 
Last edited:
Back
Top