A Bushound log confused me. The log is like this.
//block a
{
9 CMD 2a 00 00 00 00 00 00 00 80 00 WRITE 3317238.1.0
9 CMD 2a 00 00 00 00 80 00 00 80 00 WRITE 3317239.1.0
9 CMD 2a 00 00 00 01 00 00 00 80 00 WRITE 3317240.1.0
9 CMD 2a 00 00 00 01 80 00 00 80 00 WRITE 3317241.1.0
. . ~ . . for 32 times
9 OUT 03 00 00 00 03 00 00 00 04 00 00 00 03 00 00 00 05 00 00 00 03 00 00 00 06 00 00 00 03 00 00 00 ................................ 3317238.2.0
07 00 00 00 03 00 00 00 08 00 00 00 03 00 00 00 09 00 00 00 03 00 00 00 0a 00 00 00 03 00 00 00 ................................ 3317238.2.32
0b 00 00 00 03 00 00 00 0c 00 00 00 03 00 00 00 0d 00 00 00 03 00 00 00 0e 00 00 00 03 00 00 00 ................................ 3317238.2.64
0f 00 00 00 03 00 00 00 10 00 00 00 03 00 00 00 11 00 00 00 03 00 00 00 12 00 00 00 03 00 00 00 ................................ 3317238.2.96
. . ~ . . for 1KB data
}
//end of block a
To my knowledge, it's to write data to LBA from 0x0000 to 0x1000 in several SCSI write command, or is it completed by a single SCSI write command?
I can do a SCSI write 64KB to device. Bushound log is like this.
// block b
{
13 CMD 2a 00 00 00 00 00 00 00 80 00 WRITE 394.1.0
13 CMD 00 00 00 00 00 00 TEST UNIT READY 395.1.0
13 OUT 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 .;...;...;...;...;...;...;...;.. 394.2.0
7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 .;...;...;...;...;...;...;...;.. 394.2.32
7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 .;...;...;...;...;...;...;...;.. 394.2.64
7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 7d 3b ef 84 .;...;...;...;...;...;...;...;.. 394.2.96
. . ~ . . for 1KB data
}
//end of block b
If I send SCSI write commands for 32 times, my log will be block b for 32 times.
I am using these code in C# to do SCSI write. If len > 128, it returns 0x57. So It's a 64KB limitation.
private Boolean SendCMD(byte OPCode, ref byte[] buf, long len, long addr, ref int errorCode)
{
bool result = false;
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER sptwb = null;
sptwb = new SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER((UInt32)(len * 512));
sptwb.sptd.Cdb[1] = 0x00;
sptwb.sptd.Cdb[2] = (byte)((addr >> 24) & 0xFF); // MSB of lba
sptwb.sptd.Cdb[3] = (byte)((addr >> 16) & 0xFF);
sptwb.sptd.Cdb[4] = (byte)((addr >> 8) & 0xFF);
sptwb.sptd.Cdb[5] = (byte)((addr) & 0xFF); // LSB of lba
sptwb.sptd.Cdb[6] = 0x00;
sptwb.sptd.Cdb[7] = (byte)((len >> 8) & 0xFF); // MSB of num blocks
sptwb.sptd.Cdb[8] = (byte)((len) & 0xFF); // LSB of num blocks
sptwb.sptd.Cdb[9] = 0x00;
sptwb.sptd.DataIn = SCSI_IOCTL_DATA_OUT;
Marshal.Copy(buf, 0, ptrBuf, (int)(len * 512));
sptwb.sptd.CdbLength = 10;
sptwb.sptd.Cdb[0] = OPCode;
sptwb.sptd.DataBuffer = ptrBuf;
int outByte = 0;
int inputSize = Marshal.SizeOf(typeof(SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER));
IntPtr input = Marshal.AllocHGlobal(inputSize);
Marshal.StructureToPtr(sptwb, input, true);
result = DeviceIoControl(m_hDrive, IOCTL_SCSI_PASS_THROUGH_DIRECT, input, inputSize, input, inputSize, ref outByte, System.IntPtr.Zero);
return result;
}
Is there a way to send SCSI write like the log block a? Thanks and appreciate your help!
Sorry, maybe I should change my question.
Is there a way that I can write a SD card from LBA 0x00000000 to end of LBA be send SCSI command? I can send a single SCSI write10 with data no more than MaximumTransferLength. Although I can send many SCSI write to do SD card full write operation, it is still not a single multi-write operation from the perspective of SD card. How ca I do the large data write (more than MaximumTransferLength)(It's a single multi-write operation in SD card level) by sending SCSI command like the log A does?
User contributions licensed under CC BY-SA 3.0