Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 28

Thread: Problem when uploading program to T4.1 in IDE 2.0.2

  1. #1

    Problem when uploading program to T4.1 in IDE 2.0.2

    This problem was not there in 2.0.1 and prior, but what happens is after SOME uploads to my Teensy 4.1, the "Upload" menu-item gets greyed out (and requires a program restart to clear it up). This does not happen on a UNO (other boards not tested here). The loader is 1.58 beta2.
    Of course, the UNO upload happens much faster than the ~80K code++ I am pumping out at this point.
    I sometimes encounter this problem on every upload, sometimes I get a random few before it happens.
    There seems to be a timing issue involved. The progress bar on the IDE itself seems to be still moving after the Teensy Uploader has said it was done. It happens in a short time frame (just a second or so longer), but it is detrimental to my work (or play, whatever) here, as the shutdown/restarts are not instant.
    I tried to get some help on the Arduino forums, but so far it no one else has noticed this.
    I ask here because I lack the knowledge/experience to analyze what happens between the Teensy loader and the IDE to develop a credible root cause for the problem. While it started with a single update to the IDE, I cannot eliminate either software component as the culprit.

    Perhaps even some hints on what more I could do to better define the events.

    - Wes, W5ZZO

    Addendum: It appears that when the Teensy loader is not running and I upload, it opens (as expected) and programs normally. If I close the loader after each upload, this problem seems to happen less frequently. This is just a patchwork solution, and does not work every time.
    Last edited by W5ZZO; 11-19-2022 at 05:36 PM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    Are you using MacOS, Windows or Linux? Which version? Are you running directly on real hardware, or inside a virtual machine?

  3. #3
    Windows 10 straight up.
    I got some advice yesterday over on the Arduino forum on how to find the log file from the IDE..
    As usual, since I learned that I haven't had a failure yet. I hate these sort of inconsistent issues.
    I will put up logs when it happens again.

    - Wes, W5ZZO

  4. #4
    It happened again, and I have a log. It is around 190KB though.
    I don't see any way to attach it, should I just paste it into a message?

    - Wes, W5ZZO

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,691
    Quote Originally Posted by W5ZZO View Post
    It happened again, and I have a log. It is around 190KB though.
    I don't see any way to attach it, should I just paste it into a message?

    - Wes, W5ZZO
    Lower right corner of 'Post Quick Reply' is 'Go Advanced'. On Advanced post there is an icon for 'attach file'.

    190KB may be close to MAX size and fail attach during 'upload file' after it is located - so it may need to be put into a ZIP.

    Also - where was the log file located?

  6. #6
    The logs are in user/username/appdata/roaming/ArduinoIDE/
    It seems to do a daily delete, at least when you use it every day.
    I went ahead and zipped it so it is now only 13K in size.

    - Wes, W5ZZO

    2022-11-21_log.zip

  7. #7
    I have also determined (as best I can) that this problem DOES NOT happen when the Serial Monitor window is closed.
    I don't know whether the IDE or the Teensyloader is not working right, but as it stands they appear not to be getting along smoothly.
    Since this started with IDE 2.0.2, which included code fixing a bug related to serial port recapture failure (or slowness) disabling the "Compile" AND "Upload" menu-items, it would be easy to blame the IDE. But maybe the prior behavior masked an issue with the loader action sequences. I am totally out at sea on how to delve further.

    - Wes, W5ZZO

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,691
    Quote Originally Posted by W5ZZO View Post
    I have also determined (as best I can) that this problem DOES NOT happen when the Serial Monitor window is closed.
    I don't know whether the IDE or the Teensyloader is not working right, but as it stands they appear not to be getting along smoothly.
    Since this started with IDE 2.0.2, which included code fixing a bug related to serial port recapture failure (or slowness) disabling the "Compile" AND "Upload" menu-items, it would be easy to blame the IDE. But maybe the prior behavior masked an issue with the loader action sequences. I am totally out at sea on how to delve further.

    - Wes, W5ZZO
    With IDE 2, been finding here that open SerMon working before upload will not 'reconnect' after upload. Requires SerMon Close and re-open then it connects and runs fine.

    So, closing SerMon and re-opening after upload would eliminate that hitch in advance.

    Typical use here is TyCommander for SerMon and building with CmdLine from SublimeText on Windows - and that cmdline batch file uses the '--delegate' option that has TyComm prompt for what Teensy then take Serial Offline and defers to Teensy Loader for the upload {so that Locked T_4.x's can get .eHex files}. That has continues to work with no problem - as did the IDE 1.8.19 SerMon did. So, some element of the IDE 2.0 seems to be the issue and not any direct fault of the Teensy or with Windows changing something about USB connectivity.

    TyComm isn't a direct replacement for IDE 2 usage without manually taking TyComm Serial offline to allow upload and then turning the Serial back on in TyComm. Under IDE 1.8.x there was 'Integrate to Arduino' - but that hasn't been looked into for IDE 2, or at least not tried here. Even so that doesn't work for T_4.x's requiring .eHex upload - unless finding the 'edited line' and adding '--delegate' might work.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    I tried dozens of uploads with Arduino 2.0.2 and a simple program. Could not get any behavior where the Upload button remains grayed out.

    Click image for larger version. 

Name:	capture.png 
Views:	20 
Size:	278.7 KB 
ID:	29802

    Clicking either Verify or Upload causes the "Output" tab to be selected. But after uploading, just clicking "Serial Monitor" tab always showed the serial monitor had reconnected. I never needed to use the menu to open the port again.

    Maybe this problem only happens with large programs?

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,691
    @Paul - can you post that simple sketch - easy to type but IDE and Boards need updating first it seems ...

    I'll build and run that and some other sketch and see if I can get a repro of any failure to connect on Win 11.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    Quote Originally Posted by defragster View Post
    can you post that simple sketch
    Code:
    void setup() {
      pinMode(13, OUTPUT);
      Serial.begin(9600);      // not needed
      Serial.println("Begin");
    }
    
    void loop() {
      static unsigned int count = 0;
      Serial.print("count = ");
      Serial.println(count++);
      digitalToggle(13);
      delay(250);
    }

  12. #12
    Yes, it's a larger size program, tons of audio objects.

    Memory Usage on Teensy 4.1:
    FLASH: code:84068, data:33928, headers:8976 free for files:7999492
    RAM1: variables:65952, code:80520, padding:17784 free for local variables:360032
    RAM2: variables:18112 free for malloc/new:506176

    I have the problem ONLY if I leave the Serial Monitor on the IDE open when uploading. Used to be that worked fine (and still does, as far as I can tell on UNOs).
    With Serial Monitor left open, here it is just a matter of time until the "Upload" menu-item greys out.
    BUT, I always hear Windows connect system sound, and the SM is always working.
    TBH, I have bit my lower lip and closed the SM in the IDE completely, and use Coolterm for debugging/configuring. More steps, but no restarting the IDE every other compilation.
    Thanks for looking into it.

    - Wes

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,691
    See thread : forum.pjrc.com/threads/71588-Arduino-IDE2-Serial-Monitor-sometimes-does-not-work-continue-from-Upload-Thread?p=316529#post316529

    As far as behavior noted here this demonstrates it looking like the T_4.1 output is not present.
    > So different behavior - UPLOAD never grayed out. Teensy is connected - just IDE GUI aberration.
    Last edited by defragster; 11-30-2022 at 05:30 PM.

  14. #14

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    Quote Originally Posted by W5ZZO View Post
    Yes, it's a larger size program, tons of audio objects.
    ...
    I have the problem ONLY if I leave the Serial Monitor on the IDE open when uploading. Used to be that worked fine (and still does, as far as I can tell on UNOs).
    I left the serial monitor panel open every time I clicked Upload (using the small test program) and I was not able to reproduce this problem after a few dozen tries.

    If you give me a complete (large) program to use, I'll try again. More specific info about exactly what to click (perhaps even a screen recording) might also help, so I do the steps the same way you are doing them.

    I hope you can understand there is little I can do it I'm unable to reproduce the problem on my Windows test machine. I'm not familiar with Arduino's log files or the internal design of the new 2.0.x IDE, so I can't work with that stuff. I need a way to reproduce the problem.

  16. #16
    The effort is incomplete, and most of what is in here has been done over and over, so here are the project files, all zipped up.
    Thanks for looking.

    - Wes, W5ZZO
    Attached Files Attached Files

  17. #17
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,371
    As mentioned in the first post, there is a forum thread up on the Arduino forum on this: https://forum.arduino.cc/t/ide-2-0-2...upload/1054971

    I just posted a little up there, including mentioning this thread.

    Most of the time, when I have IDE2 fail to do upload and/or show Serial monitor data, there is either an issue of which Teensy port is selected and/or I have TyCommander open and using it as my Serial monitor, or I have multiple IDE2 windows open and one of the other ones has the Serial monitor active in it's window.

    For the TyCommander case - I either click on the Serial and turn it off and try an upload again. Or more likely I press the program button on the Teensy and Teensy Tool uploads the sketch.

    For Multiple windows open - I double check and make sure to turn off the Serial for the other windows and/or close those windows.

    The remaining case, which I ran into yesterday. It uploaded fine but did not always show the Serial data.

    In my case:
    I opened a sketch, in this case the example USBHost_viewer of the library USBHost_t36. The Toolbar Board drop down list was not showing the board I wished to program, so I selected it from the drop-down list (It showed both Teensy Micromod and the Serial port).

    I clicked the upload button, and it did successfully program the Micromod, but when I clicked to view the Serial Monitor data, nothing was showing up.
    I then went to the Menu Tools->Port and it showed The Com under the Teensy Ports as selected. I then went and choose the Com27 not under Teensy ports and the data showed up.
    I then went back and choose the one under Teensy Ports and the Serial monitor showed empty again. But if I then did an upload command again, the upload succeeded AND the serial monitor data came out.

    It was almost like maybe selecting the Toolbar drop down item, did not setup the same state as choosing the ports within the Tools->Port menu. But again just guessing.

  18. #18
    I have seen and reported the lazy serial data display in IDE 2.0.x, iirc it has been there since the RC versions. Data appears to be captured, but will not display until you use the scroll-wheel in the window.
    For now, I am just leaving the Serial Monitor window closed and using CoolTerm to communicate with the board. It may, or may not, be as good as TyCommander, but I know how to use it. Like you, if I forget to close it upload fails, but that's not a bug, it's operator error.

    - Wes, W5ZZO

  19. #19
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,691
    Quote Originally Posted by W5ZZO View Post
    I have seen and reported the lazy serial data display in IDE 2.0.x, iirc it has been there since the RC versions. Data appears to be captured, but will not display until you use the scroll-wheel in the window.
    For now, I am just leaving the Serial Monitor window closed and using CoolTerm to communicate with the board. It may, or may not, be as good as TyCommander, but I know how to use it. Like you, if I forget to close it upload fails, but that's not a bug, it's operator error.

    - Wes, W5ZZO
    Glad the lazy data reported - that is what is showing here.

    @W5ZZO - Might view this issue for tycomm working simple task for IDE 2.0 integration: github.com/Koromix/tytools/issues/103

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    I tried uploading the code from msg #16 to a Teensy 4.1 on Windows 10 with Arduino 2.0.2 and Teensyduino 1.57.1. I uploaded many times with the serial monitor open, but I could not reproduce any sort of problem where the Upload menu became grayed out or disabled.

    To show you what I tried, and so you can see what I saw on my screen, I made a video recording. Sorry, the quality isn't great... I just grabbed a camera and pointed it at the screen without much setup (I don't use Windows much... not sure what to do in Windows to create a screen recording with audio). Hopefully you can at least see what I clicked and the results on my screen.


  21. #21
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    Ok, I read the Arduino forum thread and played with this more.

    It seems the problem depends on whether you select "Serial ports" or "teensy ports".

    Click image for larger version. 

