Skip to contentSkip to conversation

Q: how to send ATA cmds to USB drive?

DISCUSSION Robert Hancock 2 participants 2 messages May 24, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 12 lines · Herbert Rosmanith

good day,

I have a question concerning sending arbitrary ATA commands to an USB drive.

Currently, I have a particular application which sends special ATA commands to an IDE drive using IDE_TASKFILE. So far, this works pretty well.

But now I also have to support USB harddisks from the same company. The USB harddisk uses the same set of ATA commands as the IDE harddisk, well, at least that's what I suppose.

Quoted 6 lines

How do I send ATA commands to this USB drive? I suppose this would be done via SG_IO (the drive is recognised by linux as usb-storage, of course), but how exactly does this have to be done? I have already used SG_IO before to send some MMC commands to cdvd-drives, but I don't know how to send ATA (such as those from T13) commands with this interface.

Short answer is you likely can't. The USB-to-IDE bridge pretty much entirely hides the fact that it's an IDE drive behind it, from the host's viewpoint it looks pretty much like SCSI. Maybe if you sent SCSI commands to the device it would translate them into the correct ATA commands, depending on what exactly you're doing, but that's entirely dependent on the bridge chip in question and I would guess most of them don't support such fancy operations.

Signature · 3 lines
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from [email protected]
Home Page: http://www.roberthancock.com/
#2 lore raw
Quoted 13 lines · Robert Hancock
Quoted 12 lines · Herbert Rosmanith

good day,

I have a question concerning sending arbitrary ATA commands to an USB drive.

Currently, I have a particular application which sends special ATA commands to an IDE drive using IDE_TASKFILE. So far, this works pretty well.

But now I also have to support USB harddisks from the same company. The USB harddisk uses the same set of ATA commands as the IDE harddisk, well, at least that's what I suppose.

Quoted 8 lines
Quoted 6 lines

How do I send ATA commands to this USB drive? I suppose this would be done via SG_IO (the drive is recognised by linux as usb-storage, of course), but how exactly does this have to be done? I have already used SG_IO before to send some MMC commands to cdvd-drives, but I don't know how to send ATA (such as those from T13) commands with this interface.

Short answer is you likely can't. The USB-to-IDE bridge pretty much entirely hides the fact that it's an IDE drive behind it, from the host's viewpoint it looks pretty much like SCSI. Maybe if you sent SCSI commands to the device it would translate them into the correct ATA commands, depending on what exactly you're doing, but that's entirely dependent on the bridge chip in question and I would guess most of them don't support such fancy operations.

AFAIK most are not really pure bridges, but really microcontrollers running a tiny firmware. So there is a non-zero chance of there being an 'ata passthrough' SCSI command.

I would try to the official ATA_12 and ATA_16 SCSI commands first, to see if they do something useful.

Jeff