Author Topic: Teensy USB-UART  (Read 4330 times)

0 Members and 1 Guest are viewing this topic.

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Teensy USB-UART
« on: December 09, 2014, 12:58:48 am »
hi guys
i am toying with a 128x128x8bit CCD sensor and i need a fast usb device in order to upload data into my linux box.
i have chosen the teensy v2 device, used as described in this page

to summarize the device looks like an arduino board but it is much more powerful and it has a built-in USB-device, so it is possible to use it to move up to 900Kbyte/sec to the linux host.



the teensy documentation tells to use the following udev rule without specifying which kernel-module has to been used

Code: [Select]
# UDEV Rules for Teensy boards, http://www.pjrc.com/teensy/
#
# The latest version of this file may be found at:
#   http://www.pjrc.com/teensy/49-teensy.rules
#
# This file must be placed at:
#
# /etc/udev/rules.d/49-teensy.rules    (preferred location)
#   or
# /lib/udev/rules.d/49-teensy.rules    (req'd on some broken systems)
#
# To install, type this command in a terminal:
#   sudo cp 49-teensy.rules /etc/udev/rules.d/49-teensy.rules
#
# After this file is installed, physically unplug and reconnect Teensy.
#
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666"
#
# If you share your linux system with other users, or just don't like the
# idea of write permission for everybody, you can replace MODE:="0666" with
# OWNER:="yourusername" to create the device owned by you, or with
# GROUP:="somegroupname" and mange access using standard unix groups.
#
#
# If using USB Serial you get a new device each time (Ubuntu 9.10)
# eg: /dev/ttyACM0, ttyACM1, ttyACM2, ttyACM3, ttyACM4, etc
#    apt-get remove --purge modemmanager     (reboot may be necessary)
#
# Older modem proding (eg, Ubuntu 9.04) caused very slow serial device detection.
# To fix, add this near top of /lib/udev/rules.d/77-nm-probe-modem-capabilities.rules
#   SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", GOTO="nm_modem_probe_end"
#


i have programed my teensy as a serial USB device with the "USB-serial" example.
when i connect to my embedded Linux box i do not get any device to communicate with.
the /dev does not get any new devices when i connect the teensy.

Code: [Select]
# lsusb
Bus 004 Device 009: ID 16c0:047a Van Ooijen Technische Informatica Teensy Serial

this is the kernel dmesg event log when i plug the teensy with a preloaded USB-UART sketch

Code: [Select]
hub 4-0:1.0: port 2, status 0101, change 0001, 12 Mb/s
hub 4-0:1.0: debounce: port 2: total 100ms stable 100ms status 0x101
usb 4-2: new full speed USB device number 9 using uhci_hcd
usb 4-2: ep0 maxpacket = 16
usb 4-2: skipped 4 descriptors after interface
usb 4-2: default language 0x0409
usb 4-2: udev 9, busnum 4, minor = 392
usb 4-2: New USB device found, idVendor=16c0, idProduct=047a
usb 4-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 4-2: Product: USB Serial
usb 4-2: Manufacturer: Your Name
usb 4-2: SerialNumber: 12345
usb 4-2: usb_probe_device
usb 4-2: configuration #1 chosen from 1 choice
usb 4-2: adding 4-2:1.0 (config #1, interface 0)
usbserial_generic 4-2:1.0: usb_probe_interface
usbserial_generic 4-2:1.0: usb_probe_interface - got id
usb 4-2: adding 4-2:1.1 (config #1, interface 1)
usbserial_generic 4-2:1.1: usb_probe_interface
usbserial_generic 4-2:1.1: usb_probe_interface - got id
drivers/usb/core/inode.c: creating file '009'
hub 4-0:1.0: state 7 ports 2 chg 0000 evt 0004


any help is appreciated, thank you  :-+
« Last Edit: December 09, 2014, 01:06:24 am by legacy »
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #1 on: December 09, 2014, 01:35:28 am »
it may be the kernel driver is "USB Modem (CDC ACM) support"
i am adding it to the config and compiling the module …  :box:

Code: [Select]
CC [M]  drivers/usb/class/cdc-acm.o
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #2 on: December 09, 2014, 01:48:26 am »
Code: [Select]
dc_acm 4-2:1.0: usb_probe_interface
cdc_acm 4-2:1.0: usb_probe_interface - got id
cdc_acm 4-2:1.0: This device cannot do calls on its own. It is not a modem.
cdc_acm 4-2:1.0: ttyACM0: USB ACM device
usbcore: registered new interface driver cdc_acm
cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters

kernel/drivers/usb/class/cdc-acm.ko mod

it seems to be recognized, now i need to create the static device node, mknode …… /dev/ttyACM0
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #3 on: December 09, 2014, 06:14:55 am »
Code: [Select]
mknod /dev/ttyACM0 c 166 0

OK, it is working  :-+


i hope this may help  :D
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #4 on: December 17, 2014, 08:15:08 am »
interesting difference between dev/ttyusb and /dev/ttyacm  :D
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #5 on: December 17, 2014, 09:09:45 pm »
i am having issues with a second laptop running linux

i have plugged teensy v2, the kernel is seeing it and it as ttyACM0

Code: [Select]
usb 2-1: ep0 maxpacket = 32
usb 2-1: skipped 4 descriptors after interface
usb 2-1: default language 0x0409
usb 2-1: udev 2, busnum 2, minor = 129
usb 2-1: New USB device found, idVendor=16c0, idProduct=0483
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1: Product: USB Serial
usb 2-1: Manufacturer: Teensyduino
usb 2-1: SerialNumber: 12345
usb 2-1: usb_probe_device
usb 2-1: configuration #1 chosen from 1 choice
usb 2-1: adding 2-1:1.0 (config #1, interface 0)
cdc_acm 2-1:1.0: usb_probe_interface
cdc_acm 2-1:1.0: usb_probe_interface - got id
cdc_acm 2-1:1.0: This device cannot do calls on its own. It is not a modem.
cdc_acm 2-1:1.0: ttyACM0: USB ACM device
usb 2-1: adding 2-1:1.1 (config #1, interface 1)
drivers/usb/core/inode.c: creating file '002'
hub 2-0:1.0: state 7 ports 2 chg 0000 evt 0002
usb usb3: suspend_rh (auto-stop)
usb usb4: suspend_rh (auto-stop)
systemd-udevd[1532]: starting version 204

but when i try to run mini com i get no output
and the following dmesg

Code: [Select]
uhci_hcd 0000:00:1a.1: reserve dev 2 ep82-INT, period 64, phase 0, 17 us
uhci_hcd 0000:00:1a.1: release dev 2 ep82-INT, period 64, phase 0, 17 us
uhci_hcd 0000:00:1a.1: reserve dev 2 ep82-INT, period 64, phase 0, 17 us
uhci_hcd 0000:00:1a.1: release dev 2 ep82-INT, period 64, phase 0, 17 us

while unplugging this teensy module and plugging it into the first laptop i have used i got the teensy output

differences between the two laptops

working one
  • kernel 2.6.39
  • gentoo
  • DELL laptop
  • the teensy USB is OHCI driven

not working one
  • kenrel 3.1.8
  • gentoo
  • IBM laptop
  • the teensy USB is UHCI driven
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #6 on: December 17, 2014, 10:48:31 pm »
i have done two more tests

1) bare bone piece of C code, compiled without any arduino library
2) arduino code, compiled on Arduino v1.0.5 + teensy library (installed as described in their manual)

the barebone firmware is working on both laptops
the arduino code is not working on the second laptop but it is working on macOSX

there is something strange with this :-//


any idea about what to investigate ?
also, i will try to a MIPS SoC running embedded linux, which is the final target on where i need to plug this teensy device
the Bunker is open!
(shortcut)
 

Offline legacy

  • Super Contributor
  • ***
  • Posts: 3635
  • Country: 00
Re: Teensy USB-UART
« Reply #7 on: December 18, 2014, 03:17:39 am »
i have compiled an ACM kernel module for my MIPS SoC, uploaded to the board, and attached a teensy device in order to test the kernel driver

Code: [Select]
# insmod cdc-acm.ko
cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB
# mknod /dev/ttyACM0 c 166 0
# fempto-uart-terminal /dev/ttyACM0 -b 115200 -p n -s 1 -d 8 -f n -e n
meta=CTRL+T

lidar_controller_v1.2/Rev1
data ready

so it is working  :-+

but it is working everywhere except on UHCI machines like my IBM laptops (1)  :-//




(1) tested on
IBM ThinkPad T23, UHCI: not working
IBM ThinkPad X61S, UHCI: not working
the Bunker is open!
(shortcut)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf