Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: Unable to flash Teensy4.0 with Arduino

  1. #1
    Junior Member
    Join Date
    Oct 2020
    Posts
    4

    Unable to flash Teensy4.0 with Arduino

    I'm using a new Teensy 4.0 which isn't connected to anything except power.
    Using the flashing tool, I'm able to program it with some known good pre-compiled hex files for blink_fast and blink_slow (that I grabbed from here: https://www.pjrc.com/teensy/loader_win10.html), so I can tell that the cable is fine and uploading works.

    However I'm unable to upload any programs compiled from the Arduino IDE (version 1.8.13) with Teensyduino (version 1.53). When installing, I made sure to disable my antivirus.
    These are the settings, which I left as default.
    Click image for larger version. 

Name:	Teensy Settings.png 
Views:	3 
Size:	7.9 KB 
ID:	22204

    I'm trying to compile and upload the blink example
    Code:
    int led = 13;
    
    // the setup routine runs once when you press reset:
    void setup() {
      // initialize the digital pin as an output.
      pinMode(led, OUTPUT);
    }
    
    // the loop routine runs over and over again forever:
    void loop() {
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);               // wait for a second
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);               // wait for a second
    }
    However after it compiles and uploads the hex file, the Teensy appears to lock up. The LED doesn't flash and no lights are on, and I'm no longer able to enter programming mode (pressing the button doesn't do anything)
    I have to use the "restore program" function to factory reset it to the stock blink program in order to get it out of this mode

    Any ideas on what could be causing the problem could be or what to try to fix it? Thanks!

    Some additional info that I observed:
    Also, I've noticed that whatever it's doing/whatever mode it's in causes it to draw less power. While running the default blink sketch that comes with it, it draws ~70mA. But after attempting to program it, it is only drawing ~25mA

    Verbose Info Log (If useful):
    Code:
    03:43:40.389 (post_compile 6): Begin, version=1.53, high-res time
    03:43:40.390 (loader): remote connection 2912 opened
    03:43:40.396 (post_compile 6): Sending command: comment: Teensyduino 1.53 - WINDOWS (teensy_post_compile)
    03:43:40.396 (loader): remote cmd from 2912: "comment: Teensyduino 1.53 - WINDOWS (teensy_post_compile)"
    03:43:40.401 (loader): remote cmd from 2912: "status"
    03:43:40.407 (post_compile 6): Sending command: dir:C:\Users\Redacted\AppData\Local\Temp\arduino_build_149660\
    03:43:40.407 (loader): remote cmd from 2912: "dir:C:\Users\Redacted\AppData\Local\Temp\arduino_build_149660\"
    03:43:40.412 (post_compile 6): Sending command: file:Blink.ino.hex
    03:43:40.412 (loader): remote cmd from 2912: "file:Blink.ino.hex"
    03:43:40.430 (loader): File "Blink.ino.hex". 13172 bytes, 1% used
    03:43:40.441 (loader): remote cmd from 2912: "status"
    03:43:40.450 (post_compile 6): Status: 1, 1, 0, 8, 0, 0, C:\Users\Redacted\AppData\Local\Temp\arduino_build_149660\, Blink.ino.hex
    03:43:40.450 (post_compile 6): Disconnect
    03:43:40.472 (loader): remote connection 2912 closed
    03:43:58.637 (ports 2): WM_DEVICECHANGE DBT_DEVICEREMOVECOMPLETE
    03:43:58.638 (ports 2): remove: loc=usb:80000/1/0/2/3/2
    03:43:58.638 (ports 2): usb_remove: usb:80000/1/0/2/3/2
    03:43:58.638 (ports 2): nothing new, skipping HID & Ports enum
    03:43:58.897 (ports 2): WM_DEVICECHANGE DBT_DEVICEARRIVAL
    03:43:58.898 (ports 2): found_usb_device, id=\\?\usb#vid_16c0&pid_0478#000cac20#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
    03:43:58.898 (ports 2): found_usb_device, loc=usb:80000/1/0/2/3/2    Port_#0002.Hub_#0014
    03:43:58.898 (ports 2): found_usb_device, hwid=USB\VID_16C0&PID_0478&REV_0105
    03:43:58.898 (ports 2): found_usb_device, devinst=00000035
    03:43:58.898 (ports 2): add: loc=usb:80000/1/0/2/3/2, class=HID, vid=16C0, pid=0478, ver=0105, serial=000cac20, dev=\\?\usb#vid_16c0&pid_0478#000cac20#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
    03:43:58.898 (ports 2): hiddev_from_devinst_list: iface=0
    03:43:58.899 (ports 2): found_usb_device complete
    03:43:58.899 (ports 2): hid, found devinst=00000036
    03:43:58.899 (ports 2): hid, path=\\?\hid#vid_16c0&pid_0478#b&6c288a5&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
    03:43:58.899 (ports 2): hid,  opened handle
    03:43:58.900 (ports 2):  devinst=00000036, location=usb:80000/1/0/2/3/2
    03:43:58.900 (ports 2):  vid=16C0, pid=0478, ver=0105, usepage=FF9C, use=0024
    03:43:58.900 (ports 2):  devpath=\\?\hid#vid_16c0&pid_0478#b&6c288a5&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
    03:43:58.900 (ports 2): usb_add: usb:80000/1/0/2/3/2  hid#vid_16c0&pid_0478 (Teensy 4.0) Bootloader
    03:43:59.051 (loader): Device came online, code_size = 2031616
    03:43:59.056 (loader): Board is: Teensy 4.0 (IMXRT1062), version 1.05
    03:43:59.071 (loader): File "Blink.ino.hex". 13172 bytes, 1% used
    03:43:59.078 (loader): set background IMG_ONLINE
    03:43:59.097 (loader): File "Blink.ino.hex". 13172 bytes, 1% used
    03:43:59.105 (loader): elf appears to be for Teensy 4.0 (IMXRT1062) (2031616 bytes)
    03:43:59.109 (loader): elf binary data matches hex file
    03:43:59.113 (loader): elf file is for Teensy 4.0 (IMXRT1062)
    03:43:59.120 (loader): begin operation
    03:43:59.136 (loader): flash, block=0, bs=1024, auto=1
    03:43:59.141 (loader):  gauge old value = 0
    03:43:59.146 (loader): flash, block=1, bs=1024, auto=1
    03:43:59.308 (loader):  gauge old value = 1
    03:43:59.312 (loader): flash, block=2, bs=1024, auto=1
    03:43:59.317 (loader):  gauge old value = 2
    03:43:59.320 (loader): flash, block=3, bs=1024, auto=1
    03:43:59.325 (loader):  gauge old value = 3
    03:43:59.329 (loader): flash, block=4, bs=1024, auto=1
    03:43:59.334 (loader):  gauge old value = 4
    03:43:59.340 (loader): flash, block=5, bs=1024, auto=1
    03:43:59.344 (loader):  gauge old value = 5
    03:43:59.349 (loader): flash, block=6, bs=1024, auto=1
    03:43:59.353 (loader):  gauge old value = 6
    03:43:59.358 (loader): flash, block=7, bs=1024, auto=1
    03:43:59.362 (loader):  gauge old value = 7
    03:43:59.367 (loader): flash, block=8, bs=1024, auto=1
    03:43:59.371 (loader):  gauge old value = 8
    03:43:59.376 (loader): flash, block=9, bs=1024, auto=1
    03:43:59.380 (loader):  gauge old value = 9
    03:43:59.385 (loader): flash, block=10, bs=1024, auto=1
    03:43:59.389 (loader):  gauge old value = 10
    03:43:59.395 (loader): flash, block=11, bs=1024, auto=1
    03:43:59.400 (loader):  gauge old value = 11
    03:43:59.405 (loader): flash, block=12, bs=1024, auto=1
    03:43:59.410 (loader):  gauge old value = 12
    03:43:59.420 (loader): sending reboot
    03:43:59.427 (loader): begin wait_until_offline
    03:43:59.439 (ports 2): WM_DEVICECHANGE DBT_DEVICEREMOVECOMPLETE
    03:43:59.440 (ports 2): remove: loc=usb:80000/1/0/2/3/2
    03:43:59.440 (ports 2): usb_remove: usb:80000/1/0/2/3/2
    03:43:59.440 (ports 2): nothing new, skipping HID & Ports enum
    03:43:59.482 (loader): offline, waited 1
    03:43:59.486 (loader): end operation, total time = 0.361 seconds
    03:43:59.491 (loader): set background IMG_REBOOT_OK
    03:43:59.497 (loader): redraw timer set, image 14 to show for 1200 ms
    03:43:59.553 (loader): HID/win32:  vid:046D pid:C53A ver:4001
    03:43:59.557 (loader): HID/win32:  vid:1532 pid:021F ver:0200
    03:43:59.561 (loader): HID/win32:  vid:28DE pid:2300 ver:0200
    03:43:59.566 (loader): HID/win32:  vid:28DE pid:2300 ver:0200
    03:43:59.570 (loader): HID/win32:  vid:048D pid:8297 ver:0003
    03:43:59.574 (loader): HID/win32:  vid:048D pid:8297 ver:0003
    03:43:59.578 (loader): HID/win32:  vid:1532 pid:021F ver:0200
    03:43:59.582 (loader): HID/win32:  vid:28DE pid:2102 ver:0100
    03:43:59.586 (loader): HID/win32:  vid:28DE pid:2300 ver:0200
    03:43:59.590 (loader): HID/win32:  vid:1B1C pid:0C10 ver:0008
    03:43:59.594 (loader): HID/win32:  vid:046D pid:C53A ver:4001
    03:43:59.598 (loader): HID/win32:  vid:1532 pid:021F ver:0200
    03:43:59.602 (loader): HID/win32:  vid:046D pid:C53A ver:4001
    03:43:59.606 (loader): HID/win32:  vid:043E pid:9A39 ver:0203
    03:43:59.610 (loader): HID/win32:  vid:28DE pid:2102 ver:0100
    03:43:59.614 (loader): HID/win32:  vid:046D pid:C53A ver:4001
    03:43:59.618 (loader): HID/win32:  vid:0FD9 pid:0063 ver:0100
    03:43:59.622 (loader): HID/win32:  vid:1532 pid:021F ver:0200
    03:44:00.692 (loader): redraw, image 9
    03:44:01.041 (ports 2): purge, name=hid#vid_16c0&pid_0478 (Teensy 4.0) Bootloader, loc=usb:80000/1/0/2/3/2, age=1.602 sec
    03:44:01.645 (ports 2): WM_DEVICECHANGE DBT_DEVNODES_CHANGED
    03:44:01.646 (ports 2): nothing new, skipping HID & Ports enum
    03:44:02.147 (ports 2): WM_DEVICECHANGE DBT_DEVNODES_CHANGED
    03:44:02.148 (ports 2): nothing new, skipping HID & Ports enum

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,080
    Arduino is putting the hex file and all the compiled stuff into a temporary folder. The name changes every time you run Arduino. In this log file, you can see it's C:\Users\Redacted\AppData\Local\Temp\arduino_build _149660\

    Could you navigate to that folder and grab the hex file? Or better yet, put the whole thing into a zip file, and then post it here so we can take a look at the files? In using "Quick Reply" on this forum, click "Go Advanced" to get to the full editor which lets you attach files.

  3. #3
    Junior Member
    Join Date
    Oct 2020
    Posts
    4
    No matter what I tried, it kept giving me an error "Upload of file failed"

    I can upload it to google drive and get a link to the zip file. Here's the zipped temp folder that Arduino creates when compiling the example blink sketch:
    https://drive.google.com/file/d/1uZs...ew?usp=sharing

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,080
    I downloaded the zip file and used Teensy Loader to write your HEX file to a Teensy 4.0 here (using Linux). Works fine. I know that doesn't solve your issue, but at least we can know the HEX file data is good.

    From the logfile, looks like you're connected through at least 1 hub, perhaps 2 or 3 (most 7+ port hubs are actually made from multiple 4 port hub chips). We've had some reports of issues with certain types of hubs. Here's a recent thread.

    https://forum.pjrc.com/threads/63718...l=1#post255778

    We also had an issue reported recently (sorry, don't have the link handy) from a Macintosh users where the problem turned out to be too many converter cables plugged in tandem.

    Maybe try plugging directly into your PC with only a single USB cable?

  5. #5
    Junior Member
    Join Date
    Oct 2020
    Posts
    4
    I don't think it would be due to using a USB hub since it's still able to upload the blink_fast hex file. But I tried plugging it in directly to my computer and it still had the same problem.
    I also tried it with another laptop I had laying around, and also tried downgrading the Arduino software to the previous version (1.8.12) neither of which fixed it.

    I'm wondering if it could be some kind of problem with the board itself? Though I have no clue what kind of issue would let me flash some programs but not others...
    I have a spare teensy 3.2 which I tried programming the blink sketch onto which worked perfectly without issue... Unfortunately I can't just use that one since it doesn't have enough PWM pins

    I am now quite thoroughly confused as to what is going on

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,080
    The hub problems seem to be related to power consumption. Those blink hex files are built with slower CPU speed, so they use less power. In Arduino you can access that with Tools > CPU Speed.

  7. #7
    Junior Member
    Join Date
    Oct 2020
    Posts
    4

    It looks like power consumption was likely the problem.
    At the default 600MHz, it was trying to draw more power than the power source was set up to provide, and therefore virtually shutting down. Either lowering the clock frequency or giving it more power seems to fix it.

    At 600MHz it draws about 3x as much power as at 24MHz. Since I don't need super-high performance, I'll probably leave it at the lower clock speed.

    Thanks!

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,080
    USB is really unreliable if running at only 24 MHz, as there's not really enough bus bandwidth. Best to run at 150 MHz or higher if you're going to use USB.

Posting Permissions

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