Hm yes I can reproduce this with my Teensy 4.0 (that I can also treat as a 4.1 with identical config as yours…)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Building...
Uploading...
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
the problem is that after the firmware is uploaded, the MCU reboots and it then initializes its USB peripheral to act as a USB serial device, then Windows has to recognize it and initialize it etc. This takes time, but the Testing..
, aka looking at the serial port output, seems to be happening too early. So basically it’s the issue as known in Add test start delay option · Issue #3742 · platformio/platformio-core · GitHub.
Boards with a fixed USB-serial adapter chip don’t have this problem.
Solution per SigFox MKR1200 Unit Testing - If you don't see any output for the first 10 secs, please reset board - #4 by isa56k works for me.
Aka, when I do
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
upload_protocol = teensy-cli
extra_scripts = extra_script.py
with extra_script.py
in the root as
Import("env")
def after_upload(source, target, env):
print("Delay while uploading...")
import time
time.sleep(5)
print("Done!")
env.AddPostAction("upload", after_upload)
and increasing the delay(3000);
to delay(5000);
in the firmware, I get…
> Executing task in folder pico_test_2: C:\Users\Max\AppData\Local\Programs\Python\Python38\Scripts\platformio.exe test --environment teensy41 <
Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items
Processing * in teensy41 environment
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Building...
Uploading...
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
test\test1.cpp:24:test_led_builtin_pin_number [PASSED]
test\test1.cpp:35:test_led_state_high [PASSED]
test\test1.cpp:37:test_led_state_low [PASSED]
test\test1.cpp:35:test_led_state_high [PASSED]
test\test1.cpp:37:test_led_state_low [PASSED]
test\test1.cpp:35:test_led_state_high [PASSED]
test\test1.cpp:37:test_led_state_low [PASSED]
test\test1.cpp:35:test_led_state_high [PASSED]
test\test1.cpp:37:test_led_state_low [PASSED]
test\test1.cpp:35:test_led_state_high [PASSED]
test\test1.cpp:37:test_led_state_low [PASSED]
-----------------------
11 Tests 0 Failures 0 Ignored
========================= [PASSED] Took 16.96 seconds =========================
So it’s ‘just’ a timing issue that will hopefully get resolved in the linked issue.