Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB serial doesn't work with TEENSY_OPT_SMALLEST_CODE #107

Open
ktgilliam opened this issue Sep 5, 2023 · 4 comments
Open

USB serial doesn't work with TEENSY_OPT_SMALLEST_CODE #107

ktgilliam opened this issue Sep 5, 2023 · 4 comments

Comments

@ktgilliam
Copy link

Having some trouble using the USB Serial on the teensy, while optimizing for code size.

I've been able to reproduce the issue using Teensy 4.1 and VS Code's platformIO IDE on both Windows 10 and Ubuntu 22.04.

Steps to reproduce:

  1. Set up the HelloSerialMonitor Teensy example in VSCode (source copied below).
  2. Build and upload, and observe that the serial device is detected by the the OS.
  3. Rebuild with "-D TEENSY_OPT_SMALLEST_CODE" added to build_flags in platformio.ini, then upload and observe that now the serial device does not show up (even if you also have "-D USB_SERIAL" in the build flags as well.

Here is the source :

void setup() 
{                
  Serial.begin(38400);
}
void loop()                     
{
  Serial.println("Hello World");
  delay(1000);
}

and here is the platformio.ini:

[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
build_flags =
    -D TEENSY_OPT_SMALLEST_CODE
    -D USB_SERIAL

Any guidance is appreciated!

@PaulStoffregen
Copy link

PaulStoffregen commented Sep 6, 2023

Please try with Arduino IDE 2.2.1 and Teensy 0.59.3. After selecting Teensy, use Tools > Optimization to select smallest code.

@ktgilliam
Copy link
Author

Please try with Arduino IDE 2.2.1 and Teensy 0.59.3. After selecting Teensy, use Tools > Optimization to select smallest code.

It seems to work for the test case using the Arduino IDE as you instructed. Are they doing something differently than PlatformIO which I can implement? The actual project I'm working on depends pretty heavily on PlatformIO, so I can't easily port it to the Arduino IDE.

Thanks for your help!

@PaulStoffregen
Copy link

What happens if you try Arduino IDE 2.2.1 and Teensy 1.58.1 (the version PlatformIO is probably using)?

@ktgilliam
Copy link
Author

ktgilliam commented Sep 12, 2023

What happens if you try Arduino IDE 2.2.1 and Teensy 1.58.1 (the version PlatformIO is probably using)?

Correction to my previous reply... I thought I was using Teensy 0.59.3 but it wasn't actually installed in the Arduino IDE (just selected). Apologies for that. I ran through several tests now after I realized my mistake, and what I'm finding is that with BOTH Teensy 0.59.3 and And 1.58.1, using Arduino 2.2.1 (both installed and from zip), regardless of the optimization setting, the COM port does populate in device manager... for a few moments at a time. It is repeatedly appearing and then disappearing, and if I try to watch the output in Arduino's serial monitor or using PuTTY I'm not seeing anything.

After un/reinstalling Arduino 1.8.19, teensyduino, platformio, making sure all my drivers are up to date and trying all that stuff again, behavior is the same as in the original post using old arduino or platformio.

So it looks like Arduno 2.2.1 is producing whole different set of behaviors.

Update:

After testing it on a coworker's computer, this issue where the serial port would appear and vanish didn't happen after flashing the Teensy with code that was compiled on his machine (it still happened when it was flashed from mine)... so that seems to be a separate issue with my machine. The issue with the smallest code optimization making the serial port disappear entirely is still occurring though.

Another update:
Okay so after realizing there's some issue with my windows machine, I tried using Teensy 0.59.3 in Arduino 2.2.1 on Linux, and now the serial port is not affected by the smallest code optimization setting... so to summarize, the issue is occurs when building on a windows machine using teensy 1.58.1, regardless of IDE (tried platformio and arduino 2.2.1 and 1.8.19).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants