Usb device driver programming

Hello, i need a hand here with few questions.
I am writing device driver for the usb data aquisition device. When i plug the device in the ‘usb -vvv’ command returns three devices. USB hub, audio codec and FT232R. I know it should be visible as audio codec and serial port (ft232r) however, what for is the USB hub? That was first one.

The next thing, can you provide me any examples, or tutorials on usb programming in qnx? Ive written simple program that should attach to found usb devices, however it returns "no such device" error code - so, no devices found. This is the error code when usbd_device_ident_t struct is filled with data specfific for pendrive ive plugged in. But when i filled that struct with data specefic for usb hub, the errror code was “device bussy”

The program lists usb controllers, but no reasonable number of devices currently connected is provided. It is 12 for every controller.

I`m attaching source code with its output and usb -vvv output


USB hubs are not passive devices. They appear as devices on the bus just like other devices. Even if you are not using an external hub, most computers with USB connections have a hub intenally.

As a starter, you probably want to get ahold of a good generic boot on USB. There is a lot of terminology that goes along with USB that you have to understand.

Somewhere around there is an example of a USB driver, I think the parallel port driver.


Is your device reporting as a HID device? Those are handled differently than non-HID devices.

There is a USB ddk available. I think it’s on the QNX web site still (was last time I went there a year or so ago). It had non-HID USB examples for a mouse, keyboard and printer.


Generally the device is reported as 3 devices:

  • usb hub
  • audio codec, HID device
  • usb serial uart ft232

Regarding the ddk usb. What is it EXACTLY? All the functions usbd_*() are present in my system, and I can use whenever I want. Why do I need the ddk usb?

Because usbd_attach() returns “resource bussy” for each device mentioned above I am confused what to do. Is there any method to obtain name or any id of driver that uses the device and slay it?

Tim could you pass me the examples, please? (

With a USB driver, you are not interacting with hardware directly. The actual hardware in your system is a chip that is communicated with by inp() and outp() calls. You don’t do this. Instead there is a USB driver called io-usb that does this. The usb_*() interface allows your driver to connect to io-usb and get access to the devices that are connected. The bus itself has limited bandwidth. You can request different types of bandwidth. For example you request a guaranteed delivery of data. The io-usb program is responsible for managing the bandwidth.

Thank you, its much more clear now. Is it mandatory to use ddk to write drivers, or is there any other way (i`m asking cause i have qnx + momentics educational version and I dont have the code that is requierd to download ddk).
The question that remains is, what to do when usbd_attach() returns “resource bussy”?

Is it possible to get access to the usb controller by pci_*() interface (pci -vv returns its vendor and product ID), and then using in()/out() functions perform IO operations with data that finally should be send to the connected device?

Could you please provide me a simple example how to use insertion and removal callbacks with usb devices? The documentation is too enigmatic about it. The other method (loop through all devices) doesn`t work for me, when I try to attach it returns that device is bussy.

Ok, I decided to get accest to the device by accessing the io-usb by usbd_* interface. However the usbd_attach() function (as Ive written above) returns EBUSSY. Ive googled for it, and found post on foundry27: … _pagenum=1

The general idea is to use io-hid with igndev option, this should cause that no driver uses it. Ive added the proper line to main() function, it doesnt work however.

I`m posting my code:

#define CODEC_VENDOR 0x08bb
#define CODEC_PRODUCT 0x29b2
#define CODEC_CLASS 0x01
#define CODEC_SUB_CONTROL 0x01
#define CODEC_PROTO 0x00

int main(int argc, char *argv[]) {

system("io-hid -dusb igndev=0x08bb:0x29b2 &");

usbd_device_ident_t        interest = {
usbd_funcs_t            funcs = {

usbd_connect_parm_t        cparms = {
struct usbd_connection    *connection;
int                        error;

error = usbd_connect(&cparms, &connection);

usbd_hcd_info_t info;

usbd_device_instance_t instance;
int busno, devno;
usbd_device * device;

for (busno = 0; busno < 5; ++busno){
	for ( devno = 0; devno< 5; ++devno){
		memset(&instance, 0, sizeof(usbd_device_instance_t));
		instance.path = busno, instance.devno = devno;
		error = usbd_attach(connection, & instance, 0, &device);
		cout<<"bus: "<<busno<<", dev: "<<devno<<", "<<strerror(error)<<endl;



Could you give ma any clue please?