Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OS independent , Platform independent USB device driver

276 views
Skip to first unread message

GürüPràçäd

unread,
Dec 21, 2008, 8:48:18 PM12/21/08
to
Hello guys ,

I do have task of writing a USB device driver , which should be
easily portable across platform and operating system.I was tried
googling , I couldnt get much information regarding that.

I read the whole USB architecture , and understood that only USB Host
controller driver is platform dependent. USB core and USB class are
platform Independent.

So I do have feeling that , I can write USB device driver which is
platform independent and easily portable across Operating Systems.

Is it possible?

Any guides to do that?

Message has been deleted

Janaka

unread,
Dec 22, 2008, 12:57:21 AM12/22/08
to

I've never seen one of these platform portable device drivers before.
What do you mean by "platform portable" ? is this like portable across
Windows/Linux/HPUx type of thing. Let me know if you find one!!
Is this a device driver for host side USB (Such as a System On Chip)
or a client side USB (such as a CommunicationDeviceControl (CDC)) ?

GürüPràçäd

unread,
Dec 22, 2008, 1:15:11 AM12/22/08
to
Well , let me explain my question elaborately.

Almost all operating systems provides Platform specific Host
controller drivers and platform INDependent USB core(or equivalent)
and USB Class drivers.Normally we have to write USB device drivers on
top of USB class drivers, which is also platform(or operating system)
INDependent.

Suppose I write a driver on linux on a known class ( eg: Storage
class) .

Can I easily port the same driver on windows too?
Because even windows provides ,
host controller driver ( usbport.sys )
USB Core ( called USB Bus Driver = usbhub.sys )
USB common class driver ( usbccgp.sys ) etc


So architecture is pretty common , with some differences.

So , what I feel is , with little effort , drivers can be easily
ported across the platforms !!

I need some expert input regarding this

Jike Song

unread,
Dec 22, 2008, 4:16:02 AM12/22/08
to Janaka
Janaka wrote:
>
> I've never seen one of these platform portable device drivers before.
> What do you mean by "platform portable" ? is this like portable across
> Windows/Linux/HPUx type of thing. Let me know if you find one!!

Maybe he can write a user-space USB driver upon libusb, which can support
several OS.


GürüPràçäd

unread,
Dec 22, 2008, 5:08:02 AM12/22/08
to
I know libusb is usermode USB drivers. But the operating system needs
to support usermode usb drivers right?


Not all the operating systems support that.

Even in windows only vista can provide usermode driver in the form of
WinUSB.

On Dec 22, 6:16 pm, Jike Song <albca...@gmail.com> wrote:

Tim Roberts

unread,
Dec 22, 2008, 5:52:52 PM12/22/08
to
GürüPràçäd <guru...@gmail.com> wrote:
>
>Well , let me explain my question elaborately.
>
>Almost all operating systems provides Platform specific Host
>controller drivers and platform INDependent USB core(or equivalent)
>and USB Class drivers.

Unfortunately, this is not true. Drivers in general, and USB drivers in
particular, are system-specific. There's just no way around it. Kernel
services are not standardized, nor are the device models.

>Normally we have to write USB device drivers on
>top of USB class drivers, which is also platform(or operating system)
>INDependent.

Again, this is not true. USB classes might be system-independent, but
their drivers are not.

The CONCEPTS are similar. The USB spec actually uses terms like URB (USB
Request Block) and IRP (I/O request packet), and those concepts exist in
Windows and Linux, but the operation is quite different.

>Suppose I write a driver on linux on a known class ( eg: Storage
>class) .

If you have a device that meets one of the standard USB classes (Storage,
Audio, HID, Video, Net, Comm, etc), then you do not write a driver AT ALL.
The major operating systems all provide drivers for those devices
automatically. Those class drivers then expose those standard services in
whatever way is customary for that system.

>Can I easily port the same driver on windows too?
>Because even windows provides ,
>host controller driver ( usbport.sys )
>USB Core ( called USB Bus Driver = usbhub.sys )
>USB common class driver ( usbccgp.sys ) etc
>
>So architecture is pretty common , with some differences.

The concepts are common. The operation is very different.

>So , what I feel is , with little effort , drivers can be easily
>ported across the platforms !!
>
>I need some expert input regarding this

You are, unfortunately, incorrect.

There is a library called "libusb" that can allow a user-mode application
to act as a device driver for generic USB devices, and it is (more or less)
compatible across several operating systems. However, libusb uses the
generic USB driver on Linux, and installs its own generic USB driver on
Windows.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Janaka

unread,
Dec 22, 2008, 5:56:20 PM12/22/08
to

libusb provides some wrappers to the underlying OS device drivers so
that user space apps can access lower level USB functionality. I
would NOT call it a user space device driver. I would consider X.org
to contain some user space device drivers to access specific features
of graphics cards. Note the difference here. Xorg drivers maps the
HW registers to its memory space and punches values directly to them.
AFAIK libusb uses the OS provided root hub interface to do low level
USB comms. The interaction between HW and software still happens in a
controlled manner through the OS provided device driver.

Janaka

unread,
Dec 22, 2008, 6:05:51 PM12/22/08
to

As Tim points out libusb installs its own generic device driver in
windows (that sometimes stuffs up windows native USB functionality).
But this part of libusb is never portable; its windows specific. I
wouldn't call the portable bits of libusb a "user space device
driver". Its just a easy access wrapper.

GürüPràçäd

unread,
Dec 22, 2008, 11:50:17 PM12/22/08
to
Tim

Thank you very much. This is exactly the answer I was Looking for. It
was very precise answer indeed.


On Dec 23, 7:52 am, Tim Roberts <t...@probo.com> wrote:

> Tim Roberts, t...@probo.com
> Providenza & Boekelheide, Inc.

GürüPràçäd

unread,
Dec 23, 2008, 1:28:42 AM12/23/08
to
Also I was wondering , if anyone could point out , some main
differences between USB architecture of Linux and Windows.I am going
through the documents , but I am not able to get comprehensive
difference list .

Tim Roberts

unread,
Dec 26, 2008, 3:51:20 PM12/26/08
to

The problem is that the question isn't very meaningful. Both systems use
URBs (USB Request Blocks) to send requests to the host controller driver.
Beyond that, they aren't very much alike. You can go look at the source
code for the Linux kernel; the "generic" USB driver (which libusb uses) in
Linux is in src/drivers/usb/core/devio.c. It accepts ioctls from user
mode, and creates URBs to send to the host controller driver.

Tim Roberts

unread,
Dec 26, 2008, 4:03:51 PM12/26/08
to
Janaka <jan...@optiscan.com> wrote:
>
>As Tim points out libusb installs its own generic device driver in
>windows (that sometimes stuffs up windows native USB functionality).
>But this part of libusb is never portable; its windows specific. I
>wouldn't call the portable bits of libusb a "user space device
>driver". Its just a easy access wrapper.

I have to disgree with you, because this kind of assertion raises the hopes
of USB beginners who think they can whack their USB devices just like
reading from a disk file. We see this all the time on the libusb mailing
list.

Libusb provides an interface that is much like WinUSB on Windows. Neither
of them are extra-friendly easy access wrappers. Both are just mappings of
the kernel-level interfaces to user-mode. In order to use either libusb or
WinUSB successfully, you really do have to write a user-mode device driver.
You have to understand descriptors, classes, interfaces, endpoints, pipes,
packets, frames, URBs, and control messages. It requires a level of
expertise that I associate with "device drivers", not "easy access
wrappers".

Stanislaw Gruszka

unread,
Dec 31, 2008, 6:04:34 AM12/31/08
to
GürüPr?çäd wrote:

> So I do have feeling that , I can write USB device driver which is
> platform independent and easily portable across Operating Systems.
>
> Is it possible?
>
> Any guides to do that?
I think (but I'm not 100% certain) jungo provide
widnows and linux abstraction layer for USB
device drivers.

http://www.jungo.com/st/windriver_usb_pci_driver_development_software.html

However better way would be create linux GPL driver with
community. If you provide hardware documentation,
people from linux driver project will write linux driver
for you in the right way - your device will be supported
in current and futher linux kernel releases.
So you could concentrate on widnows and other OS driver.
See here about LDP:

http://www.linuxdriverproject.org/twiki/bin/view

Stanislaw Gruszka

Janaka

unread,
Jan 11, 2009, 10:42:57 PM1/11/09
to
Hi Tim,
> I have to disgree with you, because this kind of assertion ....
Ok. We'll agree to disagree on this.

> Libusb provides an interface that is much like WinUSB on Windows.  Neither
> of them are extra-friendly easy access wrappers.  Both are just mappings of
> the kernel-level interfaces to user-mode.  In order to use either libusb or
> WinUSB successfully, you really do have to write a user-mode device driver.
> You have to understand descriptors, classes, interfaces, endpoints, pipes,
> packets, frames, URBs, and control messages.  It requires a level of
> expertise that I associate with "device drivers", not "easy access
> wrappers".

What you are describing here is the standard USB communications and
infrastructure formats as described in Chapter 8 (as I could remember)
on the USB spec. Who ever uses Libusb surely needs to understand how
USB works. But as far as I am concerned that code does NOT become a
"User space device driver" just because it has to comply with USB
communications spec. As far as I know libUsb based user code does not
have Hardware specific interactions nor time critical response needs
nor interrupts. All of these gets handled on the lower level native
device driver.
Cheers
Janaka

Tim Roberts

unread,
Jan 13, 2009, 1:24:22 AM1/13/09
to
Janaka <jan...@optiscan.com> wrote:
>
>What you are describing here is the standard USB communications and
>infrastructure formats as described in Chapter 8 (as I could remember)
>on the USB spec. Who ever uses Libusb surely needs to understand how
>USB works. But as far as I am concerned that code does NOT become a
>"User space device driver" just because it has to comply with USB
>communications spec. As far as I know libUsb based user code does not
>have Hardware specific interactions nor time critical response needs
>nor interrupts. All of these gets handled on the lower level native
>device driver.

USB drivers do not worry about hardware-specific interactions like DMA,
physical memory and interrupts, either . That's all done by the host
controller driver.

There is, in fact, virtually no difference between a kernel USB driver and
a libusb application, other than the names of the APIs that are used. I've
written many of both.

0 new messages