Closed PSLLSP closed 3 years ago
hi how to get eeprom to STC MCU
Could be patch for this issue accepted?
I've already noticed this issue and the proposed patch, I'd just like to test it myself with various STC15 series MCUs. It would certainly help if you prepare a proper MR.
When I flash EEPROM second file to
stcgal
to empty chip, it works, no problem ($ stcgal -p /dev/ttyUSB0 program.hex eeprom.hex
). When I try upload EEPROM second time, I receive errorProtocol error: incorrect magic in write packet
. When I check EEPROM area, it was not erased so I think that error means that EEPROM cannot be written because that area is not blank. I can repeat this problem with STC15F104W and STC15W408AS.Tail of flashing process in DEBUG mode (stcgal -D -p /dev/ttyUSB0 flash-dump.ihx 80.hex ):
Issue #58 has program
flash-dump.c
that can be used to troubleshot this issue (to dump EEPROM area to serial port)I erased the chip in Windows with
STC-ISP
. Then I prepared EEPROM file with 0xff data:I can write this file with
stcgal
again and again, no problem (because no data are changed):I prepared other EEPROM file, it has only one byte data and data is 0xfe.
I flash it to MCU, no problem:
But when I try to flash it again, I receive error
Protocol error: incorrect magic in write packet
. When I don't ask to write EEPROM file, no error is reported. So I think this confirm the theory that this error means that EEPROM is not blank and data cannot be written...I prepared file with 0xff data, length 8192. My MCU is STC15W408AS and it has 8kB of FLASH and it has 5kB EEPROM. I read somewhere that
stcgal
has a secret feature and it can write program and EEPROM data in one run, when first file is large enough. So my idea was to flash file with size 13312 ((8+5)*1024=13312) bytes and data 0xff, that should erase the complete chip.stcgal
wrote 8kB and than reported error but EEPROM was not erased it still has 0xfe byte at position 0x0000 (0x2000 when accessed from code)... I executed more experiments and I can confirm thatstcgal
can write flash and EEPROM in one go as one big file BUT only in the case that EEPROM is blank;stcgal
cannot blank EEPROM. When EEPROM is not blank, errorProtocol error: incorrect magic in write packet
is reported.Workarround (to avoid switching to Windows to use STC-ISP programmer to blank EEPROM area). C program to check and blank EEPROM, sector by sector, up to 128 sectors; it assumes that sector size is 512 bytes. Based on demo program from STC, modified for SDCC.
The patch (for stc15 protocol, the only one with this issue?):