Re: USB Device Driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jan 22, 2012 at 07:57:20PM +0530, prathamesh deshpande wrote:
>  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;
>        }

First off, what type of device are you trying to write a driver for[1]?
Are you sure you will always have a bulk in and out endpoint on it?

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

"I guess"?

Oh wow, please go re-read the USB chapter for how exactly USB works here
please.

> 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.

Did you hook up the character node callbacks properly?  Why are they not
being called?  What do you expect to have your driver do with this data?

> 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.

That's all created automatically by the kernel showing your device,
driver, and module, you don't need to worry about that.

> 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 ?

Again, what type of device is this?

{please let it not be a usb-storage device...}

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux