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-01-16 13:24:26 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-01-16 13:24:26 +0300
commit2e07a79d4ddd78bc0ac06bf87c9e86979cce414b (patch)
tree0bef97808cf9c020e33e655ae6d6e2bddc4407a6 /FelLib
parent10de3c40654d71a58095ff900567a8e592e2a738 (diff)
Code cleanup
Diffstat (limited to 'FelLib')
-rw-r--r--FelLib/Fel.cs53
1 files changed, 37 insertions, 16 deletions
diff --git a/FelLib/Fel.cs b/FelLib/Fel.cs
index 549e71b8..ba618d6d 100644
--- a/FelLib/Fel.cs
+++ b/FelLib/Fel.cs
@@ -11,7 +11,7 @@ namespace com.clusterrr.FelLib
public class Fel
{
public byte[] Fes1Bin;
- public byte[] UBootBin;
+ byte[] uBootBin;
public enum CurrentAction { RunningCommand, ReadingMemory, WritingMemory }
public delegate void OnFelProgress(CurrentAction action, string command);
@@ -25,20 +25,40 @@ namespace com.clusterrr.FelLib
UInt16 vid, pid;
bool DramInitDone = false;
- const UInt32 cmdOffset = 0x604FF;
- const UInt32 fes1_base_m = 0x2000;
- const UInt32 dram_base = 0x40000000;
- const UInt32 flash_mem_base = 0x43800000;
- const UInt32 flash_mem_size = 0x20;
- const UInt32 uboot_base_m = 0x47000000u;
- const UInt32 sector_size = 0x20000;
- const UInt32 uboot_base_f = 0x100000;
- const UInt32 kernel_base_f = (sector_size * 0x30);
- const UInt32 kernel_base_m = flash_mem_base;
- const UInt32 kernel_max_size = (uboot_base_m - flash_mem_base);
- const UInt32 kernel_max_flash_size = (sector_size * 0x20);
+ int cmdOffset = -1;
+ public const UInt32 fes1_base_m = 0x2000;
+ public const UInt32 dram_base = 0x40000000;
+ public const UInt32 flash_mem_base = 0x43800000;
+ public const UInt32 flash_mem_size = 0x20;
+ public const UInt32 uboot_base_m = 0x47000000u;
+ public const UInt32 sector_size = 0x20000;
+ public const UInt32 uboot_base_f = 0x100000;
+ public const UInt32 kernel_base_f = (sector_size * 0x30);
+ public const UInt32 kernel_base_m = flash_mem_base;
+ public const UInt32 kernel_max_size = (uboot_base_m - flash_mem_base);
+ public const UInt32 kernel_max_flash_size = (sector_size * 0x20);
const string fastboot = "fastboot_test";
+ public byte[] UBootBin
+ {
+ get
+ {
+ return uBootBin;
+ }
+
+ set
+ {
+ uBootBin = value;
+ var prefix = "bootcmd=";
+ for (int i = 0; i < uBootBin.Length - prefix.Length; i++)
+ if (Encoding.ASCII.GetString(uBootBin, i, prefix.Length) == prefix)
+ {
+ cmdOffset = i + prefix.Length;
+ break;
+ }
+ }
+ }
+
public static bool DeviceExists(UInt16 vid, UInt16 pid)
{
var fel = new Fel();
@@ -82,14 +102,14 @@ namespace com.clusterrr.FelLib
{
inEndp = pipe.Address;
#if DEBUG
- DebugLog("IN endpoint found: "+ inEndp);
+ DebugLog("IN endpoint found: " + inEndp);
#endif
}
else
{
outEndp = pipe.Address;
#if DEBUG
- DebugLog("Out endpoint found: "+outEndp);
+ DebugLog("Out endpoint found: " + outEndp);
#endif
}
}
@@ -329,7 +349,8 @@ namespace com.clusterrr.FelLib
public void RunUbootCmd(string command, bool noreturn = false, OnFelProgress callback = null)
{
- if (callback != null) callback(CurrentAction.RunningCommand, command);
+ callback?.Invoke(CurrentAction.RunningCommand, command);
+ if (cmdOffset < 0) throw new Exception("Invalid Unoot binary, command variable not found");
const UInt32 testSize = 0x20;
if (UBootBin == null || UBootBin.Length < testSize)
throw new FelException("Can't init Uboot, incorrect Uboot binary");