Hi there folks!
I was trying to read flash from not-mine device based on AT89s52. Here's my struggle.
Long story short: I'm using Arduino UNO as ArduinoISP and it works for Nano. But it does not work for my AT. Reading with command
avrdude -C F40R96CIUSLFZFP.conf -c avrisp -P /dev/ttyACM0 -p 89s52 -b 19200 -D -Uflash:r:program.bin:r
Gives 0x00000000 signature.
So, I'am wondering if there are not LOCK BITS set, as it is stated in datasheet:
The signature bytes are not readable in Lock Bit Modes 3 and 4.
So I'll propably need to erase chip and program it by myself. But, before I do that I woild like to check LB's.
Here's my avrdude.conf for this purpose:
# This is supposed to be the "default" STK500 entry.
# Attempts to select the correct firmware version
# by probing for it. Better use one of the entries
# below instead.
programmer
id = "stk500v2";
desc = "Atmel STK500 Version 2.x firmware";
type = "stk500v2";
connection_type = serial;
;
programmer
id = "stk500";
desc = "Atmel STK500";
type = "stk500generic";
;
programmer
id = "stk500v1";
desc = "Atmel STK500 Version 1.x firmware";
type = "stk500";
;
programmer
id = "avrisp";
desc = "Atmel AVR ISP";
type = "stk500";
;
programmer
id = "arduino";
desc = "Arduino";
type = "arduino";
;
#------------------------------------------------------------
# AT89S52
#------------------------------------------------------------
part
id = "at89s52";
desc = "AT89S52";
signature = 0x1E 0x52 0x06;
stk500_devcode = 0xE1;
chip_erase_delay = 20000;
pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
"x x x x x x x x x x x x x x x x";
chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
"x x x x x x x x x x x x x x x x";
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 0;
memory "flash"
size = 8192;
paged = no;
min_write_delay = 4000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 0 0 1 0 0 0 0 0",
" x x x a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 0 1 0 0 0 0 0 0",
" x x x a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
mode = 0x21;
delay = 12;
;
memory "signature"
size = 3;
read = "0 0 1 0 1 0 0 0 x x x 0 0 0 a1 a0",
"0 0 0 0 0 0 0 0 o o o o o o o o";
;
;
SPI table attached.
As far as i understand there is missing section "lock". Here's this section for atmega664:
memory "lock"
size = 1;
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x x x o o o o o o";
write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
"x x x x x x x x 1 1 i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
In case of AT89S52 datasheet states for
WRITE: 1 0 1 0 1 1 0 0 1 1 1 0 0 0 B1 B2 x x x x x x x x x x x x x x x x
READ: 0 0 1 0 0 1 0 0 x x x x x x x x x x x x x x x x x x x LB3 LB2 LB1 x x
As far as i understand avrdude would read for me bit locks, with -U lock:r:lb.bin.
But only with correct "lock" section. Also, I'm not sure if "signature" part is written correcty... Shouldn't it state something like:
memory "signature"
size = 3;
read = "0 0 1 0 1 0 0 0 x x x a12 a11 a10 a9 a8",
"a7 x x x x x x 0 o o o o o o o o";
;
And for lock:
memory "lock"
size = 1;
read = "0 0 1 0 0 1 0 0 x x x x x x x x",
"x x x x x x x x x x x o o o x x";
write = "1 0 1 0 1 1 0 0 1 1 1 0 0 0 i i",
"x x x x x x x x x x x x x x x x ";
min_write_delay = 9000;
max_write_delay = 9000;
;
Have no idea about min/max write delay...