2010-12-16 13:45:08     Porting a Linux USB driver

Document created by Aaronwu Employee on Aug 25, 2013
Version 1Show Document
  • View in full screen mode

2010-12-16 13:45:08     Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96812   

 

I need to interface a fingerprint reader to the BF548 Kit. Blackfin would be USB Host and reader would be the Device.

 

  www.digitalpersona.com/Biometrics/SDK-Products/One-Touch-for-Linux-SDK/One-Touch-for-Linux-Software-Development-Kit/

 

  www.digitalpersona.com/uploadedFiles/Collateral/Datasheets/OneTouchLinux05-08.pdf

 

How feasible it is to port the driver to Blackfin/Linux? I have used ADI Drivers and know USB internals to some level, but I haven't developed applications with that. Therefore I am pretty knew in that area. Any hints on where to begin from and what the real issues could be?

 

offtopic, does anyone know how such a tested USB driver could be later ported to ADI Driver? Not the right place for VDSP driver related, but perhaps some directions? It's probably too complicated to compare the drivers, and to explain a one to one API mapping.

 

- Prasanth.

QuoteReplyEditDelete

 

 

2010-12-16 14:12:07     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96813   

 

do you want to use this device in Linux or VDSP ?  if under Linux, then if the driver is using libusb, it should be pretty trivial to make it work on a Blackfin processor.  if it uses the usb kernel framework, it should still be pretty easy.

 

if you want to make this work under VDSP then this is not the forum.  we dont use/know/care about VDSP.  you should try the VDSP forums instead:   ez.analog.com/

QuoteReplyEditDelete

 

 

2010-12-16 14:39:06     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96814   

 

Mike,

 

Well, currently I am thinking of use this with Blackfin/uC-Linux.

 

However here is what I am trying to do as long term:

 

Linux --> uC-Linux --> VDSP++

 

I am trying to get an overall idea about the feasibility and complexity involved. I didn't find any info anywhere about porting Linux USB driver to ADI Driver, but of course this isn't the right place...Perhaps I need to think of it has re-writing the driver, rather than porting.

QuoteReplyEditDelete

 

 

2010-12-16 14:44:51     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96815   

 

the website requires registration to d/l their driver, and i'm not about to waste time on that.  so you'd have to look through their code release to see what exactly it is they're giving you.  assuming of course they dont give you any binary-only blobs in which case you might not be able to port it at all.  you'd have to contact them for details.

QuoteReplyEditDelete

 

 

2010-12-22 03:23:43     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96946   

 

I got some code for connecting my Fingerprint sensor:

 

These were written by hacking in to the USB transfers by sniffing / analysing etc.

 

  www.libusb.org/browser/libusb/examples/dpfp.c

 

It build and worked perfectly with Suse Linux.

 

Can I build the above user application with Blackfin/Linux? Do I need to link for the library in uCLinux dist? Could not find libusb.h, but I do find usb.h. Maybe I am not exactly sure what to try...

QuoteReplyEditDelete

 

 

2010-12-22 03:35:39     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96947   

 

And here is another version, here I see usb library and not libusb (  sourceforge.net/projects/fprint/files/libfprint/v0.0.6/)

 

uru4000.c

QuoteReplyEditDelete

 

 

2010-12-22 08:33:44     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96951   

 

Looks like I might be running older versions. When I did some search I saw the release note for 2010:

 

https://docs.blackfin.uclinux.org/doku.php?id=toolchain:release-notes:2010r1&s[]=libusb

 

There are some compatability issues as I found out:

 

  www.libusb.org/

 

There are currently two separate core projects, with non-compatible APIs:

 

    libusb-1.0

    libusb-0.1

 

Are these libraries completely user space callable (irrespective of 1.0 or 0.1)?

QuoteReplyEditDelete

 

 

2010-12-22 09:26:46     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96954   

 

the libusb version used by the toolchain has no bearing on the version used in the distribution and on the Blackfin processor

QuoteReplyEditDelete

 

 

2010-12-23 05:25:45     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96969   

 

Let me understand this correct.

 

So I could run the libusb-1.0 codes in user space in Blackfin/Linux. I could port almost any code (like the above dpfp.c). I don't need to worry about the version of libusb in uClinux dist, since I am building the code from user space.

 

Now, how do I get the libusb libraries and header files to build from user space? Do I need to build them from source, seperately with blackfin toolchain. So I would have to download it as blackfin-toolchain-2010R1-RC4.src.tar.bz2.and compile from source?

 

Pretty much a newbie here..

 

Thanks

 

Prasanth.

QuoteReplyEditDelete

 

 

2010-12-23 11:47:17     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96973   

 

you're confusing the projects.  forget about the toolchain.

 

uclinux-dist already includes libusb-0.x in it.  enable it in the uclinux-dist configuration system.

QuoteReplyEditDelete

 

 

2010-12-24 06:54:46     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96982   

 

Hmmm I would build a libusb application from user space, by linking in to libusb library in uclinux-dist?

 

When I look for the files, it shows:

 

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/lib/libusb # ls

build-libusb-0.1.12  libusb-0.1.12  Makefile  patches  .sgbuilt_lib

 

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/lib/libusb/build-libusb-0.1.12 # ls

config.h        descriptors.o   error.lo        libtool        libusbpp.la  Makefile  usb.h     usbpp.o

config.log      .dist.settings  error.o         libusb-config  libusb.spec  README    usb.lo

config.status   doc             INSTALL.libusb  libusb.la      linux.lo     stamp-h1  usb.o

descriptors.lo  Doxyfile        .libs           libusb.pc      linux.o      tests     usbpp.lo

 

 

The libraries seem to be here:

 

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/romfs/usr/lib # ls

libasound.so.2   libjpeg.so.62  libosip2.so.4        libpng12.so.0  libspeexdsp.so.1  libusb-0.1.so.4

libeXosip2.so.4  liblzo2.so.2   libosipparser2.so.4  libpng.so.3    libspeex.so.1     libusbpp-0.1.so.4

 

With that I suppose I have all required files, and I can build with -L<path to libusb> and -lusb?

 

Sorry for asking this repeatedly...If I am doing it correct, no matter what I try to fix by googling, I get:

 

URU_Simple.c:(.text+0x6): undefined reference to `_usb_init'

URU_Simple.c:(.text+0xa): undefined reference to `_usb_find_busses'

URU_Simple.c:(.text+0xe): undefined reference to `_usb_find_devices'

 

Am I still doing it wrong way or I am missing something in build? The simplest code I am trying is:

 

#include <errno.h>

#include <signal.h>

#include <string.h>

#include <stdio.h>

#include <stdlib.h>

 

#include <usb.h>

 

int main()

{

    struct usb_bus *bus;

    struct usb_device *dev;

 

    /* Initialize libusb */

    usb_init();

 

    /* Find all USB busses on system */

    usb_find_busses();

 

    /* Find all devices on all USB devices */

    usb_find_devices();

 

  

    return 0;

}

QuoteReplyEditDelete

 

 

2010-12-24 06:55:55     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96983   

 

Oh, and, thanks for the patience!

 

- Prasanth.

QuoteReplyEditDelete

 

 

2010-12-24 10:52:22     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96986   

 

please read the documentation:

  docs.blackfin.uclinux.org/doku.php?id=uclinux-dist:existing_libraries#using_from_staging_directory

QuoteReplyEditDelete

 

 

2010-12-24 12:00:26     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96988   

 

I missed that, thanks for pointing out.

 

But, I still could not resolve it...

 

linux-68ge:/prasanth-work/fprint/fprint_reduced/URU_driver_simplified_bfin # bfin-uclinux-gcc URU_Simple.c -o URU_Simple -isystem /prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/staging/usr/include -L /prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/staging/usr/lib

/tmp/ccilsIPu.o: In function `_main':

URU_Simple.c:(.text+0x6): undefined reference to `_usb_init'

URU_Simple.c:(.text+0xa): undefined reference to `_usb_find_busses'

URU_Simple.c:(.text+0xe): undefined reference to `_usb_find_devices'

collect2: ld returned 1 exit status

 

 

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/staging/usr/lib # ls > out

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/staging/usr/lib # grep usb out

libusb-0.1.so.4

libusb-0.1.so.4.4.4

libusb.a

libusb.la

libusbpp-0.1.so.4

libusbpp-0.1.so.4.4.4

libusbpp.a

libusbpp.la

libusbpp.so

libusb.so

 

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/staging/usr/include # ls > out

linux-68ge:/prasanth-work/Linux/Kernel/Linphone-test/uClinux-dist/staging/usr/include # grep usb out

usb.h

usbpp.h

 

I did a make vendor_staging_install, but didnt help.

 

Am I missing anything else in linking?

QuoteReplyEditDelete

 

 

2010-12-24 12:08:22     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96989   

 

the compiler wont magically figure out what libraries you need.  nowhere did you specify -lusb, so the compiler wont attempt to link it in for you.

 

QuoteReplyEditDelete

 

 

2010-12-24 12:59:36     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96990   

 

Actually I tried that earlier, but didn't realize that was a grievous mistake, but then I could never find the library.

 

bfin-uclinux/bin/ld.real: cannot find -lusb

QuoteReplyEditDelete

 

 

2010-12-24 13:23:06     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96991   

 

Not to mention I used -lusb to build the libusb.1.0 and 0.1 codes on host machine. And where I could not fix things on host, I could try with pkg-config --cflags --libs libusb-1.0

 

QuoteReplyEditDelete

 

 

2010-12-24 13:26:08     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96992   

 

do you have a question, or are things working for you now ?

QuoteReplyEditDelete

 

 

2010-12-25 02:31:05     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 96993   

 

I still could not fix it. The lusb library cannot be found while linking:

 

ld.real: cannot find -lusb

QuoteReplyEditDelete

 

 

2010-12-25 04:13:50     Re: Porting a Linux USB driver

Mike Frysinger (UNITED STATES)

Message: 96996   

 

you need to show the full commands you're executing as well as the full output you see.  you cannot post simple snippets and ask questions about it because we really have no idea.  the less information you provide, the less likely we will be able to answer your question.

QuoteReplyEditDelete

 

 

2010-12-28 05:34:25     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 97031   

 

Yes, I fully agree with you; not being a regular I just tend to deviate from the rules - although that's no excuse to be considered.

 

I didnt get the 'library not found' problem anymore, maybe it was a wrong syntax. After that I ended up in 'wrong format' problem. I forgot that I had built the kernel for FDPIC, so it always failed when I tried with bfin-uclinux-gcc, whereas it should have been  bfin-linux-uclibc-gcc. I was messing up things and ended in loop...

 

I fixed all that, and now the test code builds perfectly fine.

 

I am now all set to build and test the fingerprint reader code on Blackfin/Linux through USB.

 

Thanks for the time & help.

QuoteReplyEditDelete

 

 

2010-12-29 08:04:53     Re: Porting a Linux USB driver

Prasanth Rajagopal (INDIA)

Message: 97060   

 

Further to that. I have successfully cross compiled the fprint Linux Fingerprint project to Blackfin/Linux and tested image acquistions with a Digital Persona URU.4000B USB reader.

 

  www.reactivated.net/fprint/wiki/Main_Page.

 

I removed the recognition-algorithm part (hopefully I can add it later, but I had some memory constraints earlier with uCLinux), stripped out most of unused functions and tested on Linux. Then I had to cross compile glib and all its dependencies (googling and fourms helped) and then it worked straight out when I connected the USB device to BF548 Kit. The USB driver is based on libusb.0 .1library. I used the ftp to simply check the *.pgm image file with a browser at Host.

 

- Prasanth.

Attachments

Outcomes