Sample code to do scsi pass through to USB flash drive

338 views
Skip to first unread message

David Lethe

unread,
Apr 5, 2013, 5:07:53 PM4/5/13
to ata-sc...@lists.apple.com
Is there a simple project out there that lets me send (vendor-specific) SCSI CDBs to a mounted USB flash drive? I've not found any sample apps.

David




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Ata-scsi-dev mailing list (Ata-sc...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/ata-scsi-dev/ata-scsi-dev-garchive-72467%40googlegroups.com

This email sent to ata-scsi-dev-...@googlegroups.com

Gary Little

unread,
Apr 7, 2013, 11:28:19 AM4/7/13
to ata-sc...@lists.apple.com
Have you looked at USBPrivateDataSample? That will show you the basics that are needed as far as finding your device and opening lower interfaces. What are you wanting to do with the SCSI CDBs?

Gary Little
ggli...@comcast.net
C 952-454-4629
H 952-223-1349
Tain't what you want that makes you fat, it's what you get.



On Apr 5, 2013, at 4:07 PM, David Lethe <da...@santools.com> wrote:

> Is there a simple project out there that lets me send (vendor-specific) SCSI CDBs to a mounted USB flash drive? I've not found any sample apps.
>
> David
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Ata-scsi-dev mailing list (Ata-sc...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/ata-scsi-dev/gglittle%40comcast.net
>
> This email sent to ggli...@comcast.net

Joel Reymont

unread,
Apr 7, 2013, 11:44:31 AM4/7/13
to Gary Little, ata-sc...@lists.apple.com
I have a post on this at http://wagerlabs.com and sample code at http://github.com/wagerlabs

--- Sent from my BlackBerry Z10

David Lethe

unread,
Apr 12, 2013, 7:32:49 PM4/12/13
to ata-sc...@lists.apple.com
I've got a USB flash device with custom firmware on it. It is used as a standard flash memory device that somebody plugs in, mounts, and uses to run software that may or may not already be running. One of the programs on the device sends pass-through commands that are vendor/product specific to the firmware. I have to keep this mounted, must not lock it in exclusive access mode, and not interfere with whatever other programs are running that may interact with the stick's file system.

The commands I will do will include READ(10) & WRITE(10), along with some CDBs that are formerly defined as vendor-specific per the ANSI spec. (10 & 16-byte opcodes that might start with C0, 02, EE among others).

The USBPrivateDataSample isn't even close. I doubt it would even compile, and it doesn't have anything in there for sending mass storage type commands. Basically, looking for a "hello world" type of sample app that works on a mounted USB target device that uses a pass-through CDB to do something simple.

For what it is worth, I do not have to make this work with just any usb flash device, so if there is some constraint that requires me to limit it to a specific pair of 16-bit usbVendor/usbProduct combinations, then that is OK).

Q. So is there pass-through function somewhere that allows an app to send ANSI-standard block CDBs to a mounted USB flashmemory device, and a sample app?
Q. Would that technique require a kext or anything else? Remember, exclusive access for the program is unacceptable for my needs, I want to be able to have a program that has read/write access to the filesystem on the USB to invoke this pass-through code and interct with the filesystem.

David
W 972-618-2265

=======
Have you looked at USBPrivateDataSample? That will show you the basics that are needed as far as finding your device and opening lower interfaces. What are you wanting to do with the SCSI CDBs?

Gary Little
email@hidden
C 952-454-4629
H 952-223-1349
Tain't what you want that makes you fat, it's what you get.



On Apr 5, 2013, at 4:07 PM, David Lethe <email@hidden> wrote:

> Is there a simple project out there that lets me send (vendor-specific) SCSI CDBs to a mounted USB flash drive? I've not found any sample apps.
>
> David
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Ata-scsi-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

Giorgio

unread,
Apr 15, 2013, 6:01:11 PM4/15/13
to ata-sc...@lists.apple.com
It would be great if anyone could implement the ability to send SCSI
passthrough commands on MacOS X in libcdio:

http://www.gnu.org/software/libcdio/

The mmc_run_cmd() function is there right for that purpose, but I
think it doesn't do anything on MacOS X.

If someone did this, we would immediately gain SCSI passthrough in an
immediate and portable way.

G.

2013/4/5 David Lethe <da...@santools.com>:
> Is there a simple project out there that lets me send (vendor-specific) SCSI CDBs to a mounted USB flash drive? I've not found any sample apps.
>
> David
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Ata-scsi-dev mailing list (Ata-sc...@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/ata-scsi-dev/sukko.ml%40sukkology.net
>
> This email sent to sukk...@sukkology.net

Chris Sarcone

unread,
Apr 15, 2013, 6:53:19 PM4/15/13
to David Lethe, ata-sc...@lists.apple.com
On Apr 12, 2013, at 4:32 PM, David Lethe <da...@santools.com> wrote:

I've got a USB flash device with custom firmware on it.  It is used as a standard flash memory device that somebody plugs in, mounts, and uses to run software that may or may not already be running. One of the programs on the device sends pass-through commands that are vendor/product specific to the firmware.  I have to keep this mounted, must not lock it in exclusive access mode, and not interfere with whatever other programs are running that may interact with the stick's file system.

The commands I will do will include READ(10) & WRITE(10), along with some CDBs that are formerly defined as vendor-specific per the ANSI spec.  (10 & 16-byte opcodes that might start with C0, 02, EE among others).

The USBPrivateDataSample isn't even close.  I doubt it would even compile, and it doesn't have anything in there for sending mass storage type commands. Basically, looking for a "hello world" type of sample app that works on a mounted USB target device that uses a pass-through CDB to do something simple.  

For what it is worth, I do not have to make this work with just any usb flash device, so if there is some constraint that requires me to limit it to a specific pair of 16-bit usbVendor/usbProduct combinations, then that is OK).

Q. So is there pass-through function somewhere that allows an app to send ANSI-standard block CDBs to a mounted USB flashmemory device, and a sample app?

No.

Please see Technical Q&A QA1179 "Sending SCSI or ATA commands to storage devices"


Q. Would that technique require a kext or anything else?  Remember, exclusive access for the program is unacceptable for my needs, I want to be able to have a program that has read/write access to the filesystem on the USB to invoke this pass-through code and interct with the filesystem.

Yes, a kext is required.

Thanks,

-- Chris

------------------

6 Infinite Loop

M/S 306-2MS

Cupertino CA 95014

phone: (408) 974-4033

fax:   (408) 862-7577

email: sar...@apple.com


Chris Sarcone

unread,
Apr 15, 2013, 6:55:06 PM4/15/13
to Giorgio, ata-sc...@lists.apple.com
Giorgio --

It would be great if anyone could implement the ability to send SCSI
passthrough commands on MacOS X in libcdio:

http://www.gnu.org/software/libcdio/

The mmc_run_cmd() function is there right for that purpose, but I
think it doesn't do anything on MacOS X.

If someone did this, we would immediately gain SCSI passthrough in an
immediate and portable way.

There is a user-space API that you can use to access CD/DVD/BD burners already and it allows you to get exclusive access to the device. There is sample code and header doc available (see SCSITaskLib.h)

Thanks,

-- Chris

Reply all
Reply to author
Forward
0 new messages