LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Closed Thread
  Search this Thread
Old 04-24-2020, 04:49 AM   #1
awesomed
LQ Newbie
 
Registered: Apr 2020
Posts: 4

Rep: Reputation: Disabled
Exclamation Block Driver for the USB drive


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 ?
 
Old 04-26-2020, 03:42 PM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,604

Rep: Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103Reputation: 4103
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
 
  


Closed Thread

Tags
block device, usb



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Block Driver for the USB drive awesomed Linux - Kernel 2 04-24-2020 10:33 PM
Block Driver for the USB drive awesomed Linux - Newbie 1 04-24-2020 04:33 AM
IPTables and PPTPD :S (to block or not to block) thewonka Linux - Networking 0 03-24-2005 06:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration