USB Device Driver

prathamesh deshpande prathameshdeshpande7 at gmail.com
Sun Jan 22 09:27:20 EST 2012


 I am experimenting with a USB device and studied the steps given in
Linux Device Drivers book.
 I have just started kernel programming and am new in this area.

This is what I tried to do:

 I "make" it, then install the module: # insmod trial.ko. Connect the
pendrive. I checked the /var/log/messages...seemed fine:

Jan 21 00:30:10 prathamesh-laptop kernel: [10508.290016]
usbcore:registered new interface driver prathamesh driver
Jan 21 00:31:57 prathamesh-laptop kernel: [10615.120142] usb
1-1:newhigh speed USB device using ehci_hcd and address 11
Jan 21 00:31:57 prathamesh-laptop kernel: [10615.273792] usb
1-1:configuration #1 chosen from 1 choice

The USB device gets detected and also the individual bulk_in and
bulk_out endpoints show no error.
But when we AND both endpoints, error occurs (line no. 354 trial.c )
on the terminal :-

 if (!(dev->bulk_in_endpointAddr && dev->bulk_out_endpointAddr))
       {
               printk(KERN_ALERT "\nTHIS IS THE POINT OF ERROR\n");
               err("Could not find both bulk-in and bulk-out endpoints");
               goto error;
       }

I see my files created in /sys/bus/usb/drivers.. and a file
/dev/prathamesh driver which i can access i guess.

Do I need to read/write to this file so that the data gets reflected
in the USB using cp command ( however it didn't happen though ) ?
I also chmod 777 ( read write and execute permissions ) to
/dev/prathamesh driver already.

I also tried echo "1" > /dev/prathamesh driver but nothing happened. I
am not able to figure out what to do next.

I also see a file /sys/bus/usb/drivers/prathamesh\ driver/module/
initstate which contains "live" when my driver is loaded.
Also,  /sys/bus/usb/drivers/prathamesh driver/6-1:1.2 which has ep_04
( out_endpoint ) and ep_84  ( in_endpoint )directories which contains
 information about endpoints.

I've attached the folder containing code ( 'trial.c' ) and 'Makefile'
and the error messages ( dmseg | tail -n 50 ).

Can someone please help and tell me what to do next ?
I mean how do I transfer data to my driver so that it gets reflected in my USB ?

Thank you and regards,
Prathamesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Code.tar.gz
Type: application/x-gzip
Size: 4274 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120122/7abe32bf/attachment-0001.gz 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dmesg | tail -n 50
Type: application/octet-stream
Size: 3421 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120122/7abe32bf/attachment-0001.obj 


More information about the Kernelnewbies mailing list