Go Down

Topic: Is it possible to read entire chip ATMEGA328P-PU and output it serially? (Read 2126 times) previous topic - next topic

bamafan

I have a board with a ATMEGA328P-PU eprom chip on it.  For a verification purpose, I want to be able to read the contents of the chip and output that via the serial port.  I know I can read the EEPROM portion using the serial commands, but that is only 512 bytes of it.

Can someone tell me how to read all the contents of the entire chip, all bytes including the memory portion and the portion that the C programming resides on?  Basically every byte of the chip.

I would then like to output the bytes through the onboard serial port to a program I will write.  Is there any way to read the contents of the whole chip byte by byte using some sort of sketch?

Thank you for any help you can provide.

Jack Christensen


johnwasser

You are trying to read the FLASH memory.  The ability to do that depends on the settings of the memory protection flags.

You can read FLASH memory with: byte value =  pgm_read_byte_near(address);
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

bamafan

Jack, yes, the chip is already programmed to output the serial bytes of the EEPROM memory using serial commands and works fine.

John,  Thanks, I will give that a try.


Jack Christensen

I was just curious as to why the concern to verify. I believe AVRDUDE verifies the program after upload, whether via serial or in-circuit programming.

bamafan

Jack,  The verification is an end customer requirement, I suppose to make sure that all eproms are always exactly the same.

John, your tip to read the flash memory was dead on.  I have the program running now.  Thank you for saving me lots of googling time.


Jack Christensen

It just sounds like re-inventing the wheel, and re-verifying something that's already been verified. For example, verbose upload output from Arduino IDE (only the salient lines):

Quote
avrdude: AVR device initialized and ready to accept instructions
avrdude: reading input file "C:\DOCUME~1\...\BlinkWithoutDelay.cpp.hex"
avrdude: writing flash (970 bytes):
avrdude: 970 bytes of flash written
avrdude: verifying flash memory against C:\DOCUME~1\...\BlinkWithoutDelay.cpp.hex:
avrdude: load data flash data from input file C:\DOCUME~1\...\BlinkWithoutDelay.cpp.hex:
avrdude: input file C:\DOCUME~1\...\BlinkWithoutDelay.cpp.hex contains 970 bytes
avrdude: reading on-chip flash data:
avrdude: verifying ...
avrdude: 970 bytes of flash verified
avrdude done.  Thank you.

bamafan

I am reinventing the wheel, but you have to please the customer.

In this particular case, this is what he needs.

This way, he can use whatever verification program he wants, and that makes him happy.


Jack Christensen


westfw

"avrdude", which is the program used to load the sketch into the ardunio, is also capable of reading the entire chip's memory contents, either by using the bootloader or by using the ISP programming connection.  That's probably how this should be done, since otherwise you're talking about devoting a relatively significant chunk of the sketch to doing this "verification."

At the chip is a microcontroller, not an EPROM.

Senso


robtillaart

Quote
Is it possible to read entire chip ATMEGA328P-PU and output it serially?


Theoretically it cannot be done as the pointer to the (Flash/RAM/EEPROM) memory location will change during the reading. Also internal timers registers etc are changing during the process.

In practice just follow John Wasser's advice - You can read FLASH memory with: byte value =  pgm_read_byte_near(address);

Do you also need to dump the RAM?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

bamafan

Hi all,

I just wanted to let you know that I was able to read the chip using the commands pgm_read_byte_near(address) as John suggested.

Thanks for all the helpful suggestions.  I hope and can return the favor one day.


Go Up