Name:	capture.png 
Views:	15 
Size:	82.6 KB 
ID:	29818

    Quick fix, just select the "teensy ports" entry. Problem solved! (at least I hope, you can be the judge of that....)

    Long term... I need to do much more investigation to figure out what's going wrong when "Serial ports" is selected. It very likely could be a bug in Arduino 2.0.2 which I can't resolve. When you select "teensy ports", Teensy's pluggable discovery and pluggable monitor tools are used. With "Serial ports" discovery of the hardware and communication for the serial monitor all based on Arduino's code.

    After 5 uploads of the msg #16 code with "Serial ports", I did get the grayed out Upload menu.

    Click image for larger version. 

Name:	capture2.png 
Views:	13 
Size:	30.2 KB 
ID:	29819

    Simply clicking Tools > Ports and selecting the "teensy ports" version fixes everything. The Upload menu becomes clickable again, without even restarting Arduino 2.0.2. As you can see in the video, it's highly reliable with "teensy ports" selected.

  22. #22
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    @Defragster - please start a new thread regarding any issues other than this problem where Arduino 2.0.2's Upload becomes disabled. Maybe edit msg #13 & msg #14 to be just a link to that new thread? Let's keep this thread only about the issue where Upload gets disabled (for reasons as-yet unknown...)

  23. #23
    I should not be happy, but at least now I know I am not seeing ghosts by myself.
    I also learned a lot about what the teensy ports are and "what's under the hood" that I did not know.

    - Wes

  24. #24
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,348
    Rather than pour a lot more time into this issue, which is probably in the Arduino IDE code, I'm going to "solve" it by detecting when "Serial ports" was used to select Teensy. Future versions will print this extra message.

    Teensy should be selected from "teensy ports" rather
    than "Serial ports" in Arduino's Tools > Ports menu
    Click image for larger version. 

Name:	capture.png 
Views:	19 
Size:	88.3 KB 
ID:	29820

  25. #25
    I switched my connection to the teensypins, opened the Serial Monitor and made many uploads w/o the menu greying out.
    I suppose it would be nice if some developer at Arduino would fix this, but so far the workaround is fine.
    This will be my last post on the issue unless the current equilibrium breaks; TY for your (as always) expert analysis.

    - Wes, W5ZZO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •