From 4d2f087ff15f0a68162a253af5ae6e964646d83b Mon Sep 17 00:00:00 2001 From: Florian Geib Date: Tue, 26 Jun 2018 21:42:14 +0200 Subject: [PATCH] More firmware modifications added --- .../BackgroundWorkers/ChangeLogoWorker.cs | 197 ------- .../BackgroundWorkers/ModifyFirmwareWorker.cs | 452 +++++++++++++++ RTD266xFlash/RTD266xFlash/Firmware.cs | 35 +- .../RTD266xFlash/FormMain.Designer.cs | 514 ++++++++++++++++-- RTD266xFlash/RTD266xFlash/FormMain.cs | 138 ++++- .../RTD266xFlash/Properties/AssemblyInfo.cs | 5 +- RTD266xFlash/RTD266xFlash/RTD266x.cs | 50 +- RTD266xFlash/RTD266xFlash/RTD266xFlash.csproj | 2 +- 8 files changed, 1125 insertions(+), 268 deletions(-) delete mode 100644 RTD266xFlash/RTD266xFlash/BackgroundWorkers/ChangeLogoWorker.cs create mode 100644 RTD266xFlash/RTD266xFlash/BackgroundWorkers/ModifyFirmwareWorker.cs diff --git a/RTD266xFlash/RTD266xFlash/BackgroundWorkers/ChangeLogoWorker.cs b/RTD266xFlash/RTD266xFlash/BackgroundWorkers/ChangeLogoWorker.cs deleted file mode 100644 index fad144f..0000000 --- a/RTD266xFlash/RTD266xFlash/BackgroundWorkers/ChangeLogoWorker.cs +++ /dev/null @@ -1,197 +0,0 @@ -using System; -using System.ComponentModel; -using System.IO; -using System.Security.Cryptography; -using System.Text; - -namespace RTD266xFlash.BackgroundWorkers -{ - public class ChangeLogoWorker : BaseWorker - { - private readonly string _logoFileName; - - public delegate void ChangeLogoeWorkerFinishedEvent(RTD266x.Result result); - public event ChangeLogoeWorkerFinishedEvent ChangeLogoWorkerFinished; - - private readonly Firmware[] _firmwares = - { - new Firmware("KeDei v1.0", 0x260D8, 0x12346, 1507, new[] - { - new HashInfo(0, 0x80000, "2319EE74B6A09F62484C62B9500FFD356C2A7142BB6D00A5DDFD9E562562F8F4", new [] - { - new HashSkip(0xD263, 1), // CAdjustBackgroundColor 1 - new HashSkip(0xD273, 1), // CAdjustBackgroundColor 2 - new HashSkip(0x12346, 16), // "HDMI" - new HashSkip(0x13A31, 48), // palette - new HashSkip(0x14733, 1), // CShowNote - new HashSkip(0x260D8, 903) // logo - }) - }), - new Firmware("KeDei v1.1, panel type 1 (SKY035S13B00-14439)", 0x260D8, 0x12346, 1507, new[] - { - new HashInfo(0, 0x80000, "B980A13D3472C422FB8E101F6A2BA95DCA0CC2C3D133B8B8B68DF7D5F8FD4AEA", new [] - { - new HashSkip(0xD45E, 1), - new HashSkip(0xD46E, 1), - new HashSkip(0x12346, 16), - new HashSkip(0x13A31, 48), - new HashSkip(0x14733, 1), - new HashSkip(0x260D8, 903) - }) - }), - new Firmware("KeDei v1.1, panel type 2 (SKY035S13D-199)", 0x260D8, 0x12346, 1507, new[] - { - new HashInfo(0, 0x80000, "F206FB3C359FE9BB57BEADA1D79E054DCD7727A898E800C0EDED27F3183BF79B", new [] - { - new HashSkip(0xD2D1, 1), - new HashSkip(0xD2E1, 1), - new HashSkip(0x12346, 16), - new HashSkip(0x13A31, 48), - new HashSkip(0x14733, 1), - new HashSkip(0x260D8, 903) - }) - }) - }; - - public ChangeLogoWorker(RTD266x rtd, string logoFileName) : base(rtd) - { - _logoFileName = logoFileName; - } - - protected override void _backgroundWorker_DoWork(object sender, DoWorkEventArgs e) - { - if (string.IsNullOrEmpty(_logoFileName)) - { - ReportStatus("Error! No logo input file specified.\r\n"); - e.Result = RTD266x.Result.NotOk; - return; - } - - ReportStatus("Checking logo file... "); - - string error; - - if (!FontCoder.CheckFile(_logoFileName, FontCoder.FontWidthKedei, FontCoder.FontHeightKedei, out error)) - { - ReportStatus($"Error! {error}\r\n"); - e.Result = RTD266x.Result.NotOk; - return; - } - - ReportStatus("ok\r\n"); - ReportStatus("Identifying device... "); - - RTD266x.Result result; - RTD266x.StatusInfo status; - - result = _rtd.ReadStatus(out status); - - if (result != RTD266x.Result.Ok || status.ManufacturerId != 0xC8 || status.DeviceId != 0x12) - { - ReportStatus("Error! Cannot identify chip.\r\n"); - e.Result = result; - return; - } - - ReportStatus("ok\r\n"); - ReportStatus("Reading firmware...\r\n"); - - byte[] firmware; - - result = Read(0, 512 * 1024, out firmware, true); - - if (result != RTD266x.Result.Ok) - { - ReportStatus(RTD266x.ResultToString(result) + "\r\n"); - e.Result = result; - return; - } - - string backupFirmwareFileName = "firmware-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".bin"; - - ReportStatus($"Creating firmware backup file \"{backupFirmwareFileName}\"... "); - - try - { - File.WriteAllBytes(backupFirmwareFileName, firmware); - } - catch (Exception ex) - { - ReportStatus($"Error! Could not save file \"{backupFirmwareFileName}\". {ex.Message}\r\n"); - e.Result = result; - return; - } - - ReportStatus("ok\r\n"); - ReportStatus("Checking firmware... "); - - Firmware detectedFirmware = null; - - foreach (Firmware fw in _firmwares) - { - if (fw.CheckHash(firmware)) - { - detectedFirmware = fw; - break; - } - } - - if (detectedFirmware == null) - { - ReportStatus("Error! Could not detect firmware.\r\n"); - e.Result = result; - return; - } - - ReportStatus("ok\r\n"); - ReportStatus($"Detected firmware is {detectedFirmware.Name}\r\n"); - ReportStatus("Converting logo... "); - - FontCoder logo = new FontCoder(FontCoder.FontWidthKedei, FontCoder.FontHeightKedei); - - if (!logo.LoadImage(_logoFileName)) - { - ReportStatus($"Error! Cannot load logo from \"{_logoFileName}\".\r\n"); - e.Result = result; - return; - } - - byte[] logoBytes = logo.Encode(); - - if (logoBytes.Length > detectedFirmware.MaxLogoLength) - { - ReportStatus("Error! Encoded logo is too long and would overwrite other firmware parts.\r\n"); - e.Result = result; - return; - } - - ReportStatus("ok\r\n"); - ReportStatus("Embedding the new logo... "); - - Array.Copy(logoBytes, 0, firmware, detectedFirmware.LogoOffset, logoBytes.Length); - - ReportStatus("ok\r\n"); - ReportStatus("Writing patched sector...\r\n"); - - byte[] sector = new byte[4096]; - int sectorAddress = (detectedFirmware.LogoOffset / 4096) * 4096; - - Array.Copy(firmware, sectorAddress, sector, 0, sector.Length); - - if (Write(sectorAddress, sector, true) != RTD266x.Result.Ok) - { - e.Result = result; - return; - } - - ReportStatus("Finished! Now reboot the display and enjoy your new boot logo :)\r\n"); - - e.Result = RTD266x.Result.Ok; - } - - protected override void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - ChangeLogoWorkerFinished?.Invoke((RTD266x.Result)e.Result); - } - } -} diff --git a/RTD266xFlash/RTD266xFlash/BackgroundWorkers/ModifyFirmwareWorker.cs b/RTD266xFlash/RTD266xFlash/BackgroundWorkers/ModifyFirmwareWorker.cs new file mode 100644 index 0000000..bf8fe5f --- /dev/null +++ b/RTD266xFlash/RTD266xFlash/BackgroundWorkers/ModifyFirmwareWorker.cs @@ -0,0 +1,452 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; + +namespace RTD266xFlash.BackgroundWorkers +{ + public class ModifyFirmwareWorker : BaseWorker + { + private readonly string _logoFileName; + + private readonly Color _logoBackground; + + private readonly Color _logoForeground; + + private readonly Color _displayBackground; + + private readonly bool _removeHdmi; + + private readonly string _replaceHdmi; + + public delegate void ModifyFirmwareWorkerFinishedEvent(RTD266x.Result result); + public event ModifyFirmwareWorkerFinishedEvent ModifyFirmwareWorkerFinished; + + /// + /// Known firmwared + /// + private readonly Firmware[] _firmwares = + { + new Firmware("KeDei v1.0", 0x260D8, 1507, 0x12346, 0xD237, 0x14733, 0x13A31, new[] + { + new HashInfo(0, 0x80000, "B325D2F791EF9122D7E84E2B261CEEA08A2672C94EC851CAC5480D43EA314B25", new [] + { + new HashSkip(0xD254, 48), // CAdjustBackgroundColor + new HashSkip(0x12346, 16), // "HDMI" + new HashSkip(0x13A31, 48), // palette + new HashSkip(0x14733, 1), // CShowNote + new HashSkip(0x260D8, 903) // logo + }) + }), + new Firmware("KeDei v1.1, panel type 1 (SKY035S13B00-14439)", 0x260D8, 1507, 0x12346, 0xD432, 0x14733, 0x13A31, new[] + { + new HashInfo(0, 0x80000, "ADAFD43BE9962E1383CE0223D44E53925C076013C6A88167451DD84F7C47AD42", new [] + { + new HashSkip(0xD44F, 48), + new HashSkip(0x12346, 16), + new HashSkip(0x13A31, 48), + new HashSkip(0x14733, 1), + new HashSkip(0x260D8, 903) + }) + }), + new Firmware("KeDei v1.1, panel type 2 (SKY035S13D-199)", 0x260D8, 1507, 0x12346, 0xD2A5, 0x14733, 0x13A31, new[] + { + new HashInfo(0, 0x80000, "FE61C30E7F78D342426BD175312E57309E3993356ED670155D02A5D4DD7405F9", new [] + { + new HashSkip(0xD2C2, 48), + new HashSkip(0x12346, 16), + new HashSkip(0x13A31, 48), + new HashSkip(0x14733, 1), + new HashSkip(0x260D8, 903) + }) + }) + }; + + /// + /// Character mapping to internal font + /// + private readonly Dictionary _osdCharacters = new Dictionary + { + { ' ', new byte[] { 0x01 }}, + { 'A', new byte[] { 0x10, 0x11 }}, + { 'B', new byte[] { 0x12 }}, + { 'C', new byte[] { 0x13 }}, + { 'D', new byte[] { 0x14 }}, + { 'E', new byte[] { 0x15 }}, + { 'F', new byte[] { 0x16 }}, + { 'G', new byte[] { 0x17, 0x18 }}, + { 'H', new byte[] { 0x19 }}, + { 'I', new byte[] { 0x1A }}, + { 'J', new byte[] { 0x1B }}, + { 'K', new byte[] { 0x1C }}, + { 'L', new byte[] { 0x1D }}, + { 'M', new byte[] { 0x1E, 0x1F }}, + { 'N', new byte[] { 0x20 }}, + { 'O', new byte[] { 0x21, 0x22 }}, + { 'P', new byte[] { 0x23 }}, + { 'Q', new byte[] { 0x24, 0x25 }}, + { 'R', new byte[] { 0x26 }}, + { 'S', new byte[] { 0x27 }}, + { 'T', new byte[] { 0x28 }}, + { 'U', new byte[] { 0x29 }}, + { 'V', new byte[] { 0x2A }}, + { 'W', new byte[] { 0x2B, 0x2C }}, + { 'X', new byte[] { 0x2D }}, + { 'Y', new byte[] { 0x2E }}, + { 'Z', new byte[] { 0x2F }}, + { '0', new byte[] { 0x30 }}, + { '1', new byte[] { 0x31 }}, + { '2', new byte[] { 0x32 }}, + { '3', new byte[] { 0x33 }}, + { '4', new byte[] { 0x34 }}, + { '5', new byte[] { 0x35 }}, + { '6', new byte[] { 0x36 }}, + { '7', new byte[] { 0x37 }}, + { '8', new byte[] { 0x38 }}, + { '9', new byte[] { 0x39 }}, + { 'a', new byte[] { 0x3A }}, + { 'b', new byte[] { 0x3B }}, + { 'c', new byte[] { 0x3C }}, + { 'd', new byte[] { 0x3D }}, + { 'e', new byte[] { 0x3E }}, + { 'f', new byte[] { 0x3F }}, + { 'g', new byte[] { 0x40 }}, + { 'h', new byte[] { 0x41 }}, + { 'i', new byte[] { 0x42 }}, + { 'j', new byte[] { 0x43 }}, + { 'k', new byte[] { 0x44 }}, + { 'l', new byte[] { 0x45 }}, + { 'm', new byte[] { 0x46, 0x47 }}, + { 'n', new byte[] { 0x48 }}, + { 'o', new byte[] { 0x49 }}, + { 'p', new byte[] { 0x4A }}, + { 'q', new byte[] { 0x4B }}, + { 'r', new byte[] { 0x4C }}, + { 's', new byte[] { 0x4D }}, + { 't', new byte[] { 0x4E }}, + { 'u', new byte[] { 0x4F }}, + { 'v', new byte[] { 0x50 }}, + { 'w', new byte[] { 0x51, 0x52 }}, + { 'x', new byte[] { 0x53 }}, + { 'y', new byte[] { 0x54 }}, + { 'z', new byte[] { 0x55 }}, + { ':', new byte[] { 0x5E }}, + { '.', new byte[] { 0x5F }}, + }; + + public ModifyFirmwareWorker(RTD266x rtd, string logoFileName, Color logoBackground, Color logoForeground, Color displayBackground, bool removeHdmi, string replaceHdmi) : base(rtd) + { + _logoFileName = logoFileName; + _logoBackground = logoBackground; + _logoForeground = logoForeground; + _displayBackground = displayBackground; + _removeHdmi = removeHdmi; + _replaceHdmi = replaceHdmi; + } + + protected override void _backgroundWorker_DoWork(object sender, DoWorkEventArgs e) + { + if (!string.IsNullOrEmpty(_logoFileName)) + { + ReportStatus("Checking logo file... "); + + string error; + + if (!FontCoder.CheckFile(_logoFileName, FontCoder.FontWidthKedei, FontCoder.FontHeightKedei, out error)) + { + ReportStatus($"Error! {error}\r\n"); + e.Result = RTD266x.Result.NotOk; + return; + } + + ReportStatus("ok\r\n"); + } + + if (!string.IsNullOrEmpty(_replaceHdmi)) + { + ReportStatus("Checking \"HDMI\" replacement... "); + + if (_replaceHdmi.Length > 8) + { + ReportStatus("Error! String is too long!\r\n"); + e.Result = RTD266x.Result.NotOk; + return; + } + + foreach (char chr in _replaceHdmi) + { + if (!_osdCharacters.ContainsKey(chr)) + { + ReportStatus($"Error! Invalid character \"{chr}\"!\r\n"); + e.Result = RTD266x.Result.NotOk; + return; + } + } + + ReportStatus("ok\r\n"); + } + + ReportStatus("Identifying device... "); + + RTD266x.Result result; + RTD266x.StatusInfo status; + + result = _rtd.ReadStatus(out status); + + if (result != RTD266x.Result.Ok || status.ManufacturerId != 0xC8 || status.DeviceId != 0x12) + { + ReportStatus("Error! Cannot identify chip.\r\n"); + e.Result = result; + return; + } + + ReportStatus("ok\r\n"); + ReportStatus("Reading firmware...\r\n"); + + byte[] firmware; + + result = Read(0, 512 * 1024, out firmware, true); + + if (result != RTD266x.Result.Ok) + { + ReportStatus(RTD266x.ResultToString(result) + "\r\n"); + e.Result = result; + return; + } + + string backupFirmwareFileName = "firmware-" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".bin"; + + ReportStatus($"Creating firmware backup file \"{backupFirmwareFileName}\"... "); + + try + { + File.WriteAllBytes(backupFirmwareFileName, firmware); + } + catch (Exception ex) + { + ReportStatus($"Error! Could not save file \"{backupFirmwareFileName}\". {ex.Message}\r\n"); + e.Result = result; + return; + } + + ReportStatus("ok\r\n"); + ReportStatus("Checking firmware... "); + + Firmware detectedFirmware = null; + + foreach (Firmware fw in _firmwares) + { + if (fw.CheckHash(firmware)) + { + detectedFirmware = fw; + break; + } + } + + if (detectedFirmware == null) + { + ReportStatus("Error! Could not detect firmware.\r\n"); + e.Result = result; + return; + } + + ReportStatus("ok\r\n"); + ReportStatus($"Detected firmware is {detectedFirmware.Name}\r\n"); + + if (!string.IsNullOrEmpty(_logoFileName)) + { + ReportStatus("Converting logo... "); + + FontCoder logo = new FontCoder(FontCoder.FontWidthKedei, FontCoder.FontHeightKedei); + + if (!logo.LoadImage(_logoFileName)) + { + ReportStatus($"Error! Cannot load logo from \"{_logoFileName}\".\r\n"); + e.Result = result; + return; + } + + byte[] logoBytes = logo.Encode(); + + if (logoBytes.Length > detectedFirmware.MaxLogoLength) + { + ReportStatus("Error! Encoded logo is too long and would overwrite other firmware parts.\r\n"); + e.Result = result; + return; + } + + ReportStatus("ok\r\n"); + ReportStatus("Embedding the new logo... "); + + Array.Copy(logoBytes, 0, firmware, detectedFirmware.LogoOffset, logoBytes.Length); + + ReportStatus("ok\r\n"); + + result = WritePatchedSector(firmware, detectedFirmware.LogoOffset); + + if (result != RTD266x.Result.Ok) + { + e.Result = result; + return; + } + } + + if (_logoBackground != Color.Empty) + { + ReportStatus("Patching logo background color... "); + + firmware[detectedFirmware.PaletteOffset + 42] = _logoBackground.R; + firmware[detectedFirmware.PaletteOffset + 43] = _logoBackground.G; + firmware[detectedFirmware.PaletteOffset + 44] = _logoBackground.B; + + ReportStatus("ok\r\n"); + } + + if (_logoForeground != Color.Empty) + { + ReportStatus("Patching logo foreground color... "); + + firmware[detectedFirmware.PaletteOffset + 12] = _logoForeground.R; + firmware[detectedFirmware.PaletteOffset + 13] = _logoForeground.G; + firmware[detectedFirmware.PaletteOffset + 14] = _logoForeground.B; + + ReportStatus("ok\r\n"); + } + + if ((_logoBackground != Color.Empty) || (_logoForeground != Color.Empty)) + { + result = WritePatchedSector(firmware, detectedFirmware.PaletteOffset); + + if (result != RTD266x.Result.Ok) + { + e.Result = result; + return; + } + } + + if (_displayBackground != Color.Empty) + { + ReportStatus("Patching display background color... "); + + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x1D] = 0x7D; // MOV R5 + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x1E] = _displayBackground.R; + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x1F] = 0x00; // NOP + + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x23] = 0x7D; // MOV R5 + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x24] = _displayBackground.G; + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x25] = 0x00; // NOP + + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x29] = 0x7D; // MOV R5 + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x2A] = _displayBackground.B; + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x2B] = 0x00; // NOP + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x2C] = 0x00; // NOP + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x2D] = 0x00; // NOP + + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x3C] = 0x00; // NOP + firmware[detectedFirmware.AdjustBackgroundColorOffset + 0x3D] = 0x00; // NOP + + ReportStatus("ok\r\n"); + + result = WritePatchedSector(firmware, detectedFirmware.AdjustBackgroundColorOffset); + + if (result != RTD266x.Result.Ok) + { + e.Result = result; + return; + } + } + + if (_removeHdmi) + { + ReportStatus("Removing \"HDMI\" pop-up... "); + + firmware[detectedFirmware.ShowNoteOffset] = 0x22; // RET + + ReportStatus("ok\r\n"); + + result = WritePatchedSector(firmware, detectedFirmware.ShowNoteOffset); + + if (result != RTD266x.Result.Ok) + { + e.Result = result; + return; + } + } + else + { + ReportStatus("Enabling \"HDMI\" pop-up... "); + + firmware[detectedFirmware.ShowNoteOffset] = 0xE4; // CLR A + + ReportStatus("ok\r\n"); + + result = WritePatchedSector(firmware, detectedFirmware.ShowNoteOffset); + + if (result != RTD266x.Result.Ok) + { + e.Result = result; + return; + } + } + + if (!string.IsNullOrEmpty(_replaceHdmi)) + { + ReportStatus($"Replacing \"HDMI\" pop-up with \"{_replaceHdmi}\"... "); + + int offset = 0; + + foreach (char chr in _replaceHdmi) + { + byte[] bytes = _osdCharacters[chr]; + + foreach (byte b in bytes) + { + firmware[detectedFirmware.HdmiStringOffset + offset] = b; + offset++; + } + } + + firmware[detectedFirmware.HdmiStringOffset + offset] = 0x00; + + ReportStatus("ok\r\n"); + + result = WritePatchedSector(firmware, detectedFirmware.HdmiStringOffset); + + if (result != RTD266x.Result.Ok) + { + e.Result = result; + return; + } + } + + ReportStatus("Finished! Now reboot the display and enjoy your new firmware :)\r\n"); + + e.Result = RTD266x.Result.Ok; + } + + protected override void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + ModifyFirmwareWorkerFinished?.Invoke((RTD266x.Result)e.Result); + } + + private RTD266x.Result WritePatchedSector(byte[] firmware, int address) + { + int sectorAddress = (address / 4096) * 4096; + byte[] sector = new byte[4096]; + + Array.Copy(firmware, sectorAddress, sector, 0, sector.Length); + + ReportStatus("Writing patched sector...\r\n"); + + RTD266x.Result result = Write(sectorAddress, sector, true); + + if (result != RTD266x.Result.Ok) + { + ReportStatus(RTD266x.ResultToString(result) + "\r\n"); + } + + return result; + } + } +} diff --git a/RTD266xFlash/RTD266xFlash/Firmware.cs b/RTD266xFlash/RTD266xFlash/Firmware.cs index 86f0a42..0b71c25 100644 --- a/RTD266xFlash/RTD266xFlash/Firmware.cs +++ b/RTD266xFlash/RTD266xFlash/Firmware.cs @@ -18,6 +18,14 @@ public int LogoOffset get; } + /// + /// Maximum logo length + /// + public int MaxLogoLength + { + get; + } + /// /// "HDMI" string offset /// @@ -27,9 +35,25 @@ public int HdmiStringOffset } /// - /// Maximum logo length + /// Offset of function AdjustBackgroundColor /// - public int MaxLogoLength + public int AdjustBackgroundColorOffset + { + get; + } + + /// + /// Offset of function ShowNote + /// + public int ShowNoteOffset + { + get; + } + + /// + /// Palette offset + /// + public int PaletteOffset { get; } @@ -42,12 +66,15 @@ public HashInfo[] Hashes get; } - public Firmware(string name, int logoOffset, int hdmiStringOffset, int maxLogoLength, HashInfo[] hashes) + public Firmware(string name, int logoOffset, int maxLogoLength, int hdmiStringOffset, int adjustBackgroundColorOffset, int showNoteOffset, int paletteOffset, HashInfo[] hashes) { Name = name; LogoOffset = logoOffset; - HdmiStringOffset = hdmiStringOffset; MaxLogoLength = maxLogoLength; + HdmiStringOffset = hdmiStringOffset; + AdjustBackgroundColorOffset = adjustBackgroundColorOffset; + ShowNoteOffset = showNoteOffset; + PaletteOffset = paletteOffset; Hashes = hashes; } diff --git a/RTD266xFlash/RTD266xFlash/FormMain.Designer.cs b/RTD266xFlash/RTD266xFlash/FormMain.Designer.cs index c185b04..e8b0ed5 100644 --- a/RTD266xFlash/RTD266xFlash/FormMain.Designer.cs +++ b/RTD266xFlash/RTD266xFlash/FormMain.Designer.cs @@ -72,8 +72,36 @@ private void InitializeComponent() this.groupMode = new System.Windows.Forms.GroupBox(); this.radioModeExpert = new System.Windows.Forms.RadioButton(); this.radioModeSimple = new System.Windows.Forms.RadioButton(); - this.groupLogo = new System.Windows.Forms.GroupBox(); - this.btnChangeLogo = new System.Windows.Forms.Button(); + this.groupModify = new System.Windows.Forms.GroupBox(); + this.picBackgroundColor = new System.Windows.Forms.PictureBox(); + this.picLogoForegroundColor = new System.Windows.Forms.PictureBox(); + this.picLogoBackgroundColor = new System.Windows.Forms.PictureBox(); + this.numericLogoForegroundBlue = new System.Windows.Forms.NumericUpDown(); + this.lblLogoForegroundBlue = new System.Windows.Forms.Label(); + this.numericLogoForegroundGreen = new System.Windows.Forms.NumericUpDown(); + this.lblLogoForegroundGreen = new System.Windows.Forms.Label(); + this.lblLogoForegroundRed = new System.Windows.Forms.Label(); + this.numericLogoForegroundRed = new System.Windows.Forms.NumericUpDown(); + this.chkChangeLogoForegroundColor = new System.Windows.Forms.CheckBox(); + this.txtChangeHdmi = new System.Windows.Forms.TextBox(); + this.chkChangeHdmi = new System.Windows.Forms.CheckBox(); + this.chkRemoveHdmi = new System.Windows.Forms.CheckBox(); + this.numericBackgroundBlue = new System.Windows.Forms.NumericUpDown(); + this.lblBackgroundBlue = new System.Windows.Forms.Label(); + this.numericBackgroundGreen = new System.Windows.Forms.NumericUpDown(); + this.lblBackgroundGreen = new System.Windows.Forms.Label(); + this.lblBackgroundRed = new System.Windows.Forms.Label(); + this.numericBackgroundRed = new System.Windows.Forms.NumericUpDown(); + this.numericLogoBackgroundBlue = new System.Windows.Forms.NumericUpDown(); + this.lblLogoBackgroundBlue = new System.Windows.Forms.Label(); + this.numericLogoBackgroundGreen = new System.Windows.Forms.NumericUpDown(); + this.lblLogoBackgroundGreen = new System.Windows.Forms.Label(); + this.lblLogoBackgroundRed = new System.Windows.Forms.Label(); + this.numericLogoBackgroundRed = new System.Windows.Forms.NumericUpDown(); + this.chkChangeBackgroundColor = new System.Windows.Forms.CheckBox(); + this.chkChangeLogoBackgroundColor = new System.Windows.Forms.CheckBox(); + this.chkChangeLogo = new System.Windows.Forms.CheckBox(); + this.btnModify = new System.Windows.Forms.Button(); this.btnLogoFileNameBrowse = new System.Windows.Forms.Button(); this.txtLogoFileName = new System.Windows.Forms.TextBox(); this.lblLogoFileName = new System.Windows.Forms.Label(); @@ -86,7 +114,19 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.numericWriteStartAddress)).BeginInit(); this.groupMisc.SuspendLayout(); this.groupMode.SuspendLayout(); - this.groupLogo.SuspendLayout(); + this.groupModify.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picBackgroundColor)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picLogoForegroundColor)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.picLogoBackgroundColor)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoForegroundBlue)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoForegroundGreen)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoForegroundRed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericBackgroundBlue)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericBackgroundGreen)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericBackgroundRed)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoBackgroundBlue)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoBackgroundGreen)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoBackgroundRed)).BeginInit(); this.SuspendLayout(); // // groupConnection @@ -181,12 +221,12 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.txtConsole.BackColor = System.Drawing.SystemColors.Window; this.txtConsole.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.txtConsole.Location = new System.Drawing.Point(314, 12); + this.txtConsole.Location = new System.Drawing.Point(616, 12); this.txtConsole.Multiline = true; this.txtConsole.Name = "txtConsole"; this.txtConsole.ReadOnly = true; this.txtConsole.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtConsole.Size = new System.Drawing.Size(458, 595); + this.txtConsole.Size = new System.Drawing.Size(427, 437); this.txtConsole.TabIndex = 2; // // groupRead @@ -206,7 +246,7 @@ private void InitializeComponent() this.groupRead.Controls.Add(this.numericReadStartAddress); this.groupRead.Controls.Add(this.btnReadFileNameBrowse); this.groupRead.Controls.Add(this.txtReadFileName); - this.groupRead.Location = new System.Drawing.Point(12, 350); + this.groupRead.Location = new System.Drawing.Point(12, 272); this.groupRead.Name = "groupRead"; this.groupRead.Size = new System.Drawing.Size(296, 151); this.groupRead.TabIndex = 3; @@ -377,9 +417,9 @@ private void InitializeComponent() this.groupWrite.Controls.Add(this.btnWriteFileNameBrowse); this.groupWrite.Controls.Add(this.lblWriteFileName); this.groupWrite.Controls.Add(this.txtWriteFileName); - this.groupWrite.Location = new System.Drawing.Point(12, 507); + this.groupWrite.Location = new System.Drawing.Point(314, 315); this.groupWrite.Name = "groupWrite"; - this.groupWrite.Size = new System.Drawing.Size(296, 100); + this.groupWrite.Size = new System.Drawing.Size(296, 108); this.groupWrite.TabIndex = 4; this.groupWrite.TabStop = false; this.groupWrite.Text = "Write EEPROM"; @@ -412,7 +452,8 @@ private void InitializeComponent() // // btnWrite // - this.btnWrite.Location = new System.Drawing.Point(6, 71); + this.btnWrite.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnWrite.Location = new System.Drawing.Point(6, 79); this.btnWrite.Name = "btnWrite"; this.btnWrite.Size = new System.Drawing.Size(114, 23); this.btnWrite.TabIndex = 11; @@ -476,7 +517,7 @@ private void InitializeComponent() this.groupMisc.Controls.Add(this.btnEraseChip); this.groupMisc.Controls.Add(this.btnClearLog); this.groupMisc.Controls.Add(this.btnReadStatus); - this.groupMisc.Location = new System.Drawing.Point(12, 236); + this.groupMisc.Location = new System.Drawing.Point(12, 158); this.groupMisc.Name = "groupMisc"; this.groupMisc.Size = new System.Drawing.Size(296, 108); this.groupMisc.TabIndex = 5; @@ -577,32 +618,381 @@ private void InitializeComponent() this.radioModeSimple.Text = "Simple"; this.radioModeSimple.UseVisualStyleBackColor = true; // - // groupLogo - // - this.groupLogo.Controls.Add(this.btnChangeLogo); - this.groupLogo.Controls.Add(this.btnLogoFileNameBrowse); - this.groupLogo.Controls.Add(this.txtLogoFileName); - this.groupLogo.Controls.Add(this.lblLogoFileName); - this.groupLogo.Location = new System.Drawing.Point(12, 158); - this.groupLogo.Name = "groupLogo"; - this.groupLogo.Size = new System.Drawing.Size(296, 72); - this.groupLogo.TabIndex = 7; - this.groupLogo.TabStop = false; - this.groupLogo.Text = "Change logo"; - // - // btnChangeLogo - // - this.btnChangeLogo.Location = new System.Drawing.Point(6, 43); - this.btnChangeLogo.Name = "btnChangeLogo"; - this.btnChangeLogo.Size = new System.Drawing.Size(114, 23); - this.btnChangeLogo.TabIndex = 8; - this.btnChangeLogo.Text = "Change logo"; - this.btnChangeLogo.UseVisualStyleBackColor = true; - this.btnChangeLogo.Click += new System.EventHandler(this.btnChangeLogo_Click); + // groupModify + // + this.groupModify.Controls.Add(this.picBackgroundColor); + this.groupModify.Controls.Add(this.picLogoForegroundColor); + this.groupModify.Controls.Add(this.picLogoBackgroundColor); + this.groupModify.Controls.Add(this.numericLogoForegroundBlue); + this.groupModify.Controls.Add(this.lblLogoForegroundBlue); + this.groupModify.Controls.Add(this.numericLogoForegroundGreen); + this.groupModify.Controls.Add(this.lblLogoForegroundGreen); + this.groupModify.Controls.Add(this.lblLogoForegroundRed); + this.groupModify.Controls.Add(this.numericLogoForegroundRed); + this.groupModify.Controls.Add(this.chkChangeLogoForegroundColor); + this.groupModify.Controls.Add(this.txtChangeHdmi); + this.groupModify.Controls.Add(this.chkChangeHdmi); + this.groupModify.Controls.Add(this.chkRemoveHdmi); + this.groupModify.Controls.Add(this.numericBackgroundBlue); + this.groupModify.Controls.Add(this.lblBackgroundBlue); + this.groupModify.Controls.Add(this.numericBackgroundGreen); + this.groupModify.Controls.Add(this.lblBackgroundGreen); + this.groupModify.Controls.Add(this.lblBackgroundRed); + this.groupModify.Controls.Add(this.numericBackgroundRed); + this.groupModify.Controls.Add(this.numericLogoBackgroundBlue); + this.groupModify.Controls.Add(this.lblLogoBackgroundBlue); + this.groupModify.Controls.Add(this.numericLogoBackgroundGreen); + this.groupModify.Controls.Add(this.lblLogoBackgroundGreen); + this.groupModify.Controls.Add(this.lblLogoBackgroundRed); + this.groupModify.Controls.Add(this.numericLogoBackgroundRed); + this.groupModify.Controls.Add(this.chkChangeBackgroundColor); + this.groupModify.Controls.Add(this.chkChangeLogoBackgroundColor); + this.groupModify.Controls.Add(this.chkChangeLogo); + this.groupModify.Controls.Add(this.btnModify); + this.groupModify.Controls.Add(this.btnLogoFileNameBrowse); + this.groupModify.Controls.Add(this.txtLogoFileName); + this.groupModify.Controls.Add(this.lblLogoFileName); + this.groupModify.Location = new System.Drawing.Point(314, 12); + this.groupModify.Name = "groupModify"; + this.groupModify.Size = new System.Drawing.Size(296, 297); + this.groupModify.TabIndex = 7; + this.groupModify.TabStop = false; + this.groupModify.Text = "Modify firmware"; + // + // picBackgroundColor + // + this.picBackgroundColor.BackColor = System.Drawing.Color.Black; + this.picBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.picBackgroundColor.Location = new System.Drawing.Point(247, 189); + this.picBackgroundColor.Name = "picBackgroundColor"; + this.picBackgroundColor.Size = new System.Drawing.Size(22, 22); + this.picBackgroundColor.TabIndex = 36; + this.picBackgroundColor.TabStop = false; + this.picBackgroundColor.Click += new System.EventHandler(this.picBackgroundColor_Click); + // + // picLogoForegroundColor + // + this.picLogoForegroundColor.BackColor = System.Drawing.Color.White; + this.picLogoForegroundColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.picLogoForegroundColor.Location = new System.Drawing.Point(247, 138); + this.picLogoForegroundColor.Name = "picLogoForegroundColor"; + this.picLogoForegroundColor.Size = new System.Drawing.Size(22, 22); + this.picLogoForegroundColor.TabIndex = 35; + this.picLogoForegroundColor.TabStop = false; + this.picLogoForegroundColor.Click += new System.EventHandler(this.picLogoForegroundColor_Click); + // + // picLogoBackgroundColor + // + this.picLogoBackgroundColor.BackColor = System.Drawing.Color.Black; + this.picLogoBackgroundColor.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.picLogoBackgroundColor.Location = new System.Drawing.Point(247, 87); + this.picLogoBackgroundColor.Name = "picLogoBackgroundColor"; + this.picLogoBackgroundColor.Size = new System.Drawing.Size(22, 22); + this.picLogoBackgroundColor.TabIndex = 34; + this.picLogoBackgroundColor.TabStop = false; + this.picLogoBackgroundColor.Click += new System.EventHandler(this.picLogoBackgroundColor_Click); + // + // numericLogoForegroundBlue + // + this.numericLogoForegroundBlue.Location = new System.Drawing.Point(189, 138); + this.numericLogoForegroundBlue.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoForegroundBlue.Name = "numericLogoForegroundBlue"; + this.numericLogoForegroundBlue.Size = new System.Drawing.Size(52, 22); + this.numericLogoForegroundBlue.TabIndex = 33; + this.numericLogoForegroundBlue.Value = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoForegroundBlue.ValueChanged += new System.EventHandler(this.numericLogoForeground_ValueChanged); + // + // lblLogoForegroundBlue + // + this.lblLogoForegroundBlue.AutoSize = true; + this.lblLogoForegroundBlue.Location = new System.Drawing.Point(166, 140); + this.lblLogoForegroundBlue.Name = "lblLogoForegroundBlue"; + this.lblLogoForegroundBlue.Size = new System.Drawing.Size(17, 13); + this.lblLogoForegroundBlue.TabIndex = 32; + this.lblLogoForegroundBlue.Text = "B:"; + // + // numericLogoForegroundGreen + // + this.numericLogoForegroundGreen.Location = new System.Drawing.Point(108, 138); + this.numericLogoForegroundGreen.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoForegroundGreen.Name = "numericLogoForegroundGreen"; + this.numericLogoForegroundGreen.Size = new System.Drawing.Size(52, 22); + this.numericLogoForegroundGreen.TabIndex = 31; + this.numericLogoForegroundGreen.Value = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoForegroundGreen.ValueChanged += new System.EventHandler(this.numericLogoForeground_ValueChanged); + // + // lblLogoForegroundGreen + // + this.lblLogoForegroundGreen.AutoSize = true; + this.lblLogoForegroundGreen.Location = new System.Drawing.Point(84, 140); + this.lblLogoForegroundGreen.Name = "lblLogoForegroundGreen"; + this.lblLogoForegroundGreen.Size = new System.Drawing.Size(18, 13); + this.lblLogoForegroundGreen.TabIndex = 30; + this.lblLogoForegroundGreen.Text = "G:"; + // + // lblLogoForegroundRed + // + this.lblLogoForegroundRed.AutoSize = true; + this.lblLogoForegroundRed.Location = new System.Drawing.Point(3, 140); + this.lblLogoForegroundRed.Name = "lblLogoForegroundRed"; + this.lblLogoForegroundRed.Size = new System.Drawing.Size(17, 13); + this.lblLogoForegroundRed.TabIndex = 29; + this.lblLogoForegroundRed.Text = "R:"; + // + // numericLogoForegroundRed + // + this.numericLogoForegroundRed.Location = new System.Drawing.Point(26, 138); + this.numericLogoForegroundRed.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoForegroundRed.Name = "numericLogoForegroundRed"; + this.numericLogoForegroundRed.Size = new System.Drawing.Size(52, 22); + this.numericLogoForegroundRed.TabIndex = 28; + this.numericLogoForegroundRed.Value = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoForegroundRed.ValueChanged += new System.EventHandler(this.numericLogoForeground_ValueChanged); + // + // chkChangeLogoForegroundColor + // + this.chkChangeLogoForegroundColor.AutoSize = true; + this.chkChangeLogoForegroundColor.Location = new System.Drawing.Point(6, 115); + this.chkChangeLogoForegroundColor.Name = "chkChangeLogoForegroundColor"; + this.chkChangeLogoForegroundColor.Size = new System.Drawing.Size(185, 17); + this.chkChangeLogoForegroundColor.TabIndex = 27; + this.chkChangeLogoForegroundColor.Text = "Change logo foreground color"; + this.chkChangeLogoForegroundColor.UseVisualStyleBackColor = true; + this.chkChangeLogoForegroundColor.CheckedChanged += new System.EventHandler(this.chkModifyFirmware_CheckedChanged); + // + // txtChangeHdmi + // + this.txtChangeHdmi.Location = new System.Drawing.Point(177, 238); + this.txtChangeHdmi.Name = "txtChangeHdmi"; + this.txtChangeHdmi.Size = new System.Drawing.Size(113, 22); + this.txtChangeHdmi.TabIndex = 26; + this.txtChangeHdmi.Text = "HDMI"; + // + // chkChangeHdmi + // + this.chkChangeHdmi.AutoSize = true; + this.chkChangeHdmi.Location = new System.Drawing.Point(6, 240); + this.chkChangeHdmi.Name = "chkChangeHdmi"; + this.chkChangeHdmi.Size = new System.Drawing.Size(165, 17); + this.chkChangeHdmi.TabIndex = 25; + this.chkChangeHdmi.Text = "Change \"HDMI\" pop-up to:"; + this.chkChangeHdmi.UseVisualStyleBackColor = true; + this.chkChangeHdmi.CheckedChanged += new System.EventHandler(this.chkModifyFirmware_CheckedChanged); + // + // chkRemoveHdmi + // + this.chkRemoveHdmi.AutoSize = true; + this.chkRemoveHdmi.Location = new System.Drawing.Point(6, 217); + this.chkRemoveHdmi.Name = "chkRemoveHdmi"; + this.chkRemoveHdmi.Size = new System.Drawing.Size(148, 17); + this.chkRemoveHdmi.TabIndex = 24; + this.chkRemoveHdmi.Text = "Remove \"HDMI\" pop-up"; + this.chkRemoveHdmi.UseVisualStyleBackColor = true; + this.chkRemoveHdmi.CheckedChanged += new System.EventHandler(this.chkModifyFirmware_CheckedChanged); + // + // numericBackgroundBlue + // + this.numericBackgroundBlue.Location = new System.Drawing.Point(189, 189); + this.numericBackgroundBlue.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericBackgroundBlue.Name = "numericBackgroundBlue"; + this.numericBackgroundBlue.Size = new System.Drawing.Size(52, 22); + this.numericBackgroundBlue.TabIndex = 23; + this.numericBackgroundBlue.ValueChanged += new System.EventHandler(this.numericBackground_ValueChanged); + // + // lblBackgroundBlue + // + this.lblBackgroundBlue.AutoSize = true; + this.lblBackgroundBlue.Location = new System.Drawing.Point(166, 191); + this.lblBackgroundBlue.Name = "lblBackgroundBlue"; + this.lblBackgroundBlue.Size = new System.Drawing.Size(17, 13); + this.lblBackgroundBlue.TabIndex = 22; + this.lblBackgroundBlue.Text = "B:"; + // + // numericBackgroundGreen + // + this.numericBackgroundGreen.Location = new System.Drawing.Point(108, 189); + this.numericBackgroundGreen.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericBackgroundGreen.Name = "numericBackgroundGreen"; + this.numericBackgroundGreen.Size = new System.Drawing.Size(52, 22); + this.numericBackgroundGreen.TabIndex = 21; + this.numericBackgroundGreen.ValueChanged += new System.EventHandler(this.numericBackground_ValueChanged); + // + // lblBackgroundGreen + // + this.lblBackgroundGreen.AutoSize = true; + this.lblBackgroundGreen.Location = new System.Drawing.Point(84, 191); + this.lblBackgroundGreen.Name = "lblBackgroundGreen"; + this.lblBackgroundGreen.Size = new System.Drawing.Size(18, 13); + this.lblBackgroundGreen.TabIndex = 20; + this.lblBackgroundGreen.Text = "G:"; + // + // lblBackgroundRed + // + this.lblBackgroundRed.AutoSize = true; + this.lblBackgroundRed.Location = new System.Drawing.Point(3, 191); + this.lblBackgroundRed.Name = "lblBackgroundRed"; + this.lblBackgroundRed.Size = new System.Drawing.Size(17, 13); + this.lblBackgroundRed.TabIndex = 19; + this.lblBackgroundRed.Text = "R:"; + // + // numericBackgroundRed + // + this.numericBackgroundRed.Location = new System.Drawing.Point(26, 189); + this.numericBackgroundRed.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericBackgroundRed.Name = "numericBackgroundRed"; + this.numericBackgroundRed.Size = new System.Drawing.Size(52, 22); + this.numericBackgroundRed.TabIndex = 18; + this.numericBackgroundRed.ValueChanged += new System.EventHandler(this.numericBackground_ValueChanged); + // + // numericLogoBackgroundBlue + // + this.numericLogoBackgroundBlue.Location = new System.Drawing.Point(189, 87); + this.numericLogoBackgroundBlue.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoBackgroundBlue.Name = "numericLogoBackgroundBlue"; + this.numericLogoBackgroundBlue.Size = new System.Drawing.Size(52, 22); + this.numericLogoBackgroundBlue.TabIndex = 17; + this.numericLogoBackgroundBlue.ValueChanged += new System.EventHandler(this.numericLogoBackground_ValueChanged); + // + // lblLogoBackgroundBlue + // + this.lblLogoBackgroundBlue.AutoSize = true; + this.lblLogoBackgroundBlue.Location = new System.Drawing.Point(166, 89); + this.lblLogoBackgroundBlue.Name = "lblLogoBackgroundBlue"; + this.lblLogoBackgroundBlue.Size = new System.Drawing.Size(17, 13); + this.lblLogoBackgroundBlue.TabIndex = 16; + this.lblLogoBackgroundBlue.Text = "B:"; + // + // numericLogoBackgroundGreen + // + this.numericLogoBackgroundGreen.Location = new System.Drawing.Point(108, 87); + this.numericLogoBackgroundGreen.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoBackgroundGreen.Name = "numericLogoBackgroundGreen"; + this.numericLogoBackgroundGreen.Size = new System.Drawing.Size(52, 22); + this.numericLogoBackgroundGreen.TabIndex = 15; + this.numericLogoBackgroundGreen.ValueChanged += new System.EventHandler(this.numericLogoBackground_ValueChanged); + // + // lblLogoBackgroundGreen + // + this.lblLogoBackgroundGreen.AutoSize = true; + this.lblLogoBackgroundGreen.Location = new System.Drawing.Point(84, 89); + this.lblLogoBackgroundGreen.Name = "lblLogoBackgroundGreen"; + this.lblLogoBackgroundGreen.Size = new System.Drawing.Size(18, 13); + this.lblLogoBackgroundGreen.TabIndex = 14; + this.lblLogoBackgroundGreen.Text = "G:"; + // + // lblLogoBackgroundRed + // + this.lblLogoBackgroundRed.AutoSize = true; + this.lblLogoBackgroundRed.Location = new System.Drawing.Point(3, 89); + this.lblLogoBackgroundRed.Name = "lblLogoBackgroundRed"; + this.lblLogoBackgroundRed.Size = new System.Drawing.Size(17, 13); + this.lblLogoBackgroundRed.TabIndex = 13; + this.lblLogoBackgroundRed.Text = "R:"; + // + // numericLogoBackgroundRed + // + this.numericLogoBackgroundRed.Location = new System.Drawing.Point(26, 87); + this.numericLogoBackgroundRed.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numericLogoBackgroundRed.Name = "numericLogoBackgroundRed"; + this.numericLogoBackgroundRed.Size = new System.Drawing.Size(52, 22); + this.numericLogoBackgroundRed.TabIndex = 12; + this.numericLogoBackgroundRed.ValueChanged += new System.EventHandler(this.numericLogoBackground_ValueChanged); + // + // chkChangeBackgroundColor + // + this.chkChangeBackgroundColor.AutoSize = true; + this.chkChangeBackgroundColor.Location = new System.Drawing.Point(6, 166); + this.chkChangeBackgroundColor.Name = "chkChangeBackgroundColor"; + this.chkChangeBackgroundColor.Size = new System.Drawing.Size(200, 17); + this.chkChangeBackgroundColor.TabIndex = 11; + this.chkChangeBackgroundColor.Text = "Change display background color"; + this.chkChangeBackgroundColor.UseVisualStyleBackColor = true; + this.chkChangeBackgroundColor.CheckedChanged += new System.EventHandler(this.chkModifyFirmware_CheckedChanged); + // + // chkChangeLogoBackgroundColor + // + this.chkChangeLogoBackgroundColor.AutoSize = true; + this.chkChangeLogoBackgroundColor.Location = new System.Drawing.Point(6, 64); + this.chkChangeLogoBackgroundColor.Name = "chkChangeLogoBackgroundColor"; + this.chkChangeLogoBackgroundColor.Size = new System.Drawing.Size(188, 17); + this.chkChangeLogoBackgroundColor.TabIndex = 10; + this.chkChangeLogoBackgroundColor.Text = "Change logo background color"; + this.chkChangeLogoBackgroundColor.UseVisualStyleBackColor = true; + this.chkChangeLogoBackgroundColor.CheckedChanged += new System.EventHandler(this.chkModifyFirmware_CheckedChanged); + // + // chkChangeLogo + // + this.chkChangeLogo.AutoSize = true; + this.chkChangeLogo.Location = new System.Drawing.Point(6, 19); + this.chkChangeLogo.Name = "chkChangeLogo"; + this.chkChangeLogo.Size = new System.Drawing.Size(93, 17); + this.chkChangeLogo.TabIndex = 9; + this.chkChangeLogo.Text = "Change logo"; + this.chkChangeLogo.UseVisualStyleBackColor = true; + this.chkChangeLogo.CheckedChanged += new System.EventHandler(this.chkModifyFirmware_CheckedChanged); + // + // btnModify + // + this.btnModify.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnModify.Location = new System.Drawing.Point(6, 268); + this.btnModify.Name = "btnModify"; + this.btnModify.Size = new System.Drawing.Size(114, 23); + this.btnModify.TabIndex = 8; + this.btnModify.Text = "Modify firmware"; + this.btnModify.UseVisualStyleBackColor = true; + this.btnModify.Click += new System.EventHandler(this.btnModify_Click); // // btnLogoFileNameBrowse // - this.btnLogoFileNameBrowse.Location = new System.Drawing.Point(259, 15); + this.btnLogoFileNameBrowse.Location = new System.Drawing.Point(259, 36); this.btnLogoFileNameBrowse.Name = "btnLogoFileNameBrowse"; this.btnLogoFileNameBrowse.Size = new System.Drawing.Size(31, 22); this.btnLogoFileNameBrowse.TabIndex = 4; @@ -612,7 +1002,7 @@ private void InitializeComponent() // // txtLogoFileName // - this.txtLogoFileName.Location = new System.Drawing.Point(95, 15); + this.txtLogoFileName.Location = new System.Drawing.Point(95, 36); this.txtLogoFileName.Name = "txtLogoFileName"; this.txtLogoFileName.Size = new System.Drawing.Size(158, 22); this.txtLogoFileName.TabIndex = 3; @@ -620,7 +1010,7 @@ private void InitializeComponent() // lblLogoFileName // this.lblLogoFileName.AutoSize = true; - this.lblLogoFileName.Location = new System.Drawing.Point(3, 18); + this.lblLogoFileName.Location = new System.Drawing.Point(3, 39); this.lblLogoFileName.Name = "lblLogoFileName"; this.lblLogoFileName.Size = new System.Drawing.Size(86, 13); this.lblLogoFileName.TabIndex = 2; @@ -630,8 +1020,8 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(784, 619); - this.Controls.Add(this.groupLogo); + this.ClientSize = new System.Drawing.Size(1055, 461); + this.Controls.Add(this.groupModify); this.Controls.Add(this.groupMode); this.Controls.Add(this.groupMisc); this.Controls.Add(this.groupWrite); @@ -639,7 +1029,7 @@ private void InitializeComponent() this.Controls.Add(this.txtConsole); this.Controls.Add(this.groupConnection); this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.MinimumSize = new System.Drawing.Size(800, 658); + this.MinimumSize = new System.Drawing.Size(800, 500); this.Name = "FormMain"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "RTD266x EEPROM Flasher"; @@ -657,8 +1047,20 @@ private void InitializeComponent() this.groupMisc.ResumeLayout(false); this.groupMode.ResumeLayout(false); this.groupMode.PerformLayout(); - this.groupLogo.ResumeLayout(false); - this.groupLogo.PerformLayout(); + this.groupModify.ResumeLayout(false); + this.groupModify.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.picBackgroundColor)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picLogoForegroundColor)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.picLogoBackgroundColor)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoForegroundBlue)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoForegroundGreen)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoForegroundRed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericBackgroundBlue)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericBackgroundGreen)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericBackgroundRed)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoBackgroundBlue)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoBackgroundGreen)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericLogoBackgroundRed)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -707,14 +1109,42 @@ private void InitializeComponent() private System.Windows.Forms.Label lblReadStartAddressDec; private System.Windows.Forms.Label lblWriteStartAddressHex; private System.Windows.Forms.Label lblWriteStartAddressDec; - private System.Windows.Forms.GroupBox groupLogo; + private System.Windows.Forms.GroupBox groupModify; private System.Windows.Forms.Label lblLogoFileName; - private System.Windows.Forms.Button btnChangeLogo; + private System.Windows.Forms.Button btnModify; private System.Windows.Forms.Button btnLogoFileNameBrowse; private System.Windows.Forms.TextBox txtLogoFileName; private System.Windows.Forms.CheckBox chkReadConsole; private System.Windows.Forms.CheckBox chkReadFile; private System.Windows.Forms.Button btnAbout; + private System.Windows.Forms.CheckBox chkChangeLogo; + private System.Windows.Forms.CheckBox chkChangeBackgroundColor; + private System.Windows.Forms.CheckBox chkChangeLogoBackgroundColor; + private System.Windows.Forms.NumericUpDown numericLogoBackgroundBlue; + private System.Windows.Forms.Label lblLogoBackgroundBlue; + private System.Windows.Forms.NumericUpDown numericLogoBackgroundGreen; + private System.Windows.Forms.Label lblLogoBackgroundGreen; + private System.Windows.Forms.Label lblLogoBackgroundRed; + private System.Windows.Forms.NumericUpDown numericLogoBackgroundRed; + private System.Windows.Forms.NumericUpDown numericBackgroundBlue; + private System.Windows.Forms.Label lblBackgroundBlue; + private System.Windows.Forms.NumericUpDown numericBackgroundGreen; + private System.Windows.Forms.Label lblBackgroundGreen; + private System.Windows.Forms.Label lblBackgroundRed; + private System.Windows.Forms.NumericUpDown numericBackgroundRed; + private System.Windows.Forms.TextBox txtChangeHdmi; + private System.Windows.Forms.CheckBox chkChangeHdmi; + private System.Windows.Forms.CheckBox chkRemoveHdmi; + private System.Windows.Forms.NumericUpDown numericLogoForegroundBlue; + private System.Windows.Forms.Label lblLogoForegroundBlue; + private System.Windows.Forms.NumericUpDown numericLogoForegroundGreen; + private System.Windows.Forms.Label lblLogoForegroundGreen; + private System.Windows.Forms.Label lblLogoForegroundRed; + private System.Windows.Forms.NumericUpDown numericLogoForegroundRed; + private System.Windows.Forms.CheckBox chkChangeLogoForegroundColor; + private System.Windows.Forms.PictureBox picLogoBackgroundColor; + private System.Windows.Forms.PictureBox picBackgroundColor; + private System.Windows.Forms.PictureBox picLogoForegroundColor; } } diff --git a/RTD266xFlash/RTD266xFlash/FormMain.cs b/RTD266xFlash/RTD266xFlash/FormMain.cs index ad2adc2..5335b7c 100644 --- a/RTD266xFlash/RTD266xFlash/FormMain.cs +++ b/RTD266xFlash/RTD266xFlash/FormMain.cs @@ -1,5 +1,6 @@ using RTD266xFlash.BackgroundWorkers; using System; +using System.Drawing; using System.IO; using System.IO.Ports; using System.Text; @@ -43,7 +44,54 @@ private void UpdateConnected(bool connected) btnReadStatus.Enabled = connected; btnEraseChip.Enabled = connected; btnClearLock.Enabled = connected; - btnChangeLogo.Enabled = connected; + btnModify.Enabled = connected; + } + + private void UpdateModifyFirmware() + { + _guiUpdate = true; + + txtLogoFileName.Enabled = chkChangeLogo.Checked; + btnLogoFileNameBrowse.Enabled = chkChangeLogo.Checked; + + numericLogoBackgroundRed.Enabled = chkChangeLogoBackgroundColor.Checked; + numericLogoBackgroundGreen.Enabled = chkChangeLogoBackgroundColor.Checked; + numericLogoBackgroundBlue.Enabled = chkChangeLogoBackgroundColor.Checked; + picLogoBackgroundColor.Enabled = chkChangeLogoBackgroundColor.Checked; + + numericLogoForegroundRed.Enabled = chkChangeLogoForegroundColor.Checked; + numericLogoForegroundGreen.Enabled = chkChangeLogoForegroundColor.Checked; + numericLogoForegroundBlue.Enabled = chkChangeLogoForegroundColor.Checked; + picLogoForegroundColor.Enabled = chkChangeLogoForegroundColor.Checked; + + numericBackgroundRed.Enabled = chkChangeBackgroundColor.Checked; + numericBackgroundGreen.Enabled = chkChangeBackgroundColor.Checked; + numericBackgroundBlue.Enabled = chkChangeBackgroundColor.Checked; + picBackgroundColor.Enabled = chkChangeBackgroundColor.Checked; + + if (chkRemoveHdmi.Checked) + { + chkChangeHdmi.Checked = false; + chkChangeHdmi.Enabled = false; + } + else + { + chkChangeHdmi.Enabled = true; + } + + if (chkChangeHdmi.Checked) + { + chkRemoveHdmi.Checked = false; + chkRemoveHdmi.Enabled = false; + } + else + { + chkRemoveHdmi.Enabled = true; + } + + txtChangeHdmi.Enabled = chkChangeHdmi.Checked; + + _guiUpdate = false; } private void UpdateBackgroundWorkerActive(bool active) @@ -52,7 +100,7 @@ private void UpdateBackgroundWorkerActive(bool active) groupMode.Enabled = !active; groupConnection.Enabled = !active; - groupLogo.Enabled = !active; + groupModify.Enabled = !active; groupMisc.Enabled = !active; groupRead.Enabled = !active; groupWrite.Enabled = !active; @@ -103,6 +151,25 @@ private void ShowErrorMessageBox(string errorMessage) MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } + private void FillColorBox(PictureBox pictureBox, int red, int green, int blue) + { + pictureBox.BackColor = Color.FromArgb(red, green, blue); + } + + private void ShowColorDialog(NumericUpDown numericRed, NumericUpDown numericGreen, NumericUpDown numericBlue) + { + ColorDialog colorDialog = new ColorDialog(); + + colorDialog.Color = Color.FromArgb((int)numericRed.Value, (int)numericGreen.Value, (int)numericBlue.Value); + + if (colorDialog.ShowDialog() == DialogResult.OK) + { + numericRed.Value = colorDialog.Color.R; + numericGreen.Value = colorDialog.Color.G; + numericBlue.Value = colorDialog.Color.B; + } + } + #region Background workers private void ReadWorkerFinished(RTD266x.Result result, byte[] data) @@ -157,7 +224,7 @@ private void WriteWorkerFinished(RTD266x.Result result) UpdateBackgroundWorkerActive(false); } - private void ChangeLogoWorkerFinished(RTD266x.Result result) + private void ModifyFirmwareWorkerFinished(RTD266x.Result result) { UpdateBackgroundWorkerActive(false); } @@ -186,6 +253,7 @@ private void FormMain_Load(object sender, EventArgs e) UpdateConnected(false); UpdateMode(); + UpdateModifyFirmware(); AppendConsoleText("Configure the connection and click \"Connect\"\r\n"); } @@ -319,11 +387,11 @@ private void btnReadStatus_Click(object sender, EventArgs e) AppendConsoleText("done\r\n"); - AppendConsoleText($"Manufacturer ID: 0x{statusInfo.ManufacturerId:X2}\r\n"); - AppendConsoleText($"Device ID: 0x{statusInfo.DeviceId:X2}\r\n"); - AppendConsoleText($"JEDEC Manufacturer ID: 0x{statusInfo.JedecManufacturerId:X2}\r\n"); + AppendConsoleText($"Manufacturer ID: 0x{statusInfo.ManufacturerId:X2} ({statusInfo.Manufacturer})\r\n"); + AppendConsoleText($"Device ID: 0x{statusInfo.DeviceId:X2} ({statusInfo.Type})\r\n"); + AppendConsoleText($"JEDEC Manufacturer ID: 0x{statusInfo.JedecManufacturerId:X2} ({statusInfo.Manufacturer})\r\n"); AppendConsoleText($"JEDEC Memory Type: 0x{statusInfo.JedecMemoryType:X2}\r\n"); - AppendConsoleText($"JEDEC Capacity: 0x{statusInfo.JedecCapacity:X2}\r\n"); + AppendConsoleText($"JEDEC Capacity: 0x{statusInfo.JedecCapacity:X2} ({statusInfo.Capacity})\r\n"); AppendConsoleText($"Status: 0x{statusInfo.Status:X4}\r\n"); } @@ -483,18 +551,64 @@ private void btnLogoFileNameBrowse_Click(object sender, EventArgs e) } } - private void btnChangeLogo_Click(object sender, EventArgs e) + private void btnModify_Click(object sender, EventArgs e) { - string logoFileName = txtLogoFileName.Text; - UpdateBackgroundWorkerActive(true); - ChangeLogoWorker changeLogoWorker = new ChangeLogoWorker(_rtd, logoFileName); + ModifyFirmwareWorker changeLogoWorker = new ModifyFirmwareWorker( + _rtd, + chkChangeLogo.Checked ? txtLogoFileName.Text : null, + chkChangeLogoBackgroundColor.Checked ? Color.FromArgb((int)numericLogoBackgroundRed.Value, (int)numericLogoBackgroundGreen.Value, (int)numericLogoBackgroundBlue.Value) : Color.Empty, + chkChangeLogoForegroundColor.Checked ? Color.FromArgb((int)numericLogoForegroundRed.Value, (int)numericLogoForegroundGreen.Value, (int)numericLogoForegroundBlue.Value) : Color.Empty, + chkChangeBackgroundColor.Checked ? Color.FromArgb((int)numericBackgroundRed.Value, (int)numericBackgroundGreen.Value, (int)numericBackgroundBlue.Value) : Color.Empty, + chkRemoveHdmi.Checked, + chkChangeHdmi.Checked ? txtChangeHdmi.Text : null); + changeLogoWorker.WorkerReportStatus += AppendConsoleText; - changeLogoWorker.ChangeLogoWorkerFinished += ChangeLogoWorkerFinished; + changeLogoWorker.ModifyFirmwareWorkerFinished += ModifyFirmwareWorkerFinished; changeLogoWorker.Start(); } + private void chkModifyFirmware_CheckedChanged(object sender, EventArgs e) + { + if (_guiUpdate) + { + return; + } + + UpdateModifyFirmware(); + } + + private void numericLogoBackground_ValueChanged(object sender, EventArgs e) + { + FillColorBox(picLogoBackgroundColor, (int)numericLogoBackgroundRed.Value, (int)numericLogoBackgroundGreen.Value, (int)numericLogoBackgroundBlue.Value); + } + + private void numericLogoForeground_ValueChanged(object sender, EventArgs e) + { + FillColorBox(picLogoForegroundColor, (int)numericLogoForegroundRed.Value, (int)numericLogoForegroundGreen.Value, (int)numericLogoForegroundBlue.Value); + } + + private void numericBackground_ValueChanged(object sender, EventArgs e) + { + FillColorBox(picBackgroundColor, (int)numericBackgroundRed.Value, (int)numericBackgroundGreen.Value, (int)numericBackgroundBlue.Value); + } + + private void picLogoBackgroundColor_Click(object sender, EventArgs e) + { + ShowColorDialog(numericLogoBackgroundRed, numericLogoBackgroundGreen, numericLogoBackgroundBlue); + } + + private void picLogoForegroundColor_Click(object sender, EventArgs e) + { + ShowColorDialog(numericLogoForegroundRed, numericLogoForegroundGreen, numericLogoForegroundBlue); + } + + private void picBackgroundColor_Click(object sender, EventArgs e) + { + ShowColorDialog(numericBackgroundRed, numericBackgroundGreen, numericBackgroundBlue); + } + #endregion } } diff --git a/RTD266xFlash/RTD266xFlash/Properties/AssemblyInfo.cs b/RTD266xFlash/RTD266xFlash/Properties/AssemblyInfo.cs index 84764f9..a036e18 100644 --- a/RTD266xFlash/RTD266xFlash/Properties/AssemblyInfo.cs +++ b/RTD266xFlash/RTD266xFlash/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // Allgemeine Informationen über eine Assembly werden über die folgenden @@ -32,5 +31,5 @@ // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/RTD266xFlash/RTD266xFlash/RTD266x.cs b/RTD266xFlash/RTD266xFlash/RTD266x.cs index b04d72a..52dd565 100644 --- a/RTD266xFlash/RTD266xFlash/RTD266x.cs +++ b/RTD266xFlash/RTD266xFlash/RTD266x.cs @@ -52,6 +52,9 @@ public class StatusInfo public int JedecMemoryType; public int JedecCapacity; public int Status; + public string Manufacturer; + public string Capacity; + public string Type; } private readonly SerialPort _comPort; @@ -61,32 +64,32 @@ public RTD266x(SerialPort comPort) _comPort = comPort; } - public static string ResultToString(RTD266x.Result result) + public static string ResultToString(Result result) { switch (result) { - case RTD266x.Result.Ok: + case Result.Ok: return "ok"; - case RTD266x.Result.NotOk: + case Result.NotOk: return "not ok"; - case RTD266x.Result.NotConnected: + case Result.NotConnected: return "not connected"; - case RTD266x.Result.CrcError: + case Result.CrcError: return "CRC error"; - case RTD266x.Result.SerialReadError: + case Result.SerialReadError: return "serial read error"; - case RTD266x.Result.Timeout: + case Result.Timeout: return "timeout"; - case RTD266x.Result.UnexpectedCommand: + case Result.UnexpectedCommand: return "unexpected command"; - case RTD266x.Result.InvalidParameters: + case Result.InvalidParameters: return "invalid parameters"; } @@ -218,6 +221,35 @@ public Result ReadStatus(out StatusInfo status) status.JedecCapacity = response[6]; status.Status = (response[7] << 8) | response[8]; + switch (status.ManufacturerId) + { + case 0xC8: + status.Manufacturer = "Bright Moon Semiconductor Co., Ltd"; + break; + + default: + status.Manufacturer = "Unknown"; + break; + } + + if ((status.ManufacturerId == 0xC8) && (status.JedecCapacity == 0x13)) + { + status.Capacity = "512 KB"; + } + else + { + status.Capacity = "Unknown"; + } + + if ((status.ManufacturerId == 0xC8) && (status.DeviceId == 0x12)) + { + status.Type = "T25S40"; + } + else + { + status.Type = "Unknown"; + } + return Result.Ok; } diff --git a/RTD266xFlash/RTD266xFlash/RTD266xFlash.csproj b/RTD266xFlash/RTD266xFlash/RTD266xFlash.csproj index b8ca009..b8a9561 100644 --- a/RTD266xFlash/RTD266xFlash/RTD266xFlash.csproj +++ b/RTD266xFlash/RTD266xFlash/RTD266xFlash.csproj @@ -43,7 +43,7 @@ - +