28C256 EEPROM Writer
This is a simple homemade EEPROM writer that any one can make.
To make a writer It requires the following
Breadboard w/jumpers
2 - MCP23S17 16-bit SPI I/O Expander
Raspberry PI
*note the project is 100% directed towards the 28c256 EEPROM's. but you should be able to adapt the concept to other sizes of EEPROM's
Schematics
Python code
32k.zip To run go to the command terminal in the folder with the files and type python3 32k.py
Includes
32k.py
SPI32k.py
unlock_code.asm (this is for unlocking 28c256 on my 8088 motherboard see attached video)
32k.py
#pyinstaller --onefile --hidden-import tkinter new.py
from tkinter import *
from tkinter import filedialog
from tkinter import messagebox
import os
from os import system
import SPI32k
def donothing():
print("Hello World")
def new_file():
text_field.delete(1.0,END)
main_window.title("32K 28C256 Writer")
main_window.file_and_path = ''
def open_file():
file_name = filedialog.askopenfilename(initialdir = "/home/pi",title = "Open",filetypes = (("Assembly","*.asm"),("all files","*.*")))
if file_name:
file_open = open(file_name)
file_data = file_open.read()
file_open.close()
text_field.delete(1.0,END)
text_field.insert(END, file_data)
main_window.file_and_path = file_name
main_window.title("32K 28C256 Writer " + main_window.file_and_path)
def save_file():
if(main_window.file_and_path == ''):
file_save = filedialog.asksaveasfile(mode='w', initialdir = "/home/pi",title = "Save",filetypes = (("Assembly","*.asm"),("all files","*.*")))
if file_save:
file_save.write(text_field.get(1.0,END))
main_window.file_and_path = file_save.name
main_window.title("32K 28C256 Writer " + main_window.file_and_path)
file_save.close()
else:
file_save = open(main_window.file_and_path, 'w')
file_save.write(text_field.get(1.0,END))
file_save.close()
def save_as_file():
file_save = filedialog.asksaveasfile(mode='w', initialdir = "/home/pi",title = "Save As",filetypes = (("Assembly","*.asm"),("all files","*.*")))
if file_save:
file_save.write(text_field.get(1.0,END))
main_window.file_and_path = file_save.name
main_window.title("32K 28C256 Writer " + main_window.file_and_path)
file_save.close()
def Compile_and_Upload():
if(main_window.file_and_path == ''):
messagebox.showinfo("Compiler Error", "File not open or saved!")
else:
file_save = open(main_window.file_and_path, 'w')
file_save.write(text_field.get(1.0,END))
file_save.close()
main_window.file_and_path_bin = main_window.file_and_path[:-4] + '.bin'
os.system("nasm " + main_window.file_and_path + ' -o ' + main_window.file_and_path_bin)
if os.path.exists(main_window.file_and_path[:-4] + '.bin'):
file_open = open(main_window.file_and_path[:-4] + '.bin', mode='rb')
file_data = file_open.read()
file_open.close()
Jump_code = [0XEA, 0X00, 0X00, 0X00, 0XF8]
SPI32k.Write_Memory_Array(0xFFF0, Jump_code)
print("JUMP CODE DONE JMP 0XF800:0X0000")
SPI32k.Write_Memory_Array(0x0000, file_data)
print("CODE DONE AT ADDRESS 0X0000")
else:
messagebox.showinfo("Compiler Error", "bin file was not compiled check NASM output for errors")
def Compile_code():
if(main_window.file_and_path == ''):
messagebox.showinfo("Compiler Error", "File not open or saved!")
else:
file_save = open(main_window.file_and_path, 'w')
file_save.write(text_field.get(1.0,END))
file_save.close()
main_window.file_and_path_bin = main_window.file_and_path[:-4] + '.bin'
os.system("nasm " + main_window.file_and_path + ' -o ' + main_window.file_and_path_bin)
if os.path.exists(main_window.file_and_path[:-4] + '.bin'):
print("COMPILE COMPLETE")
else:
messagebox.showinfo("Compiler Error", "bin file was not compiled check NASM output for errors")
def Read_Back():
print("JUMP CODE")
SPI32k.Read_Memory_Array(0xFFFF0, 16)
# Create the main window
main_window = Tk()
main_window.title("32K 28C256 Writer")
main_window.minsize(800, 600)
menubar = Menu(main_window)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=new_file)
filemenu.add_command(label="Open", command=open_file)
filemenu.add_command(label="Save", command=save_file)
filemenu.add_command(label="Save As", command=save_as_file)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=main_window.destroy)
menubar.add_cascade(label="File", menu=filemenu)
buildmenu = Menu(menubar, tearoff=0)
buildmenu.add_command(label="Compile -> Upload", command=Compile_and_Upload)
buildmenu.add_command(label="Compile", command=Compile_code)
buildmenu.add_command(label="Read Back 0xFFFF0", command=Read_Back)
menubar.add_cascade(label="Build", menu=buildmenu)
main_window.config(menu=menubar)
main_window.file_and_path = ''
main_window.file_and_path_bin = ''
text_field = Text(main_window)
#text_field.wrap (WORD)
text_field.pack(expand=True, fill='both')
# Run forever!
scrollbar = Scrollbar(text_field)
scrollbar.pack( side = RIGHT, fill = Y )
SPI32k.Start_SPI()
main_window.mainloop()
SPI32k.spi.close()
SPI32k.py
import spidev
import time
MCP23S17_WRITE_00 = 0b01000000
MCP23S17_READ_00 = 0b01000001
MCP23S17_WRITE_01 = 0b01000010
MCP23S17_READ_01 = 0b01000011
IOCON_0A = 0x0A
IODIRA = 0x00
IODIRB = 0x01
GPIOA = 0x12;
GPIOB = 0X13;
ALL_OUT = 0x00;
ALL_IN = 0xFF;
spi = spidev.SpiDev()
def Start_SPI():
spi.open(0, 0)
spi.max_speed_hz = 10000000
#Enable address pins
spi.xfer([MCP23S17_WRITE_01, IOCON_0A, 0b00001000])
#Setup ports
#8 bit Data
spi.xfer([MCP23S17_WRITE_00, IODIRA, ALL_OUT])
#Address 0-7
spi.xfer([MCP23S17_WRITE_00, IODIRB, ALL_OUT])
#Address 8-15
spi.xfer([MCP23S17_WRITE_01, IODIRA, ALL_OUT])
#Control Port
spi.xfer([MCP23S17_WRITE_01, IODIRB, ALL_OUT])
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00000111])
def Read_Memory_Array(Address, Count):
#8 bit Data out put
spi.xfer([MCP23S17_WRITE_00, IODIRA, ALL_IN])
#Turn on power
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00001111])
time.sleep(10000/1000000)
oAddress = Address
while Address < (oAddress + Count):
spi.xfer([MCP23S17_WRITE_00, GPIOB, Address])
spi.xfer([MCP23S17_WRITE_01, GPIOA, Address >> 8])
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00001010])
val = spi.xfer([MCP23S17_READ_00, GPIOA, 0x00])
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00001111])
print(hex(val[2]))
Address += 1
time.sleep(10000/1000000)
#Turn off power
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00000111])
def Write_Memory_Array(Address, code_for_8088):
#8 bit Data out put
spi.xfer([MCP23S17_WRITE_00, IODIRA, ALL_OUT])
#Turn on power
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00001111])
time.sleep(10000/1000000)
for i in code_for_8088:
spi.xfer([MCP23S17_WRITE_00, GPIOB, Address])
spi.xfer([MCP23S17_WRITE_01, GPIOA, Address >> 8])
spi.xfer([MCP23S17_WRITE_00, GPIOA, i])
time.sleep(10000/1000000)
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00001001])
time.sleep(10000/1000000)
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00001111])
Address += 1
time.sleep(10000/1000000)
#Turn off power
spi.xfer([MCP23S17_WRITE_01, GPIOB, 0b00000111])
Unlock Code 8088 assembly
ORG 0X0000
;Setup 8255
MOV AL, 0X80 ;MODE 2 PORT B OUTPUT
OUT 0X63, AL ;WRITE TO 8255 COMMAND PORT
MOV AL, 0XAA ;WRITES 0XAA TO PORT 0X60
OUT 0X60, AL ;
MOV AX, 0XF000 ;SET UP DATA SEGMENT
MOV DS, AX ;
MOV BYTE [0X5555], 0XAA ;UNLOCK BYTES
MOV BYTE [0X2AAA], 0X55 ;
MOV BYTE [0X5555], 0X80 ;
MOV BYTE [0X5555], 0XAA ;
MOV BYTE [0X2AAA], 0X55 ;
MOV BYTE [0X5555], 0X20 ;
MOV BYTE [0X7FF0], 0X20 ;LEAVES A MARKER IN THE END OF THE ROM
HLT