I have just spent last week trying to write a driver for my (68HC08JB8 
based) microcontroller board. Nothing fancy: I just want to be able to
send bytes to the board through USB.

After reading Greg's article in Linux Journal and slightly modifying
usb-skeleton (v.0.6), I have a few questions (since obviously my
driver does not work).

Here are the modifications I made on usb-skeleton to adapt it to my
purpose:
/* Define these values to match your device */
#define USB_SKEL_VENDOR_ID      0x0c70
#define USB_SKEL_PRODUCT_ID     0x0000

#define USB_SKEL_MINOR_BASE     200

and since I do not (yet) use devfs, I removed the two references to
devfs (which I *thought* would be unnecessary).

In order to call this driver, I use the following very simple code:
int main()
{char buf=0xFF;int f;
f=open("/dev/usbskel0",O_RDWR); 
write(f,&buf,1); write(f,&buf,1); write(f,&buf,1); write(f,&buf,1);
write(f,&buf,1); write(f,&buf,1); write(f,&buf,1); write(f,&buf,1);
close(f);return(0);}

Here are the relevant lines in the log (/var/log/messages or dmesg)

This is all done under a newly downloaded (last week end) 2.4.17 kernel.
usb.c: registered new driver usbdevfs
usb.c: registered new driver hub
usb-ohci.c: USB OHCI at membase 0xc4817000, IRQ 9
usb-ohci.c: usb-00:13.0, Acer Laboratories Inc. [ALi] M5237 USB
usb.c: new USB bus registered, assigned bus number 1
usb.c: kmalloc IF c111ff20, numif 1
usb.c: new device strings: Mfr=0, Product=2, SerialNumber=1
usb.c: USB device number 1 default language ID 0x0
Product: USB OHCI Root Hub
SerialNumber: c4817000
    [usb.c message ...]
    [here I plug in my microcontrller]
usb.c: registered new driver skeleton
usb-skeleton.c: USB 68HC08JB8 Driver v0.1
hub.c: port 1 connection change
hub.c: port 1, portstatus 301, change 1, 1.5 Mb/s
hub.c: port 1, portstatus 303, change 10, 1.5 Mb/s
hub.c: USB new device connect on bus1/1, assigned device number 2
usb.c: kmalloc IF c375b700, numif 1
usb.c: new device strings: Mfr=1, Product=2, SerialNumber=0
usb.c: USB device number 2 default language ID 0x409
Manufacturer: MCT Elektronikladen
Product: USB08 Evaluation Board
usb-skeleton.c: USB Skeleton device now attached to USBSkel0
usb.c: skeleton driver claimed interface c375b700
usb.c: kusbd: /sbin/hotplug add 2
usb.c: kusbd policy returned 0xfffffffe

And when I run my user-program for calling the module (as described 
previously):
lpmorh04:/home/jmfriedt# ./usb_test
Unable to handle kernel NULL pointer dereference at virtual address
0000011b
printing eip:
c48283d6
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c48283d6>]    Not tainted
EFLAGS: 00010202
eax: c3107ca0   ebx: c3ab5920   ecx: c3ab5968   edx: 000000ff
esi: 00000001   edi: 00000000   ebp: c30c3f98   esp: c30c3f70
ds: 0018   es: 0018   ss: 0018
Process usb_test (pid: 263, stackpage=c30c3000)
Stack: c3107ca0 ffffffea 00000000 c311a4a0 c1106320 00000002 00000003
c3ab5968
       c1106320 00000000 00000001 c012beab c3107ca0 bffff8cb 00000001
c3107cc0
       c30c2000 40013650 400e0653 bffff8cc c0106b63 00000003 bffff8cb
00000001
Call Trace: [<c012beab>] [<c0106b63>]
Code: 83 7a 1c 8d 75 24 83 3d 00 94 82 c4 00 0f 84 1a 01 00 00 83
Segmentation fault
lpmorh04:/home/jmfriedt#

Now I cannot remember seeing such crashes when I was writing modules for
the
2.0.x or 2.2.x kernels (cannot remember which version it was for).
My concern is mainly about the /dev/ entry. As I said, since I do not
use
devfs I removed the (2 ?) references to devfs in usb-skeleton. I my
older
code, I used to initialize the /dev entry in the module by using 
register_chrdev(MAJOR,"name",&fops); which is apparently no longer done.
I did create mknod /dev/usbskel0 c 180 200 but I do not understand how
to refer to it in usb-skeleton.

Any help would be quite appreciated ?
Thank you, Jean-Michel

_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to