USBHost_t36 on Teensy 4.1?

cgeber24

Active member
Does the USBHost_t36 library run on the Teensy 4.1? I am just looking to access a USB memory stick...

Thanks,
Chuck Geber
 
I have not been successful getting the Teensy 4.1 Host USB Port to talk to a connected USB drive. I am running the "ListFiles" sketch, and have observed that the Host USB Port's +5V pin is not getting energized (no +5V to GND).

Am I missing something here? The "ListFiles" sketch is using <USB_Host_t36.h>

Thanks!
 
Just as a double check I ran ListFiles on one of usbdrives and is seemed to work:
Code:
System Volume Information/
  WPSettings.dat                                  12
  IndexerVolumeGuid                               76
LOST.DIR/
video/
  .snap/
photo/
  .snap/
  20210101_045152B.jpg                            92983
  20210101_021914B.jpg                            114002
done!

Just to be sure the 5v pin is the first pin closest to the USB connector. I am using one of these connected directly to the T4.1
1719965013263.png
 
Thanks for the reply! I had purchased the same type of cable elsewhere - it is a few inches longer but the exact same pinout (based on the wire colors). The fact that I can't see +5V on the pin closest to the USB connector makes me suspicious of the Teensy 4.1 that I used - I will try another device.
 
The following <post> may be helpful. The 5VDC on the USBhost interface is enabled with a call to the begin() function on the USBhost object.

Mark J Culross
KD5RXT
 
Thanks Mark - that call certainly exists in the ListFiles sketch:

USBHost myusb;
. . .
. . .
myusb.begin();

Is KD5RXT a Ham Radio call sign? 60 years ago I was K3UXJ...

Chuck
 
Hi All:

I ran the ListFiles sketch on another Teensy 4.1 in an existing system and it also is not turning on the Host +5V, so something must be amiss in my sketch build...

The ListFiles.ino file starts with:

MSC USB Drive basic directory list example

created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe
modified 17 Nov 2020
by Warren Watson




The first two lines of file USBHost_t36.h are:

/* USB EHCI Host for Teensy 3.6
* Copyright 2017 Paul Stoffregen (paul@pjrc.com)


Does anyone know if I have grabbed the correct/incorrect version of these files?

Thanks,
Chuck
 
Is Arduino IDE being used to build? With 1.x TeensyDuino 1.59 installs the needed files and with 2.x the board MGR will install the same 1.59 current with all files as needed.

When building in Arduino the last lines of the verbose console output will show the Libraries used. Showing those lines would show if the correct files are used to build.
 
Are you running it with the Teensy connected to a pc with the serial monitor open? The sketch has a while(!Serial); statement before myusb.begin(); so it won't move past that if the Serial output isn't connected.
 
@wwatson Post #3 above pointed to a thread - this post there: https://forum.pjrc.com/index.php?threads/long-time-log-on-sd-card.75275/post-345105

Has code Just loaded to a T_4.1 with a Flash drive on USB and it came up working without edit:
Code:
Initializing USB MSC drive...USB drive initialized.

Menu Options:
    l - List files on disk
    e - Erase log file on disk
    s - Start Logging data (Restarting logger will append records to existing log)
    x - Stop Logging data
    d - Dump Log
    h - Menu


 Space Used = 575062016
Filesystem Size = 31018975232
Directory
---------
System Volume Information/
  WPSettings.dat                      12    11:00  December 16, 2022
  IndexerVolumeGuid                   76    20:50  November 23, 2023
testfile.dat                          256    00:00  January 1, 2023
epd_-win-1_8_0-ea20_4.exe             157531936    10:52  January 3, 2024
ColorTest.png                         55943    23:18  June 13, 2023
INSTALL INSTRUCTIONS.pdf              1268681    15:02  January 6, 2024

// ...

And the build on IDE 1.8.19 with Teensyduino 1.59 ended with this info:
Code:
Memory Usage on Teensy 4.1:
  FLASH: code:81032, data:9188, headers:9104   free for files:8027140
   RAM1: variables:24224, code:78328, padding:19976   free for local variables:401760
   RAM2: variables:12416  free for malloc/new:511872
"T:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/stdout_redirect" "T:\\TEMP\\arduino_build_666213/MSCUSBdatalogger.ino.lst" "T:\\T_Drive\\arduino-1.8.19\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-objdump" -d -S -C "T:\\TEMP\\arduino_build_666213/MSCUSBdatalogger.ino.elf"
Using library USBHost_t36 at version 0.2 in folder: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\USBHost_t36
Using library SdFat at version 2.1.2 in folder: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SdFat
Using library SPI at version 1.0 in folder: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\SPI
Using library EEPROM at version 2.0 in folder: T:\T_Drive\arduino-1.8.19\hardware\teensy\avr\libraries\EEPROM
 
Last edited:
Does anyone know if I have grabbed the correct/incorrect version of these files?
Not sure what you mean - grab - USBHost_t36 is installed when its installed as part of Teensyduino (auto install through board manager with IDE2.2x or downloaded/installed when using IDE1.x
 
Thanks Mark - that call certainly exists in the ListFiles sketch:

USBHost myusb;
. . .
. . .
myusb.begin();

Is KD5RXT a Ham Radio call sign? 60 years ago I was K3UXJ...

Chuck
Chuck:

Yup, another of my (related) hobbies . . . I quite often make use of a variety of Teensy products in my home-built ham radio gadgets !!

Mark J Culross
KD5RXT
 
@cgeber24 - In setup() make sure:
Code:
myusb.begin();
    while (!firstPartition) {
    myusb.Task();
  }
  Serial.println("USB drive initialized.");
is there, myusb.task() is what polls for a connected USB device.
 
Thanks to everyone for the helpful replies....jmarsh helped me identify my cranial/rectal inversion problem whereby I forgot to open the Serial Monitor; that got the USB_Host +5V turned on, but the various example sketches are still not recognizing my USB Thumb Drive. At this point I am suspicious of my USB cabling, so I have ordered the associated cable from pjrc and will try again when the cables arrive.

The thumb drive seems to work AOK when plugged into my PC - it has a red LED that flashes upon first connection to the PC, perhaps indicating the USB enumeration sequence. There is no such flashing when attached to the Teensy 4.1, having tried this with 2 Teensy units.

Here's hoping the new cables resolve this perplexing issue...

Chuck
 
Also, you want to make sure you orient the connector correctly when you connect it to the Teensy. The two ground wires should be facing the 1062 chip.
 
Received new USB cables with same (non-working) result

ListFiles program hangs at:

// Start USBHost_t36, HUB(s) and USB devices.
myusb.begin();

Serial.print("\nWaiting for partition to...");

while (!firstPartition) {
myusb.Task();
}
Serial.println("initialization done.");

Never outputs "initialization done."


I compiled with USBHOST_PRINT_DEBUG and got some interesting output:

1720827630708.png


Note that Teensy has recognized by SanDisk USB Stick!!!

Can someone tell me why the wait for "firstPartition" is hanging? Do I have to format the USB Stick differently???

Thanks a million,
Chuck Geber
 
Try commenting out:

Code:
while (!firstPartition) {
myusb.Task();
}
And see if that helps. Also make sure the USB Stick is formmated to Fat32 for testing...
 
Commenting out the wait-loop enables the ListFile and USB_Logger programs to move forward, but they cannot find any files on the USB stick.

I will check the Fat32 formatting....I've become convinced that this is not a USB issue, but a file system format issue...

Thanks!
 
Commenting out the wait-loop enables the ListFile and USB_Logger programs to move forward, but they cannot find any files on the USB stick.

I will check the Fat32 formatting....I've become convinced that this is not a USB issue, but a file system format issue...

Thanks!
About all that's left that I can think off at this time. Good luck :)
 
Well....when All Else Fails.....I installed a fresh copy of the Arduino IDE and the Teensyduino software.....and....Lo and Behold....the US Host Memory Stick demo programs are now working as advertised.

I would like to extend much Hearty Thanks to all Forum members who took the time to give me some extremely useful tips and pointers! I hope to someday be able to Pay It Back to another Friend in Need.
 
Well....when All Else Fails.....I installed a fresh copy of the Arduino IDE and the Teensyduino software.....and....Lo and Behold....the US Host Memory Stick demo programs are now working as advertised.

I would like to extend much Hearty Thanks to all Forum members who took the time to give me some extremely useful tips and pointers! I hope to someday be able to Pay It Back to another Friend in Need.
That happens more often than not. Glad you have it working :)
 
Back
Top