PlatformIO Community

Issue uploading to two Teensy Boards from the IDE/terminal

I created two projects, and want to work simultaneously on them (Split screen code & split terminals).

I was able to upload the code to both boards using the following commands, but it stopped working after a couple of uploads.
pio run -t upload -e slave
and
pio run -t upload -e master

My paltformio.ini files look like this:

[env:master]
platform = teensy
board = teensy35
framework = arduino
build_flags = -D TEENSY_OPT_FASTER
upload_protocol = teensy-cli
upload_port = COM17
monitor_port = COM17
monitor_speed = 115200

and

[env:slave]
platform = teensy
board = teensy35
framework = arduino
build_flags = -D TEENSY_OPT_FASTER
upload_protocol = teensy-cli
upload_port = COM16
monitor_port = COM16
monitor_speed = 115200

I also tried uploading using the following command:
pio run -t upload --upload-port COM16 -e slave

But it fails as below. (Unable to access COM17, which is not the port I want to upload to!)

PS C:\Users\x\Documents\PlatformIO\Projects\timesync_slave> pio run -t upload -e slave -v
Processing slave (platform: teensy; board: teensy35; framework: arduino; build_flags: -D TEENSY_OPT_FASTER; upload_protocol: teensy-cli; upload_port: COM16; monitor_port: COM16; monitor_speed: 115200)
----------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy35.html
PLATFORM: Teensy (4.15.0) > Teensy 3.5
HARDWARE: MK64FX512 120MHz, 255.99KB RAM, 512KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
 - framework-arduinoteensy 1.156.0 (1.56)
 - tool-teensy 1.155.0 (1.55)
 - toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 92 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Time> 1.6.1 (C:\Users\x\.platformio\packages\framework-arduinoteensy\libraries\Time)
Building in release mode
arm-none-eabi-g++ -o .pio\build\slave\firmware.elf -T mk64fx512.ld -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m4 -Wl,--defsym=__rtc_localtime=1650860046 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O2 -fsingle-precision-constant .pio\build\slave\src\main.cpp.o -LC:\Users\2cb\.platformio\packages\framework-arduinoteensy\cores\teensy3 -L.pio\build\slave -Wl,--start-group .pio\build\slave\lib5f2\libTime.a .pio\build\slave\libFrameworkArduino.a 
-larm_cortexM4lf_math -lm -lstdc++ -Wl,--end-group
MethodWrapper(["checkprogsize"], [".pio\build\slave\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   1.7% (used 4376 bytes from 262136 bytes)
Flash: [          ]   3.4% (used 17948 bytes from 524288 bytes)
.pio\build\slave\firmware.elf  :

section                size        addr

.text                 15592           0

.fini                     4       15592

.usbdescriptortable     160   536805376

.dmabuffers             408   536805888

.usbbuffers             864   536806296

.data                  2356   536807160

.bss                    588   536809516

.ARM.attributes          48           0

.comment                110           0

.debug_frame            724           0

Total                 20854
arm-none-eabi-objcopy -O ihex -R .eeprom .pio\build\slave\firmware.elf .pio\build\slave\firmware.hex
<lambda>(["upload"], [".pio\build\slave\firmware.hex"])
AVAILABLE: jlink, teensy-cli, teensy-gui
CURRENT: upload_protocol = teensy-cli
teensy_reboot -s
Unable to open COM17 for reboot request
  Windows Error Info: Access is denied.
  more ideas... https://forum.pjrc.com/threads/40632?p=126667&viewfull=1#post126667     
teensy_loader_cli -mmcu=mk64fx512 -w -s -v .pio\build\slave\firmware.hex
Teensy Loader, Command Line, Version 2.2
Read ".pio\build\slave\firmware.hex": 17952 bytes, 3.4% usage
Soft reboot is not implemented for Win32
Waiting for Teensy device...
 (hint: press the reset button)

Note that despite having upload port set to COM16 in both my ini file and command line argument, it tries to upload to COM17, which is not the port I’m trying to upload to. What am I missing?

Thanks!

The official Teensy upload tools don’t have an upload port that PlatformIO could use. Please see --upload-port flag has no effect · Issue #44 · platformio/platform-teensy · GitHub.

Thank you for pointing that out.