public static TaskFunc FlashUboot(ConfigIni.UbootType type) { return((Tasker tasker, Object syncObject) => { tasker.SetStatus(Resources.FlashingUboot); TrackableStream uboot; if (type == ConfigIni.UbootType.Normal) { uboot = new TrackableStream(Resources.uboot); } else { uboot = new TrackableStream(Resources.ubootSD); } if (uboot.Length > 655360) { throw new Exception(Resources.InvalidUbootSize + " " + uboot.Length); } uboot.OnProgress += tasker.OnProgress; hakchi.Shell.Execute("cat > /uboot.bin", uboot, null, null, 0, true); MemoryStream flashLog = new MemoryStream(); var splitStream = new SplitterStream(flashLog).AddStreams(Program.debugStreams); if (hakchi.Shell.Execute("hakchi flashBoot1 /uboot.bin", null, splitStream) != 0) { using (var sr = new StreamReader(flashLog)) { throw new Exception(sr.ReadToEnd()); } } return Conclusion.Success; }); }
public static TaskFunc FlashUboot(ConfigIni.UbootType type) { return((Tasker tasker, Object syncObject) => { tasker.SetStatus(Resources.FlashingUboot); MemoryStream flashLog = new MemoryStream(); var splitStream = new SplitterStream(flashLog).AddStreams(Program.debugStreams); if (hakchi.Shell.Execute($"sntool sd {(type == ConfigIni.UbootType.SD ? "enable" : "disable")}", null, splitStream, splitStream) != 0) { flashLog.Seek(0, SeekOrigin.Begin); using (var sr = new StreamReader(flashLog)) { throw new Exception(sr.ReadToEnd()); } } return Conclusion.Success; }); }