I need to develop Block Driver for USB device.
I have followed below link for the same.
https://github.com/h2016101/Block-De...er/main.c#L299
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 :
memcpy(&(cdbptr[7]),&(sectors),sizeof(sectors));
memcpy(&(cdbptr[2]),&(lba),sizeof(lba));
if(dir == WRITE)
{
printk("Direction is write");
memset(&cdbptr[0],0x2A,sizeof(cdbptr[0]));
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");
memset(&cdbptr[0],0x28,sizeof(cdbptr[0]));
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 ?