LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 04-24-2020, 02:04 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-24-2020, 04:33 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Duplicate of https://www.linuxquestions.org/quest...ve-4175673852/. Reported.

Also, I think this should go to the kernel forum. There should be code tags, too.
 
  


Closed Thread

Tags
block devices, 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 bitmap for group 416 not in group (block 0) + group descriptors corrupted? quanta Linux - Server 1 12-08-2010 10:40 AM
fsck.ext3 keeps fails with "Error reading block" short read at same block jpletka Linux - Server 2 06-10-2010 02:46 AM
Error reading block "x" (Attempt to read block from....... pvandyk2005 Slackware 6 07-06-2008 05:25 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 - Newbie

All times are GMT -5. The time now is 03:28 PM.

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