public static string TestEpromSpecification(Eprom eprom) { var translator = eprom.GetPinTranslator(Top2005PlusZIFType); return(TestPins(translator, eprom.VccPins, Top2005PlusValidVccPins, "Vcc") .Concat(TestPins(translator, eprom.VppPins, Top2005PlusValidVppPins, "Vpp")) .Concat(TestPins(translator, eprom.GndPins, Top2005PlusValidGndPins, "Gnd")) .Concat(TestPins(translator, eprom.Program, Top2005PlusValidSignalPins, "Pgm")) .Concat(TestPins(translator, eprom.OutputEnable, Top2005PlusValidSignalPins, "OE")) .Concat(TestPins(translator, eprom.DataPins, Top2005PlusValidSignalPins, "Data")) .Concat(TestPins(translator, eprom.ChipEnable, Top2005PlusValidSignalPins, "CE")) .Concat(TestPins(translator, eprom.AddressPins, Top2005PlusValidSignalPins, "Address")) .Aggregate("", (a, e) => a + Environment.NewLine + e)); }
/// <summary> /// Writes an EPROM using the Classic Algorithm /// </summary> /// <param name="eprom">The EPROM type.</param> /// <param name="bytes">The bytes to write.</param> /// <param name="patch">Not used yet!</param> public void WriteEpromClassic(Eprom eprom, IList <byte> bytes, IList <int> patch = null) { var totalNumberOfAdresses = eprom.AddressPins.Length == 0 ? 0 : 1 << eprom.AddressPins.Length; var translator = eprom.GetPinTranslator(ZIFType); SetVccLevel(eprom.VccLevel); ApplyGnd(translator.ToZIF, eprom.GndPins); ApplyVcc(translator.ToZIF, eprom.VccPins); var initZif = new ZIFSocket(ZIFType); initZif.SetAll(true); initZif.Disable(eprom.GndPins, translator.ToZIF); initZif.Enable(eprom.Constants, translator.ToZIF); initZif.Disable(eprom.ChipEnable, translator.ToZIF); initZif.Disable(eprom.OutputEnable, translator.ToZIF); initZif.Disable(eprom.Program, translator.ToZIF); WriteZIF(initZif, "Apply 1 to all data and address pins"); SetVppLevel(eprom.VppLevel); ApplyVpp(translator.ToZIF, eprom.VppPins); PullUpsEnable(true); using (var progress = new ProgressBar(Shouter, totalNumberOfAdresses)) { progress.Init(); foreach (var address in Enumerable.Range(0, totalNumberOfAdresses)) { //if(patch != null) //{ // if(!patch.Contains(address)) // continue; // progress.Shout("Now patching address {0}", address); //} var zif = new ZIFSocket(40); // Pull up all pins zif.SetAll(true); zif.Disable(eprom.GndPins, translator.ToZIF); zif.Enable(eprom.Constants, translator.ToZIF); zif.Disable(eprom.Program, translator.ToZIF); zif.Disable(eprom.ChipEnable, translator.ToZIF); zif.Disable(eprom.OutputEnable, translator.ToZIF); // Set address and data eprom.SetAddress(zif, address); var data = eprom.DataPins.Length > 8 ? new[] { bytes[2 * address], bytes[2 * address + 1] } : new[] { bytes[address] }; eprom.SetData(zif, data); // Prepare ZIF without programming in order to let it stabilize // TODO: Do we really need to do this? WriteZIF(zif, "Write address & data to ZIF"); // In order to let the boost converter for manual Vcc // spin up to full output voltage. if (address == 0 && eprom.InitialProgDelay != 0) { BulkDevice.Delay(eprom.InitialProgDelay); } // Enter programming mode zif.Enable(eprom.Program, translator.ToZIF); zif.Enable(eprom.ChipEnable, translator.ToZIF); WriteZIF(zif, "Start pulse E"); // Exit programming mode after at least <pulse> ms zif.Disable(eprom.Program, translator.ToZIF); zif.Disable(eprom.ChipEnable, translator.ToZIF); BulkDevice.Delay(eprom.ProgPulse); WriteZIF(zif, "End pulse E"); progress.Progress(); } } }
/// <summary> /// NOT WORKING YET! /// </summary> /// <param name="eprom"></param> /// <param name="bytes"></param> public void WriteEpromFast(Eprom eprom, IList <byte> bytes) { if (eprom.VppPins.Any(p => eprom.OutputEnable.Any(q => p.Number == q.Number))) { throw new U2PaException("Fast Programming Algoritm can't by used for this EPROM (yet)"); } var totalNumberOfAdresses = eprom.AddressPins.Length == 0 ? 0 : 1 << eprom.AddressPins.Length; var translator = eprom.GetPinTranslator(ZIFType); { var zif = new ZIFSocket(ZIFType); zif.SetAll(true); zif.Disable(eprom.Program, translator.ToZIF); WriteZIF(zif, "Apply 1 to all pins"); SetVccLevel(eprom.VccLevel); SetVppLevel(eprom.VppLevel); ApplyGnd(translator.ToZIF, eprom.GndPins); ApplyVcc(translator.ToZIF, eprom.VccPins); ApplyVpp(translator.ToZIF, eprom.VppPins); } using (var progress = new ProgressBar(Shouter, totalNumberOfAdresses)) { progress.Init(); foreach (var address in Enumerable.Range(0, totalNumberOfAdresses)) { var pulse = 1; while (pulse <= 32) { // Writing var writerZif = new ZIFSocket(40); writerZif.SetAll(true); writerZif.Disable(eprom.GndPins, translator.ToZIF); writerZif.Enable(eprom.Constants, translator.ToZIF); writerZif.Disable(eprom.ChipEnable, translator.ToZIF); writerZif.Disable(eprom.OutputEnable, translator.ToZIF); writerZif.Disable(eprom.Program, translator.ToZIF); eprom.SetAddress(writerZif, address); var data = eprom.DataPins.Length > 8 ? new[] { bytes[2 * address], bytes[2 * address + 1] } : new[] { bytes[address] }; eprom.SetData(writerZif, data); WriteZIF(writerZif, "Write address & d ata to ZIF"); writerZif.Enable(eprom.ChipEnable, translator.ToZIF); writerZif.Enable(eprom.Program, translator.ToZIF); WriteZIF(writerZif, "Start pulse E"); writerZif.Disable(eprom.ChipEnable, translator.ToZIF); writerZif.Disable(eprom.Program, translator.ToZIF); BulkDevice.Delay(pulse); WriteZIF(writerZif, "End pulse E"); // Reading var addressZif = new ZIFSocket(40); addressZif.SetAll(true); addressZif.Disable(eprom.GndPins, translator.ToZIF); addressZif.Enable(eprom.Constants, translator.ToZIF); addressZif.Enable(eprom.ChipEnable, translator.ToZIF); addressZif.Enable(eprom.OutputEnable, translator.ToZIF); addressZif.Disable(eprom.Program, translator.ToZIF); eprom.SetAddress(addressZif, address); WriteZIF(addressZif, "Write address"); var dataZifs = ReadZIF("Read data"); ZIFSocket resultZif; if (Tools.AnalyzeEpromReadSoundness(dataZifs, eprom, address, out resultZif) == ReadSoundness.SeemsToBeAOkay) { if (eprom.GetData(resultZif).SequenceEqual(data)) { // Data validates; now we overprogram writerZif.Enable(eprom.ChipEnable, translator.ToZIF); writerZif.Enable(eprom.Program, translator.ToZIF); WriteZIF(writerZif, "Overprogram"); BulkDevice.Delay(3 * pulse); writerZif.Disable(eprom.ChipEnable, translator.ToZIF); writerZif.Disable(eprom.Program, translator.ToZIF); WriteZIF(writerZif, "End pulse E"); break; } else { Console.WriteLine("Pulse: {0}", pulse); Console.WriteLine("Address: {0}", address.ToString("X4")); Console.WriteLine(eprom.GetData(writerZif).First()); Console.WriteLine(eprom.GetData(resultZif).First()); } } pulse *= 2; } if (pulse > 32) { progress.Shout("Address {0} doesn't validate! }};-(", address.ToString("X4")); } progress.Progress(); } } }
/// <summary> /// Reads an EPROM. /// </summary> /// <param name="eprom">The EPROM type.</param> /// <param name="progressBar">The progress bar.</param> /// <param name="bytes">The list that accumulates the read bytes.</param> /// <param name="fromAddress">Start reading this address.</param> /// <param name="totalNumberOfAdresses">The total number of adesses.</param> /// <returns>The next adress to be read.</returns> public int ReadEprom( Eprom eprom, ProgressBar progressBar, IList <byte> bytes, int fromAddress, int totalNumberOfAdresses) { const int rewriteCount = 5; const int rereadCount = 5; Shouter.ShoutLine(2, "Reading EPROM{0}", eprom.Type); SetVccLevel(eprom.VccLevel); var translator = eprom.GetPinTranslator(ZIFType); ApplyVcc(translator.ToZIF, eprom.VccPins); ApplyGnd(translator.ToZIF, eprom.GndPins); PullUpsEnable(true); var zif = new ZIFSocket(ZIFType); var returnAddress = fromAddress; Shouter.ShoutLine(2, "Now reading bytes..."); progressBar.Init(); foreach (var address in Enumerable.Range(fromAddress, totalNumberOfAdresses - fromAddress)) { zif.SetAll(true); zif.Disable(eprom.GndPins, translator.ToZIF); zif.Enable(eprom.Constants, translator.ToZIF); zif.Enable(eprom.ChipEnable, translator.ToZIF); zif.Enable(eprom.OutputEnable, translator.ToZIF); eprom.SetAddress(zif, returnAddress = address); ZIFSocket resultZIF = null; var result = ReadSoundness.TryRewrite; for (var i = 0; i < rewriteCount; i++) { if (result == ReadSoundness.SeemsToBeAOkay) { break; } if (result == ReadSoundness.TryRewrite) { if (i > 0) { progressBar.Shout("A: {0}; WS: {1}ms", address.ToString("X4"), 100 * i); } WriteZIF(zif, String.Format("A: {0}", address.ToString("X4"))); if (i > 0) { Thread.Sleep(100 * i); } result = ReadSoundness.TryReread; } for (var j = 0; j < rereadCount; j++) { if (result != ReadSoundness.TryReread) { break; } if (j > 0) { progressBar.Shout("A: {0}; WS: {1}ms; RS: {2}ms", address.ToString("X4"), 100 * i, 100 * (j * i)); Thread.Sleep(100 * (j * i)); } var readZifs = ReadZIF(String.Format("for address {0}", address.ToString("X4"))); result = Tools.AnalyzeEpromReadSoundness(readZifs, eprom, address, out resultZIF); if (j == rereadCount - 1) { result = ReadSoundness.TryRewrite; } if (result == ReadSoundness.SeemsToBeAOkay && j > 0) { progressBar.Shout("Address: {0} read }};-P", address.ToString("X4")); } } } if (result != ReadSoundness.SeemsToBeAOkay) { return(returnAddress); } foreach (var b in eprom.GetData(resultZIF)) { bytes.Add(b); } progressBar.Progress(); } return(returnAddress + 1); }