Kris-Sekula / EPROM-EMU-NG

EPROM Emulator Project with Arduino
https://mygeekyhobby.com/2020/07/05/eprom-emulator/
Apache License 2.0
133 stars 32 forks source link

Emulating an AT27C256 #8

Closed InPermutation closed 3 years ago

InPermutation commented 3 years ago

Please consider this a draft note-to-self, since I don't have time tonight to write a pull request.

The pinout between an AT27C256 and a 28256 differs in that the EEPROM's A14 is on pin 1, with /WE on pin 27, while the 28256 EPROM has Vdd on pin 1 and A14 on pin 27.

So, since in the EPROM-EMU-NG, pin 1 is A15, and A14 will be held high ("write enable" not asserted), we can write a little Python script to convert a 32K binary file into a 64K file padded with junk in addresses 0000:3FFF and 8000:c000:

#!/usr/bin/env python3

import sys

if __name__ == "__main__":
    with open(sys.argv[1], "rb") as infile:
        data = infile.read()
        assert len(data) == 0x8000, f"len must be {0x8000}; was {len(data)}"
    with open(sys.argv[2], "wb") as outfile:
        outfile.write(b'\xff' * 0x4000) # junk
        outfile.write(data[0:0x4000])
        outfile.write(b'\xff' * 0x4000)  # junk
        outfile.write(data[0x4000:0x8000])

then write it out like usual:

% python3 EPROM_NG_v2.0rc3.py -mem 27512 -spi y -auto y ./a512.out /dev/tty.usbserial-1410 -start 0 -map y

I used a TL866 II+ with minipro to confirm that this reads correctly as a 27C256:

% minipro -p AT28C256 -r a.test

And, I attached it in place of the EEPROM of my Ben Eater 6502, and it boots up correctly!

InPermutation commented 3 years ago

Data writes at about 1.6 kbps, so we can speed this up by not even writing the junk bytes. First optimization: use the -start 4000 parameter, and remove the first # junk line.

Second optimization: write two separate files, write at -start 4000 and -start c000. (todo: check math)

InPermutation commented 3 years ago

The downside to the second optimization is that RST/ goes high for a fraction of a second between the two runs, which could cause undesired operation of the target computer.

Kris-Sekula commented 3 years ago

Hey Jacob, great job investigating. I sent you an email, try that if you get a chance and let me know if your BE6502 boots... if it does I'll publish the files for others to try.

Kris-Sekula commented 3 years ago

The newly released (experimental) version of firmware and software now has EEPROM support included: Firmware 2.0rc8 (EPROM_EMU_NG_FW_2.0rc8.ino - Arduino sketch in Firmware folder) Software 2.0rc8 (EPROM_EMU_NG_2.0rc8.py - Python script in Software folder)

InPermutation commented 3 years ago

The new firmware works great, thanks @Kris-Sekula!