Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/FelLib
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-09-28 00:10:24 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-09-28 00:10:24 +0300
commit0a82a5ec4240ac836c4186f517c8b49013ae889c (patch)
tree496cdff1252cc06f8d651926138a6b3a01529454 /FelLib
parentfe8cd0fc4e716b1bef4aff1fc4ff7b6b5180474b (diff)
NAND write feature (not working yet, it WILL BRICK YOUR CONSOLE, so it's hidden), some fixes
Diffstat (limited to 'FelLib')
-rw-r--r--FelLib/Fel.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/FelLib/Fel.cs b/FelLib/Fel.cs
index 1aeff89c..ca44c35a 100644
--- a/FelLib/Fel.cs
+++ b/FelLib/Fel.cs
@@ -269,7 +269,7 @@ namespace com.clusterrr.FelLib
int pos = 0;
while (pos < buffer.Length)
{
- if (callback != null) callback(CurrentAction.WritingMemory, null);
+ callback?.Invoke(CurrentAction.WritingMemory, null);
var buf = new byte[Math.Min(buffer.Length - pos, MaxBulkSize)];
Array.Copy(buffer, pos, buf, 0, buf.Length);
FelRequest(AWFELStandardRequest.RequestType.FEL_DOWNLOAD, (UInt32)(address + pos), (uint)buf.Length);
@@ -334,7 +334,7 @@ namespace com.clusterrr.FelLib
while (length > 0)
{
var reqLen = Math.Min(length, transfer_max_size);
- command = string.Format("sunxi_flash phy_read {0:x} {1:x} {2:x};{3}", transfer_base_m, address / sector_size, reqLen / sector_size, fastboot);
+ command = string.Format("sunxi_flash phy_read {0:x} {1:x} {2:x};{3}", transfer_base_m, address / sector_size, (int)Math.Floor((double)reqLen / (double)sector_size), fastboot);
RunUbootCmd(command, false, callback);
var buf = ReadMemory(transfer_base_m + address % sector_size, reqLen, callback);
result.AddRange(buf);
@@ -347,19 +347,20 @@ namespace com.clusterrr.FelLib
public void WriteFlash(UInt32 address, byte[] buffer, OnFelProgress callback = null)
{
var length = (uint)buffer.Length;
- int pos = 0;
+ uint pos = 0;
if ((address % sector_size) != 0)
throw new FelException(string.Format("Invalid flash address : 0x{0:X8}", address));
if ((length % sector_size) != 0)
throw new FelException(string.Format("Invalid flash length: 0x{0:X8}", length));
while (length > 0)
{
- var wrLength = Math.Min(length, transfer_max_size);
+ var wrLength = Math.Min(length, transfer_max_size / 8);
var newBuf = new byte[wrLength];
Array.Copy(buffer, pos, newBuf, 0, wrLength);
WriteMemory(transfer_base_m, newBuf, callback);
- var command = string.Format("sunxi_flash phy_write {0:x} {1:x} {2:x};{3}", transfer_base_m, address / sector_size, length / sector_size, fastboot);
+ var command = string.Format("sunxi_flash phy_write {0:x} {1:x} {2:x};{3}", transfer_base_m, address / sector_size, (int)Math.Floor((double)wrLength / (double)sector_size), fastboot);
RunUbootCmd(command, false, callback);
+ pos += (uint)wrLength;
address += (uint)wrLength;
length -= (uint)wrLength;
}