How to extract (read) the code stored in AM27C256-120DC EPROM using Arduino?

Hello,

At the moment, I am engaged in a project in which I have to read the stored program in AM27C256-120DC EPROM. I have been searching for this on web, but I am unsuccessful. If any one of you know how to read data or extract program from the specific EPROM using arduino, can you please shed some light on how to achieve it.

Thank You.

Regards,
Vamshi

This may be of some interest: arduino AM27C256 eprom reader

Hi KawasakiZx10r ,

Thank you for the quick response.

I have been looking at the code and it indicates that output is addressdata.

How can I use this addressdata to retrieve the program stored in EPROM?

What are you expecting?

If you read all 32Kbytes out of that device you're going to have a file of 32Kbytes of raw binary. It may be a program (and data) to whatever processor was in the original system but to you it's just going to be 32K of bytes.

Do you have a disassembler that can produce human-readable mnemonics ("assembly language") from the original processor or were you expecting to see something like a sketch or cpp file?

Hi Blackfin,

I am expecting a binary code and that too, it shows on serial console and I don't know how to convert this raw data to a hex file that can be installed on other processor.

Sorry, I don't have any disassembler. If possible, can you please shed some light on how to achieve this?

Thank You.

As far as reading an EEPROM, it's not hard: Check the datasheet (e.g. http://ecee.colorado.edu/~mcclurel/am27c256.pdf).

See "Switching Waveforms" on page 10.

You need to connect 15 address lines (A0..14), 8 data connections (D0..7) and CE# (chip enable) and OE# (output enable.)

You then just need to sequence, starting at address 0x0000, the address, CE# and OE# pins as shown in the datasheet. The part is quick enough that you probably wouldn't need to put any sort of delays in (e.g. from OE# going low to data being valid -- Toe -- is just 50nS). Read the data on D0..D7, convert it to a byte as needed and send it out the serial port.

Use a terminal program like Putty to save the output to a file.

As for your plan to install this on another processor, I can't help. Without knowing more about where this device came from and what you're looking to put the binary into, no one can really say how much work you're in for.

I will say that if the EPROM came out of, say, an old General Motors ECM (e.g. a GMP4) the code will only run on the 68HC11-variant that ran that ECM. You won't be able to load it into an AVR and have it run. Basically, whatever processor it was programmed for is the processor you're going to need.

If you know the processor, it's memory map, it's opcodes and the like, you might be able to generate passable assembly language and gauge how feasible porting it to another processor is. Like I said, without knowing specifics of what you're doing, I'm going to err on the side of caution and say "ain't gonna work."

1. Make the following connection between AM27C256 and Arduino UNO to read 1024 bytes hex codes (binary) from the EPROM of address: 0x0000 - 0x03FF, display them on Serial Monitor. (You know how to make meanings of these codes through disassembly.)
27c256.png
Figure-1:

2. Upload the following sketch (untested)

void setup()
{
    Serial.begin(9600);
    //place codes to set the directions of DPin-2 to DPin-19 as outputs except: 8 to 13; 6 and 7
    int address = 0;
    for(int i = 0; <1023; i++)
    {
        //---assert address on the EPROM----
        PORTC = lowByte(address);
        digitalWrite(2, bitRead(address, 6));
        digitalWrite(3, bitRead(address, 7));
        digitalWrite(4, bitRead(address, 8));
        digitalWrite(5, bitRead(address, 9));
        delay(1);
        //--place codes to read data of the current location---
        byte x = PINB;
        bitWrite(x, 6, digitalRead(6));
        bitWrite(x, 7, digitalRead(7));
        //-----place codes to display value of x on Serial Monitor with leading zero--
        //..............................
        //--increase the address---
        address++;
    }

}

27c256.png

Thank you GolamMostafa.

@Blackfin,

As you suggested, I will read data on D0...D7 and send it to the serial port.

Is it possible to convert this data into a sketch (program)?

@GolamMostafa,

Actually I am new to this, I don't know how to make meanings of these codes through disassembly.

Moreover, can you please elaborate the code in somewhat detailed way and the procedure of extracting the code stored in EPROM?

Thank You.

vamshich:
Thank you GolamMostafa.

@Blackfin,

As you suggested, I will read data on D0...D7 and send it to the serial port.

Is it possible to convert this data into a sketch (program)?

You're not being specific enough. From what did the EPROM come? What device/thing/computer? Do you have a manufacturer name and model number? What did this thing do? What were its inputs and outputs?

I'm going to say "no, you can't read the contents of the EPROM and make a sketch out of it"; I mean, someone might be able to reverse engineer the contents to a degree (and with a lot of information about the original system) and make a sketch and hardware that is similar in function to the original. But no, you won't be able to load the contents of the EPROM into an AVR and run it.

More likely you'll look at the original thing as a black box with inputs and outputs. You'll study those inputs -- type (analog, digital), range, frequency etc and how they interact with the outputs and then look at the outputs -- type (current, voltage), range, frequency, level etc etc and from all that attempt to make some Arduino-based device that emulates the original (i.e. accepts the same inputs, drives the same outputs with the same responses and behaviors as best as you understand them.)

vamshich:
Is it possible to convert this data into a sketch (program)?

No.

You will need to use a disassembler to convert it into assembler code for the original processor. That will allow you to determine what and how the program works, from which you can write new code to do the same functions with another microcontroller.

To do this you must have complete working knowledge of the original processor and the new one. There is simply no automated process to do this.

Try to implement Post#6 and post what you have got in the Serial Monitor. The codes could be belonging to 8085 or 8051; if so, manual disassembly is possible looking at the instruction template.

@GolamMostafa,

//place codes to set the directions of DPin-2 to DPin-19 as outputs except: 8 to 13; 6 and 7

//--place codes to read data of the current location---

Honestly, I have not understand considering which pins should set as output and which are as input and I haven't done reading data of the current location. Can you please elaborate it?

Thank You.

vamshich:
Honestly, I have not understand considering which pins should set as output and which are as input and I haven't done reading data of the current location. Can you please elaborate it?

Long way to go with you with the current topic. I would not mind to tell you how blink L of UNO if you say that you have the Arduino UNO Learning Kit.

Long way to go with you with the current topic. I would not mind to tell you how blink L of UNO if you say that you have the Arduino UNO Learning Kit.

I am sorry, you misunderstood me. I meant that I haven't wrote the code that reads the data from the current location. Moreover, I know that address pins should be set as inputs and data pins as outputs. But from your schematic and the message, I am confused like which pin is Dpin and which is not.

vamshich:
I am expecting a binary code and that too, it shows on serial console and I don't know how to convert this raw data to a hex file that can be installed on other processor.

Is the other processor the same as the processor that the EPROM was providing code to originally?
Tom.... :slight_smile:

vamshich:
I am sorry, you misunderstood me. I meant that I haven't wrote the code that reads the data from the current location. Moreover, I know that address pins should be set as inputs and data pins as outputs. But from your schematic and the message, I am confused like which pin is Dpin and which is not.

27c256.png
Figure-1:

Refer to Fig-1:
1. DPin stands for Digital IO Pin/Connector of the UNO Board.

2. In the UNO Board, we have DPin-0 to DPin-7; DPin-8 to DPin-13; these are marked on the PCB.

3. In UNO Board, we have A0 - A5; these pins can be used as digital IO pins and their corresponding DPin numbers are: 14 to 19 for A0 to A5.

4. All DPins connected with D0-D7 lines of EPROM will be working as INPUT.

5. All DPins connected to A0-A9 pins will be working as OUTPUT.

Sketch:

void setup()
{
    Serial.begin(9600);
    //place codes to set the directions of DPin-2 to DPin-19 as outputs except: 8 to 13; 6 and 7
    for(byte i = 6; i<14; i++)
    {
        pinMode(i, INPUT);    //6 to 13 are INPUT
    }

    for(byte i = 14; i<20; i++)
    {
        pinMode(i, OUTPUT);    //A0 to A5 are OUTPUT
    }

    pinMode(2, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);

    int address = 0;
    for(int i = 0; <1023; i++)
    {
        //---assert address 0, 1, 2, 3, ... on the EPROM----
        PORTC = lowByte(address);
        digitalWrite(2, bitRead(address, 6));
        digitalWrite(3, bitRead(address, 7));
        digitalWrite(4, bitRead(address, 8));
        digitalWrite(5, bitRead(address, 9));
        delay(1);
        //--place codes to read data of the current location---
        byte x = PINB;
        bitWrite(x, 6, digitalRead(6));
        bitWrite(x, 7, digitalRead(7));
        //-----place codes to display value of x on Serial Monitor with leading zero--
        if(x <0x10)
        {
           Serial.print('0');  //show leading zero
        }
        Serial.print(x);
        Serial.print(' ');   //place a space
        //--increase the address---
        address++;
    }

}

Hi,
I think we need to know more about what the you are doing.

Is the processor that you want to run on this EPROM code, the same as the processor the EPROM code is coming from?

Thanks.. Tom... :slight_smile:

I just read the content of a 27256 from an old car ECM (1994 Mazda MX6) I had lying around using this code and a Mega2560. If you have a Mega and follow the connections (and tie E to GND) you should be able to print the content to the serial monitor as I did. What you can do with the result is another matter...

(the last few lines of the output)

.
.
.
30 93 34 23 0C 8F 96 33 BD FD 94 40 50 82 00 20 
0A 40 50 82 00 8F 96 33 BD FD 94 D3 30 39 D6 30 
27 1A 5F D7 30 4C D6 31 27 07 E6 01 11 25 01 17 
39 4D 2B 07 A6 01 CE 01 01 DF 30 39 4A D6 31 26 
09 43 E6 00 11 25 01 17 43 39 4D 2A 08 A6 00 43 
CE 01 00 DF 30 39 04 04 04 04 04 04 04 4D 27 02 
C6 FF 39 04 04 04 04 04 04 04 39 47 56 47 56 47 
56 47 56 47 56 47 56 47 56 39 05 25 06 05 25 03 
05 24 03 CC FF FF 39 CE 2C FC 86 03 4D 27 0E 0F 
E6 00 5C 26 01 5A E7 00 0E 08 4A 20 EF 39 41 C5 
96 C7 96 C7 96 C7 96 C7 96 C7 96 C7 96 C7 96 C7 
96 C7 92 7E 92 87 96 C7 96 C7 96 C7 96 C7 92 72 
92 90 96 C7 96 C7 96 C7 92 99 92 B7 92 C0 93 4A 
92 C9 96 C7 96 C7 96 C7 96 C7 96 C7 96 C7 8E 26
unsigned int
    Address;

//PORTF
//can use PINF to read data bus
const byte pinD0 = A0;
const byte pinD1 = A1;
const byte pinD2 = A2;
const byte pinD3 = A3;
const byte pinD4 = A4;
const byte pinD5 = A5;
const byte pinD6 = A6;
const byte pinD7 = A7;

const byte pinA0 = 2;
const byte pinA1 = 3;
const byte pinA2 = 4;
const byte pinA3 = 5;
const byte pinA4 = 6;
const byte pinA5 = 7;
const byte pinA6 = 8;
const byte pinA7 = 9;
const byte pinA8 = 10;
const byte pinA9 = 11;
const byte pinA10 = 12;
const byte pinA11 = 13;
const byte pinA12 = 21;
const byte pinA13 = 20;
const byte pinA14 = 19;

const byte pinG = 18;

const byte grData[] = 
{
    pinD0, pinD1, pinD2, pinD3,
    pinD4, pinD5, pinD6, pinD7
        
};

const byte grAddr[] = 
{
    pinA0, pinA1, pinA2, pinA3,
    pinA4, pinA5, pinA6, pinA7,
    pinA8, pinA9, pinA10, pinA11,
    pinA12, pinA13, pinA14
    
};

char szStr[16];

void setup( void )
{
    unsigned char
        idx,
        databyte;
        
    Serial.begin(115200);

    pinMode( pinG, OUTPUT );
    digitalWrite( pinG, HIGH );
    for( int i=0; i<8; i++ )
        pinMode( grData[i], INPUT_PULLUP );
        
    for( int i=0; i<15; i++ )
        pinMode( grAddr[i], OUTPUT );
        
    //0bx111 1111 1111 1111
    Address = 0x0000;
    idx = 0;
    do
    {
        SetAddress( Address );
        digitalWrite( pinG, LOW );
        databyte = PINF;
        digitalWrite( pinG, HIGH );

        sprintf( szStr, "%02X ", databyte );
        Serial.print( szStr );
        idx++;
        if( idx == 16 )
        {
            idx = 0;
            Serial.println("");
            
        }//if
        
        Address++;
        
    }while( Address < 0x8000 );
    
}//setup

void loop( void )
{
        
}//loop

void SetAddress( unsigned int Adr )
{
    for( int i=0; i<15; i++ )
        digitalWrite( grAddr[i], (Adr & (1<<i)) ? HIGH:LOW );
    
}//SetAddress

Blackfin:
What you can do with the result is another matter...

That is the question! :roll_eyes: