diff --git a/.gitignore b/.gitignore index ed8cea9..0c59ef6 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,368 @@ fp-info-cache # Exported BOM files *.xml *.csv + + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index eb7fd53..54db57a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,4 +1,14 @@ { "version": "2.0.0", - "tasks": [] + "tasks": [ + { + "type": "PlatformIO", + "task": "Build", + "problemMatcher": [ + "$platformio" + ], + "group": "build", + "label": "PlatformIO: Build" + } + ] } \ No newline at end of file diff --git a/schematic/epromemu.kicad_pro b/schematic/epromemu.kicad_pro index 9b8fdd6..5268d1a 100644 --- a/schematic/epromemu.kicad_pro +++ b/schematic/epromemu.kicad_pro @@ -418,7 +418,7 @@ "workbook_filename": "" }, "page_layout_descr_file": "", - "plot_directory": "", + "plot_directory": "./", "spice_adjust_passive_values": false, "spice_external_command": "spice \"%I\"", "subpart_first_id": 65, diff --git a/src/SendEPROM/Program.cs b/src/SendEPROM/Program.cs new file mode 100644 index 0000000..7ffea4c --- /dev/null +++ b/src/SendEPROM/Program.cs @@ -0,0 +1,65 @@ +using System; +using System.IO; +using System.IO.Ports; +using System.CommandLine; +using System.Threading.Tasks; + +namespace SendEPROM +{ + public class Program + { + public static async Task Main(string[] args) + { + var portOption = new Option(new string[] {"--port", "-p" }, description: "COM port on which to send the file", getDefaultValue: () => "COM3"); + var baudOption = new Option (new string[] {"--baud", "-b" }, description: "Baud rate at which to send", getDefaultValue: () => 115200); + var modeOption = new Option (new string[] {"--mode", "-m" }, description: "EPROM mode (1 = 27C256, 2 = 27C020)", getDefaultValue: () => 2); + var skipOption = new Option (new string[] {"--skip", "-s" }, description: "Skip N bytes at start of file", getDefaultValue: () => 0); + + var fileArgument = new Argument("file", description: "File to send"); + + var rootCmd = new RootCommand("Send a binary image to the EPROM emulator") + { + portOption, + baudOption, + modeOption, + skipOption, + fileArgument + }; + + rootCmd.SetHandler( + (port, baud, mode, skip, file) => + { + SendData(port, baud, mode, skip, file); + }, + portOption, baudOption, modeOption, skipOption, fileArgument); + + return await rootCmd.InvokeAsync(args); + } + + static void SendData(string port, int baud, byte mode, int skip, FileInfo file) + { + + Console.WriteLine($"Reading {file.FullName}"); + byte[] buff = File.ReadAllBytes(file.FullName); + + Console.WriteLine($"Opening {port} at {baud}"); + var sp = new SerialPort(port) + { + BaudRate = baud + }; + sp.Open(); + + if(mode != 0) + { + Console.WriteLine($"Sending mode {mode}"); + byte[] modeBuff = { mode }; + sp.Write(modeBuff, 0, 1); + } + + Console.WriteLine($"Sending {buff.Length} bytes, skipping {skip} bytes"); + sp.Write(buff, skip, buff.Length - skip); + sp.Close(); + Console.WriteLine("Done!"); + } + } +} \ No newline at end of file diff --git a/src/SendEPROM/SendEPROM.csproj b/src/SendEPROM/SendEPROM.csproj new file mode 100644 index 0000000..63c3675 --- /dev/null +++ b/src/SendEPROM/SendEPROM.csproj @@ -0,0 +1,15 @@ + + + + Exe + net7.0 + disable + + + + + + + + + diff --git a/src/SendEPROM/SendEPROM.sln b/src/SendEPROM/SendEPROM.sln new file mode 100644 index 0000000..1513a9e --- /dev/null +++ b/src/SendEPROM/SendEPROM.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32014.148 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SendEPROM", "SendEPROM.csproj", "{1B795DA1-604C-44C9-8306-BE3E84743BA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B795DA1-604C-44C9-8306-BE3E84743BA2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C5F74E1C-5293-43CD-9F71-72BC2BEB69B5} + EndGlobalSection +EndGlobal diff --git a/src/main.cpp b/src/teensy/main.cpp similarity index 72% rename from src/main.cpp rename to src/teensy/main.cpp index db25f40..fb8087d 100644 --- a/src/main.cpp +++ b/src/teensy/main.cpp @@ -2,24 +2,33 @@ #include #include -// forced to a 2mbit eprom // FLASHMEM // DMAMEM // PROGMEM +enum eMode : unsigned char +{ + m27C256 = 1, + m27C020 = 2, +}; + #define ROM_BUFFER_LEN (256*1024) char buffer[ROM_BUFFER_LEN]; const char *filename = "rom.bin"; +eMode mode = m27C020; +Stream* stream; int32_t inPins[] = { 19,18,14,15,40,41,17,16,22,23,20,21,38,39,26,27,24,25,-1 }; int32_t outPins[] = { 10,12,11,13,8,7,36,37,-1 }; -void readFile(int port) +void readData(Stream* s) { const int length = 1024; char buff[length]; - memset(buffer, 0, ROM_BUFFER_LEN); + mode = (eMode)s->read(); + + memset(buffer, 0xFF, ROM_BUFFER_LEN); size_t read = 0; size_t total = 0; @@ -29,15 +38,7 @@ void readFile(int port) { memset(buff, 0, length); - switch(port) - { - case 0: - read = Serial.readBytes(buff, length); - break; - case 1: - read = Serial1.readBytes(buff, length); - break; - } + read = s->readBytes(buff, length); total += read; if(read > 0) @@ -48,10 +49,6 @@ void readFile(int port) } while(read != 0); - // on GG (and lynx?) top address bit gets stuck high (?) so mirror to upper region too? - if(total == 131072) - memcpy(p, buffer, 131072); - SD.remove(filename); File f = SD.open(filename, O_WRITE); @@ -90,7 +87,21 @@ void loop() uint32_t outb = 0; // read address pins - uint32_t addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4); + uint32_t addr = 0; + + switch(mode) + { + // 256Kbit, 32KB, 0x0000-0x7FFF + case m27C256: + addr = ((io6 >> 16) & 0x7FFF); + break; + + // 2Mbit, 256KB, 0x00000-0x3FFFF + case m27C020: + default: + addr = ((io6 >> 16) & 0xFFFF) | ((io6 & 0x3000) << 4); + break; + } // get byte at addr char b = buffer[addr]; @@ -101,8 +112,8 @@ void loop() // read file from either serial port, if available if(Serial.available()) - readFile(0); + readData(&Serial); if(Serial1.available()) - readFile(1); + readData(&Serial1); }