Potato.Fastboot
Potato.Fastboot copied to clipboard
Bug of fastboot? or exactly on device? I tried to flash sparsed images
public bool UploadData(string path)
{
//WRITE_D
FileStream stream = new FileStream(path, FileMode.Open);
string madx = Command("getvar:max-download-size").Payload;
intMAX_DWN_SIZE = (int)new Int32Converter().ConvertFromString(madx);
long totalenremain = stream.Length;
long curlenremain = totalenremain >= MAX_DWN_SIZE ? MAX_DWN_SIZE : totalenremain;
while (totalenremain > 0)
{
if (SendDataCommand(curlenremain))
{
var partname = stream.Name.Split('.')[0].Split('\\').Last();
var writeEp = device.OpenEndpointWriter(WriteEndpointID.Ep01);
LOG(0, "[Fastboot] Sending: ", partname);
while (curlenremain > 0)
{
if (curlenremain < BLOCK_SIZE)
{
TransferBlock(stream, new byte[curlenremain], (int)curlenremain);
totalenremain -= curlenremain;
curlenremain = 0;
}
else
{
TransferBlock(stream, new byte[BLOCK_SIZE], BLOCK_SIZE);
totalenremain -= BLOCK_SIZE;
curlenremain -= BLOCK_SIZE;
}
Progress((int)(stream.Length - totalenremain), (int)stream.Length);
}
stream.Close();
stream.Dispose();
//READ_ED
var resBuffer = new byte[64];
ReadEp.Read(resBuffer, DefaultRWTimeout, out _);
var strBuffer = Encoding.ASCII.GetString(resBuffer);
if (strBuffer.Length < HEADER_SIZE)
throw new Exception("Invalid response from device: " + strBuffer);
if (GetStatus(new string(strBuffer.Take(HEADER_SIZE).ToArray())) != FastbootStatus.Ok)
throw new Exception("Invalid status: " + strBuffer);
else
{
LOG(0, "[Fastboot] Writing: ", partname);
var res = Command("flash:" + partname).Payload;
if (res.Contains("table doesn't exist"))
{
LOG(1, "Skip Partition. ", res);
break;
}
}
}
else
{
stream.Close();
stream.Dispose();
return false;
}
}
return true;
}
this code writes the fastboot image. ALL good, but ramdisk.img wont flash like my device aborting pipe...