3

I am trying to write a basic device driver in Linux to perform IO on USB mass storage devices. I am using 2.6.34 kernel for the same. I used usb-skeleton.c that comes with the kernel to understand the correct working of USB core's APIs. I compiled it, inserted it generated /dev/skel0 device for my USB flash drive.

http://lxr.free-electrons.com/source/drivers/usb/usb-skeleton.c?v=2.6.34

I wrote 1 packet of 1024 bytes on the device but to my surprise, the write failed with Input/Output error.

# insmod usb-skeleton.ko
# ls /dev/skel0
  /dev/skel0
# dd if=/dev/urandom of=/dev/skel0 bs=1024 count=1
  dd closing output file `/dev/ask0': Input/Output error

When I wrote data, skeleton driver's write function and even the write callback is getting called but still the IO failed.

As usb-skeleton.c comes with Linux kernel, I am sure that it would be rigorously tested and flawless. I must be doing something wrong and being a novice in device driver programming, am unable to realize the mistake. I would appreciate any help in this matter.

Thank you.

nachiketkulk
  • 1,141
  • 11
  • 22
  • Is there any requirement to use an antique kernel? Otherwise your exercise doesn't make any sense. – 0andriy Dec 08 '15 at 20:10
  • 1
    I am following LDD 3rd edition (Chapter 13 - USB Drivers). I am using 2.6.34 because the book refers this particular version. Otherwise no particular reason behind using the archaic kernel. – nachiketkulk Dec 09 '15 at 01:51

1 Answers1

0

you can use

$ sudo chmod -R 777 /dev/skel0
radrow
  • 6,419
  • 4
  • 26
  • 53