LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-18-2008, 08:17 AM   #1
East
Member
 
Registered: Jan 2008
Posts: 84

Rep: Reputation: 15
Smile Help in accessing SATA device


Hi all
I want to know the basics of SATA driver and how the sata devices are communicated to the driver. In PATA we have ports to access the devices.is there anything for SATA.As in a beginner stage can anyone help me?

Thanks in advance.
 
Old 02-18-2008, 09:01 AM   #2
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
check this out ok. http://en.wikipedia.org/wiki/SATA
 
Old 02-18-2008, 09:07 AM   #3
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
in linux it is loaded as a scsi and linux assigns the device a sda and for every partition it is
sda1 or 2 or 3 then the next drive is sdb. the modules are built into the kernel and are detected at boot up then are ported into the loop.after this I am out of my league.
 
Old 02-18-2008, 10:18 PM   #4
East
Member
 
Registered: Jan 2008
Posts: 84

Original Poster
Rep: Reputation: 15
Thanks Drakeo.
Suppose if i have SATA device connected to the system , in that i have installed Linux and i want to get the serial number of the hard disk. Usually in PATA we issue identify drive command to get the device details to the port address where it is connected. But incase of SATA how can issue the command ....what is the structure for sending the commands.
 
Old 02-19-2008, 12:16 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Well I know one way to get the serial number, you can use 'smartctl' if your drive supports SMART.
 
Old 02-20-2008, 08:41 AM   #6
East
Member
 
Registered: Jan 2008
Posts: 84

Original Poster
Rep: Reputation: 15
Cool

I have found site that tells about sending ATA commands to SATA device using sg ioctl. I have filled the sg structure with the below value.I am running this program in Fedora4

sg_io.interface_id = 'S';
sg_io.cmdp = cdb;
sg_io.cmd_len = sizeof(cdb);
sg_io.dxferp = data_in_buffer;
sg_io.dxfer_len = 512;//data_in_length; //
sg_io.dxfer_direction = SG_DXFER_FROM_DEV;
sg_io.sbp = sense;
sg_io.mx_sb_len = sizeof(sense);
sg_io.timeout = 15000;
and CDB structure is,
cdb[0] = 0x85; // ATA pass-through 12
cdb[1] = (4 << 1); // data-in
cdb[2] = 0x2e; // data-in
cdb[4] = 0x00; // ATA feature ID
cdb[6] = 1; // number of sector
cdb[7] = 0x00; //lba_low >> 8;
cdb[8] = 0x00; //lba_low;
cdb[9] = 0x00; //lba_mid >> 8;
cdb[10] = 0x00; //lba_mid;
cdb[11] = 0x00; //lba_high >> 8;
cdb[12] = 0x00; //lba_high;
cdb[14] = 0xEC; // ATA command ID
I have checked CDB values which i am passing with the document "ATA over scsi standard passthru implementation." I am creating the handle for /dev/sda. After passing the ioctl i am getting wrong values in sense buffer.
sense buffer[0]:0x70
sense buffer[1]:0x00
sense buffer[2]:0x05
sense buffer[3]:0x00
sense buffer[4]:0x00
sense buffer[5]:0x00
sense buffer[6]:0x00
sense buffer[7]:0x06
sense buffer[8]:0x00
sense buffer[9]:0x00
sense buffer[10]:0x00. As per program, these values are not valid. I dont know how they have defined like this. Can anyone help me regarding the sense buffer values.
 
Old 02-20-2008, 10:33 AM   #7
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
cat /proc/ide/ide0/hda/model
this will tell you the name and model. if you want to know if your device smart that is old stuff but still used set it to smart. when you boot the bios will read out smart drive capable and using it . if the drive is smart drive when you boot you and is not set to smart. then it willread out smart drive but not enabled good luck.
sorry I do not have a sat drive but you can find the cat /proc/ / / comand very useful.
 
Old 02-20-2008, 10:38 AM   #8
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,716
Blog Entries: 3

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
cat /proc/scsi/scsi this will list your scis devices and info linuz sees sata as scsi.
 
  


Reply



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
Which is the best way for accessing device files in C? halturata Programming 14 10-09-2018 02:44 PM
Accessing SATA drive from Linux applicaiton. RajaGovarthanan Linux - Software 2 02-18-2008 08:01 AM
Accessing USB device directly. hacker supreme General 2 05-13-2007 05:39 PM
Accessing SATA drive captainpete DamnSmallLinux 1 03-30-2006 01:07 AM
Accessing FAT32 on SATA disk AgentX Solaris / OpenSolaris 6 10-22-2005 03:11 PM

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

All times are GMT -5. The time now is 10:12 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