Author Topic: C3000 Usb Serial  (Read 20773 times)

Bombur

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://
C3000 Usb Serial
« on: January 04, 2005, 10:49:33 am »
Hi,

I am trying to use a usb-serial converter and minicom to administer via the serial console on my Solaris boxen.

Has anybody done this?  The 5500 was much simpler in that you could use /dev/ttyS0.

I don't see anything under /dev/usb   for serial nor do I see an appropriate driver under /lib/moduels/2.4.20

If anyone has some pointers, I would greatly appreciate it!


J.
Nokia N800 (Intec Gameboy Advance Case)
SL-C3000 Sharp ROM
Socket CF BT card
Socket BT Serial Adapter
SMC CF Wifi  2642W
Socket CF Ethernet (RJ45)
Sharp Camera (CE-AG06)
GoldX 5 in 1 USB cable kit (GXQU-06)
Socket IO USB-Serial Cable
Krusell Horizontic Premium Case
Qualendar
tkc Applications

Bombur

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://
C3000 Usb Serial
« Reply #1 on: January 04, 2005, 07:23:04 pm »
ok,  I am assuming that no-one else has tried this yet. (minicom and usb-serial converter).  I have found that there are no usb-serial drivers.  Normally, I should be able to see usb serial drivers like mct_u232 or pl2303 but I don't see any on the 3k.  So that means I have to compile my own.  I have done it on my pc but not on my new 3k.

I guess the first thing to ask:   is there an accepted build environment for the 3k or is everyone kind of just muddling along with zcc and some other odds and ends?

Any comments would be most helpful.

J.
Nokia N800 (Intec Gameboy Advance Case)
SL-C3000 Sharp ROM
Socket CF BT card
Socket BT Serial Adapter
SMC CF Wifi  2642W
Socket CF Ethernet (RJ45)
Sharp Camera (CE-AG06)
GoldX 5 in 1 USB cable kit (GXQU-06)
Socket IO USB-Serial Cable
Krusell Horizontic Premium Case
Qualendar
tkc Applications

DreamTheater

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • http://
C3000 Usb Serial
« Reply #2 on: January 05, 2005, 02:06:37 am »
Hi Bombur,

I am also curious about USB serial, especially pl2303, but I haven't set up build environment ready yet.  And for your build environment quiestion, yes I think so.  SHARP already uploaded C3000 version of gcc etc.

- C3000 Kernel Source Code location
http://developer.ezaurus.com/sl_j/source/c...rom1_01.tar.bz2

- C3000 Build Procedure page (in Japanese)
http://developer.ezaurus.com/sl_j/source/c..._101J_c3000.htm

- gcc
http://developer.ezaurus.com/sl_j/tool/too...95.2-0.i386.rpm

- glibc
http://developer.ezaurus.com/sl_j/tool/too....2.2-0.i386.rpm

- headers
http://developer.ezaurus.com/sl_j/tool/too....4.6-3.i386.rpm

I just downloaded them, but haven't  looked into detail yet.  Maybe some of makefiles tell us what the exact module name is.

BTW, the reason why I am curious about this is because I want to let my GPS-360 (Microsoft Street & Trip version) working, where somehow Microsoft version has different Product ID than original Pharos one.  The following one line change in /usr/src/linux/drivers/usb/serial/pl2303.h should does the job.  Bombur, could you build that for me please???

Code: [Select]
// #define PL2303_PRODUCT_ID 0x2303
#define PL2303_PRODUCT_ID 0xaaa0

and here is what I got by lsusb -v command.
Code: [Select]
Bus 001 Device 005: ID 067b:aaa0 Prolific Technology, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 Interface
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x067b Prolific Technology, Inc.
  idProduct          0xaaa0
  bcdDevice            3.00
  iManufacturer           1
  iProduct                2
  iSerial                 3
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               none
        wMaxPacketSize         10
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               none
        wMaxPacketSize         64
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               none
        wMaxPacketSize         64
        bInterval               0
  Language IDs: (length=4)
     0409 English(US)

Jonathan

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • http://
C3000 Usb Serial
« Reply #3 on: January 13, 2005, 03:58:51 am »
Maybe this will help some people who want a quick fix for USB<>SERIAL adaptor cables (and other USB serial devices) on the C3000.

Yesterday I set up the cross compiler on my x86 linux box and compiled the USB serial modules for SL-C3000 from the kernel source on Sharp's website.

I've posted the compiled drivers in the following directory with some rough instructions on installing them:

   http://www.enm.bris.ac.uk/teaching/enjmr/Zaurus_SL-C3000/

I needed to do this to use some Prolific PL2303 and PL2303x based USB<>RS232 converter cables.  After installing these drivers all adaptors work well.  Note that I needed to find a replacement for pl2303.c to add support for the PL2303X chip, but the standard PL2303 driver is also there in the source (that particular problem was a pain in the ****).

I also had some problem with hotplugging and had to add a line to /etc/hotplug/usb.rc to remove the pl2303 module from memory when the machine goes into standby.  On looking at this file again I see that the line was already there, so I don't know if it was just the updated pl2303x driver that solved that problem.  I don't think anyone will have this problem with these drivers.  Mind you, I'm no expert  

Oh yes, and I use minicom pointing to /dev/ttyUSB0.  To make minicom start quickly it helps to disable the modem init string (use 'minicom -o') and hangup strings (delete strings in minicom modem setup screen.)

Hope this helps someone.

Jonathan

[these files may move some time in the future (months rather than days)]

Jonathan

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • http://
C3000 Usb Serial
« Reply #4 on: January 13, 2005, 04:17:34 am »
DreamTheater,

I compiled a special pl2303.o for you using your aaa0 id (only took a minute).  It should be uploaded with this message.  I see that your lsusb command gives the following line:

   bMaxPacketSize0        64

From my recent experience this value indicates a pl2303x device and so you need the updated pl2303 driver that I use.  A bMaxPacketSize0 value of 8 indicates a pl2303 device, I believe.  Your device is unlikely to work properly with the standard pl2303 driver - but I might be wrong.

Rename this file (pl2303_DT.o) to pl2303.o and use in place of the one in my archive.  Maybe it will work...

Best of luck.

Jonathan.

DreamTheater

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • http://
C3000 Usb Serial
« Reply #5 on: January 13, 2005, 05:58:54 am »
Thank you so much Jonathan!!!

I am also in process of setting up my own x86 Linux box for such use, but I will try your module first.

DreamTheater

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • http://
C3000 Usb Serial
« Reply #6 on: January 14, 2005, 05:38:22 am »
it works!!!!

I installed Jonathan provided modules into my C3000 by following included instructions.
When I plugged in Pharos(Microsoft product id) GPS-360 via USB, lsmod shows that drivers are automatically loaded.  Then, I started qpeGPS to see if it really works.
  - I had to execute qpeGPS as root.
  - I set serial device to ttyUSB0 that I got from dmesg result.

and then, it works!  Thank you god.  Thank you Jonathan.  It looks this device can be powered by C3000 USB bus power.
There is one issue I noticed that when I unplugged the USB cable from C3000, then C3000 hangs up.  This is probably because gpsd kept running even if qpeGPS was closed.  So, I tried killall gpsd before unplugging the cable, then no hang.   This is probably a future enhancement point of this driver, if it can successfully catch hot-plug event and unloading the driver or by something else.

Although, I brushed out in the picture below, qpeGPS showed correct Latitude and Longitude of my location.  I am impressed.

Jonathan

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • http://
C3000 Usb Serial
« Reply #7 on: January 14, 2005, 12:09:42 pm »
Great!

Now perhaps you can help me with this little quirk...

I can't get the /dev/ttyUSB0 device to hold its read/write permissions.  That is, as root I can change its permission to allow user and group writing...

    # chmod 666 /dev/ttyUSB0
    # ls -al /dev/ttyUSB0
    crw-rw-rw-    1 root     root     188,   0 Oct 28 03:24 /dev/ttyUSB0

but when I reboot, the device gets reset to :

    crw-r--r--    1 root     root     188,   0 Oct 28 03:24 /dev/ttyUSB0

This happens whether or not the usbserial drivers are loaded at the time of the chmod command.

In other words the Z is automatically resetting the permissions on reboot. Grrr  

As a rule I don't like doing things as root unless I absolutely need to, so I'd rather the ttyUSB0 device stayed write-able for everyone after reboot.

Could you try changing permissions on /dev/ttyUSB0 and then rebooting?
Something like 'chmod  666 /dev/ttyUSB0' would do it.  Not sure if it's just me.

I have a nasty feeling this is build into the ROM and not a config file feature.  I've tried searching for this 'feature' across the whole filesystem but come up blank.  The only other mention of /dev/ttyUSB0 is in the usbserial module sources.

Many thanks,

Jonathan.

Jonathan

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • http://
C3000 Usb Serial
« Reply #8 on: January 14, 2005, 12:40:29 pm »
Got around it for now by putting the chmod command in /etc/rc.local and making sure that script gets executed at boot time, as in the following page...

http://www.zaurususergroup.com/modules.php...=Server%20Setup

Still, not a very elegant solution.

Jonathan.
(mind going a bit dull at 2am  )

Bombur

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://
C3000 Usb Serial
« Reply #9 on: January 14, 2005, 02:00:17 pm »
Thanks Jonathan,

I hadn't had a chance to do this yet as I am in Mexico on vacation.  Only one internet connection in the whole hotel! and no Wifi...argh.

I will give it a try when I get back next week.

J.
Nokia N800 (Intec Gameboy Advance Case)
SL-C3000 Sharp ROM
Socket CF BT card
Socket BT Serial Adapter
SMC CF Wifi  2642W
Socket CF Ethernet (RJ45)
Sharp Camera (CE-AG06)
GoldX 5 in 1 USB cable kit (GXQU-06)
Socket IO USB-Serial Cable
Krusell Horizontic Premium Case
Qualendar
tkc Applications

DreamTheater

  • Newbie
  • *
  • Posts: 44
    • View Profile
    • http://
C3000 Usb Serial
« Reply #10 on: January 15, 2005, 07:38:00 pm »
Jonathan,

I was playing around with srial driver further and I found a way to hook hotplug/unplug events.  Put the following scripts and chmod 755 them.
/etc/hotplug/usb/pl2303
Code: [Select]
#!/bin/sh
. /etc/hotplug/hotplug.functions
if [ ! -L /var/run/usb/%proc%bus%usb%* ]; then
  # echo $PRODUCT > /home/zaurus/product.txt

  # Pharos(Microsoft) GPS-360
  if [ $PRODUCT = "67b/aaa0/300" ]; then
    ln -s /etc/hotplug/usb/usb-gps.off $REMOVER
    mesg make REMOVER in $REMOVER
    chmod 666 /dev/ttyUSB0
    mesg make serial port available to usr
  fi

  # put your if...fi clause here
  # ...
  # ...
fi
/etc/hotplug/usb/usb-gps.off
Code: [Select]
#!/bin/sh
. /etc/hotplug/hotplug.functions
mesg kill gps processes
#killall qpegps
killall gpsd

# these may not be necessary
rmmod pl2303
rmmod usbserial


Here is how those scripts work.
C3000 USB agent calls 'module nama' script in /etc/hotplug/usb if it exists.  So, in this case, /etc/hotplug/usb/pl2303
There may be multiple devices you want to use that are all rely on pl2303 module, so I look at PRODUCT environment variable to do device specific hot-plug/hot-unplug actions.  PRODUCT environment variable contains VenderId, ProductId and bcdDevice, but better to make sure by uncomment the 'echo' line to see what the exact string is.  In the 2nd if clause, I also register REMOVER program which is invoked at unplugging event.  C3000 kernel will create symbolic link to this REMOVER iunder /var/run/usb, so make sure if your REMOVER is successfully registered by looking at that path.

In my GPS case, simply 'chmod 666 /dev/ttyUSB0' allowed me to run qpegps/gpsd as usr level, and also C3000 doesn't hang up at cable unplug even if gpsd is running.    So, rc.local method was good enough for my own purpose.  Still, if qpegps is running at cable unplug time, C3000 hangs.  I will figure out more graceful and perfect way.

Hope this helps.

Jonathan

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • http://
C3000 Usb Serial
« Reply #11 on: January 21, 2005, 11:47:39 am »
DreamTheater,

I just got round to using your scripts.  They worked fine, and your explanation is very clear.  Many thanks.  

A word to anyone trying to program in C on the Zaurus with these pl2303 USB<>SERIAL devices - don't do it!  

I've just spent quite some time getting these devices to replicate what my x86 linux box does with a normal hardware serial port.  I have to communicate with a number of small robots and down(up?)load eeprom data.  It's not just a case of copying and compiling a C file.  Clarification finally came in the form of Perry Harrington's simple terminal program for Zaurus: (http://www.dainst.com/info/programs/terminal/)

Now time to get that GPS dongle...

Jonathan

Bombur

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
    • http://
C3000 Usb Serial
« Reply #12 on: January 21, 2005, 09:58:08 pm »
Jonathan,

thank you for the pl2303 driver.  I used my Serial-IO USB to Serial cable for the first time to administer a Sun 280R server without a hitch.  I tried both minicom and tipterm (terminal) successfully.

Cheers!

J.
Nokia N800 (Intec Gameboy Advance Case)
SL-C3000 Sharp ROM
Socket CF BT card
Socket BT Serial Adapter
SMC CF Wifi  2642W
Socket CF Ethernet (RJ45)
Sharp Camera (CE-AG06)
GoldX 5 in 1 USB cable kit (GXQU-06)
Socket IO USB-Serial Cable
Krusell Horizontic Premium Case
Qualendar
tkc Applications

gjarboni

  • Newbie
  • *
  • Posts: 20
    • View Profile
C3000 Usb Serial
« Reply #13 on: January 29, 2005, 02:34:22 am »
Just to let everyone know, the alternate solution is to use the serial cable for the SL-C5500 (et al). I can confirm that this works with the SL-C3000 (the serial port is /dev/ttyS0).  But the version of minicom I have leaves garbage characters all over the screen. Is there a link to a better version?

Thanks,

Jason M.

Jonathan

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • http://
C3000 Usb Serial
« Reply #14 on: January 29, 2005, 08:46:14 am »
Well that is good news.

But, er, um, I`m not sure what cable you are talking about.  Can you give a URL for it?  

I was, and still am, under the impression that the only way to get serial IO on the C3000 is either via the USB host or via a dedicated CF card.  

I was sure the "hidden" port connector of the C3000 doesn`t do serial, but I`d love to be corrected.

Jonathan