Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

[help]How to use libusb in uClinux

Hi all.

I'm trying to compile some code that require usb.h in libusb. Could you tell me how to use it in uClinux. I've search in menuconfig for this library but not found. Or I have to cross compile it? If so, plz give me some instructions.

Thanks.

10 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I found a link about existing lib in uClinux for blackfin (my post count isn't enough, so I can't post link here), it say that libusb is provided by uClinux-dist.

    Could I use it for uClinux in Nios? How to use or port it?

    Thanks.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I've just put all libusb code into my own code and compile ok, it work.

    But how to compile libusb as a library?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    --- Quote Start ---

    I've just put all libusb code into my own code and compile ok, it work.

    But how to compile libusb as a library?

    --- Quote End ---

    Please enter the directory of 'libusb/libusb-0.1.12' and do

    
    ./configure --help
    
    .

    Maybe you can see the option '--enable-shared' or '--enable-static'.

    Kazu
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for your help, Kazu.

    Now I have another problem, please help me.

    I tried to work with a usb 3G from huawei. I could get it change to modem mode, then I load the usbserial driver and it show some success msg, it create ttyUSB0, 1, 2, and 3. I can use cat to get data from ttyUSB3, but I can't write command to any of those ttyUSB. I try both echo command from shell and C write function. What should I fix now?

    Thanks.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    --- Quote Start ---

    I tried to work with a usb 3G from huawei. I could get it change to modem mode, then I load the usbserial driver and it show some success msg, it create ttyUSB0, 1, 2, and 3. I can use cat to get data from ttyUSB3, but I can't write command to any of those ttyUSB. I try both echo command from shell and C write function. What should I fix now?

    --- Quote End ---

    At first, check the permission of 'ttyUSB' . like

    
    ls -lp /dev/ttyUSB*
    
    If it's OK, then check the return value of the function 'write' or something, and if it reports some error, check the value 'errno'. If it reports no error,....

    Kazu
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks Kazu.

    Now I can write to ttyUSB0, but when I use "cat /dev/ttyUSB0" from telnet terminal, and write "at<cr><lf>" to ttyUSB0 from jtag terminal, I receive a lot of "at ok at ok at ok..." from telnet terminal. If I do the same on my Ubuntu PC, I receive just 1 "at ok" as normal. Besides that, when I use "chat" program in uClinux to communicate with my usb3g, it can't get any response back. I can't understand this strange :(:( , please help.

    Thanks.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    --- Quote Start ---

    Now I can write to ttyUSB0, but when I use "cat /dev/ttyUSB0" from telnet terminal, and write "at<cr><lf>" to ttyUSB0 from jtag terminal, I receive a lot of "at ok at ok at ok..." from telnet terminal. If I do the same on my Ubuntu PC, I receive just 1 "at ok" as normal.

    --- Quote End ---

    I think that you are sending 'AT' commands to your 3G modem. Maybe your modem echo-back the command to your serial terminal and it may make troubles. How about the mode of echo-back?

    --- Quote Start ---

    Besides that, when I use "chat" program in uClinux to communicate with my usb3g, it can't get any response back. I can't understand this strange :(:( , please help.

    --- Quote End ---

    I don't know such thing. The only way to help you is 'Debugging' by yourself!

    Kazu
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks.

    I think this problem cause by usbserial driver in uClinux, because every test I made on Ubuntu PC is ok. Maybe I'll try to replace uClinux's usbserial driver by those on my PC.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    --- Quote Start ---

    Maybe I'll try to replace uClinux's usbserial driver by those on my PC.

    --- Quote End ---

    Replace ? You mean recompile it from the source for Nios?

    Kazu
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I think usbserial on my PC is ok, so I want to copy them to uClinux-dist and recompile it. I know that's a hard task, but I'll try.