Welcome to the new Linux Foundation Forum!

Block Driver for the USB drive

I need to develop Block Driver for USB device.

I have followed below link for the same.


But In this code portion of memory is used as Block device. So read and write operations are bit different.

This is how I am treating Read and Write request using SCSI commands :


if(dir == WRITE)
printk("Direction is write");

send_mass_storage_command(device,endpoint_out,lunptr[0],cdbptr,USB_ENDPOINT_OUT,BLOCK_SIZE, expected_tagptr);
usb_bulk_msg(device, usb_sndintpipe(device,endpoint_out),buffer ,buffersize, &size, 0);
else if(dir == READ)
printk("Direction is read");

send_mass_storage_command(device,endpoint_out,lunptr[0],cdbptr,USB_ENDPOINT_IN,BLOCK_SIZE, expected_tagptr);
usb_bulk_msg(device, usb_rcvbulkpipe(device,endpoint_in),buffer,buffersize, &size, 0);

But still it is not working and not able to mount. Anyone has any idea ?

Sign In or Register to comment.