Skip to content

Commit fadcac1

Browse files
committedOct 1, 2014
Add chip ID & num LBA retrieval commands
1 parent 6232c23 commit fadcac1

File tree

4 files changed

+83
-8
lines changed

4 files changed

+83
-8
lines changed
 

‎DriveCom/DriveCom/DriveCom.csproj.user

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<StartArguments>/drive=E /burner=C:\Users\Brandon\Documents\GitHub\PS2251-03\BINs\BN03V104M.BIN /firmware=C:\Users\Brandon\Documents\GitHub\PS2251-03\BINs\FW03FF01V10353M.BIN</StartArguments>
55
</PropertyGroup>
66
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
7-
<StartArguments>/drive=E /burner="C:\Users\Brandon\Documents\GitHub\PS2251-03\BINs\BN03V104M.BIN"</StartArguments>
7+
<StartArguments>/drive=E</StartArguments>
88
</PropertyGroup>
99
</Project>

‎DriveCom/DriveCom/PhisonDevice.cs

+26
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ public byte[] RequestVendorInfo()
149149
return ret;
150150
}
151151

152+
public string GetChipID()
153+
{
154+
var response = SendCommand(new byte[] { 0x06, 0x56, 0x00, 0x00, 0x00,
155+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 512);
156+
157+
return BitConverter.ToString(response, 0, 6);
158+
}
159+
160+
public string GetFirmwareVersion()
161+
{
162+
var info = RequestVendorInfo();
163+
164+
return info[0x94] + "." + info[0x95].ToString("X02") + "." + info[0x96].ToString("X02");
165+
}
166+
152167
public ushort? GetChipType()
153168
{
154169
ushort? ret = null;
@@ -197,6 +212,17 @@ public RunMode GetRunMode()
197212
return ret;
198213
}
199214

215+
public ulong GetNumLBAs()
216+
{
217+
var response = SendCommand(new byte[] { 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 8);
218+
ulong ret = response[3];
219+
ret |= (ulong)((ulong)(response[2] << 8) & 0x0000FF00);
220+
ret |= (ulong)((ulong)(response[1] << 16) & 0x00FF0000);
221+
ret |= (ulong)((ulong)(response[0] << 24) & 0xFF000000);
222+
223+
return ret + 1;
224+
}
225+
200226
public void JumpToPRAM()
201227
{
202228
SendCommand(new byte[] { 0x06, 0xB3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });

‎DriveCom/DriveCom/Startup.cs

+20-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public enum Action
2626
DumpFirmware,
2727
SetBootMode,
2828
SendExecutable,
29-
SendFirmware
29+
SendFirmware,
30+
GetNumLBAs
3031
}
3132

3233
public enum ExitCode
@@ -113,6 +114,11 @@ static void Main(string[] args)
113114
_SendFirmware();
114115
break;
115116
}
117+
case Action.GetNumLBAs:
118+
{
119+
_DisplayLBAs();
120+
break;
121+
}
116122
case Action.SetBootMode:
117123
{
118124
_device.JumpToBootMode();
@@ -157,7 +163,7 @@ static void Main(string[] args)
157163
}
158164
case "mode":
159165
{
160-
Console.WriteLine("Mode: " + _GetInfo().ToString());
166+
_GetInfo();
161167
break;
162168
}
163169
case "info":
@@ -166,6 +172,11 @@ static void Main(string[] args)
166172
Console.WriteLine(string.Format("Info: {0}...", BitConverter.ToString(data, 0, 16)));
167173
break;
168174
}
175+
case "get_num_lbas":
176+
{
177+
_DisplayLBAs();
178+
break;
179+
}
169180
case "password":
170181
{
171182
_SendPassword(@params[1]);
@@ -311,6 +322,11 @@ private static void _CloseDrive()
311322
}
312323
}
313324

325+
private static void _DisplayLBAs()
326+
{
327+
Console.WriteLine("Number of LBAs: 0x" + _device.GetNumLBAs().ToString("X08"));
328+
}
329+
314330
private static void _DumpFirmware(string fileName)
315331
{
316332
var address = 0;
@@ -366,6 +382,8 @@ private static PhisonDevice.RunMode _GetInfo()
366382
{
367383
Console.WriteLine("Gathering information...");
368384
Console.WriteLine("Reported chip type: " + _device.GetChipType().GetValueOrDefault().ToString("X04"));
385+
Console.WriteLine("Reported chip ID: " + _device.GetChipID());
386+
Console.WriteLine("Reported firmware version: " + _device.GetFirmwareVersion());
369387

370388
var ret = _device.GetRunMode();
371389
Console.WriteLine("Mode: " + ret.ToString());

‎firmware/scsi.c

+36-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#define VENDOR_BOOT 0xBF
1313
#define VENDOR_INFO 0x05
14+
#define VENDOR_CHIPID 0x56
1415
#define CUSTOM_XPEEK 0x06
1516
#define CUSTOM_XPOKE 0x07
1617
#define CUSTOM_IPEEK 0x08
@@ -113,16 +114,46 @@ BYTE HandleCDB()
113114
SendData1(1, 0);
114115
break;
115116
}
116-
case VENDOR_INFO: //get info
117+
case VENDOR_CHIPID:
117118
{
118119
int i;
119-
120-
memset(usb_buffer, 0x00, 0x210);
121-
for (i = 0; i < 0x200; i++)
120+
memset(usb_buffer, 0x00, 0x200);
121+
122+
//Set raw command mode
123+
XVAL(0xF480) = 0x00;
124+
XVAL(0xF618) = 0xFF;
125+
126+
//Select chip 0
127+
XVAL(0xF608) = 0xFE;
128+
129+
//Reset it
130+
XVAL(0xF400) = 0xFF;
131+
while (!(XVAL(0xF41E) & 0x01));
132+
133+
//Send read chip ID command
134+
XVAL(0xF400) = 0x90;
135+
XVAL(0xF404) = 0x00;
136+
for (i = 0; i < 6; i++)
122137
{
123-
usb_buffer[i] = *((BYTE __xdata *)(0x5000 + i));
138+
usb_buffer[i] = XVAL(0xF408);
124139
}
140+
141+
SendData1(0x200, 0);
142+
scsi_status = 0;
143+
return 1;
144+
}
145+
case VENDOR_INFO: //get info
146+
{
147+
int i;
125148

149+
memset(usb_buffer, 0x00, 0x210);
150+
usb_buffer[0x094] = 0x00;
151+
usb_buffer[0x095] = 0x99;
152+
usb_buffer[0x096] = 0x53;
153+
usb_buffer[0x17A] = 'V';
154+
usb_buffer[0x17B] = 'R';
155+
usb_buffer[0x17E] = 0x23;
156+
usb_buffer[0x17F] = 0x03;
126157
usb_buffer[0x200] = 'I';
127158
usb_buffer[0x201] = 'F';
128159
SendData1(0x210, 0);

0 commit comments

Comments
 (0)