Here comes a small I2C christmas story

BL24C128A = I2C eeprom with 256 pages a 64 bytes + 1 extra id page ==>
https://www.belling.com.cn/media/file_object/bel_product/datasheet/BL24C128A.pdfD.MO pcb pulls all address lines to GND which make I2C address of the eeprom 0x50
In order to read from a specific address an incomplete write (just sending the address and then stop) needs to be performed.
At startup D.MO printer reads in 8 byte blocks starting at page 1 (address 0x0040).
write to 0x50 ack data: 0x00 0x40
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
read to 0x50 ack data: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF==> Factory default is empty (everything is 0xFF)
At the moment a new spool is inserted into the printer the following WRITE happens:
write to 0x50 ack data: 0x00 0x40 0xFF 0x01 0x16 0x7B 0x77 0x55 0xC6 0xFF
write to 0x50 nak
write to 0x50 nak
write to 0x50 ack data: 0x00 0x00
read to 0x50 ack data: 0xFFTranslation:
- write to I2C device 0x50, to address 0x0040
- try to start a new write => NAK (polling to find if eeprom is still busy with the write)
- try to start a new write => NAK (polling to find if eeprom is still busy with the write)
- try to start a new write @0x0000 => ACK (polling found out eeprom is not busy with write anymore)
- read (from 0x0000) ==> 0xFF (makes no sense... but maybe this was the "easy" way to cancel the previous write)
Let's have a look at the written data (8 bytes):
0xFF 0x01 0x16 0x7B 0x77 0x55 0xC6 0xFF
FIX? FIX? UID UID UID UID CNTR CNTR
So it looks like the 8 bytes are composed as follows:
0xFF 0x01 fixed (same for all records, I added more later)
0x16 0x7B 0x77 0x55 UID (lower 4 bytes of the slix2 tag UID)
0xC6 0xFF counter (last seen counter value for this slix2 tag UID)
!AFTER THE EEPROM WRITE THERE IS NO READ / VERIFY OF THE JUST WRITTEN DATA!
==> hardware write protect will work 100%And just in case there is a check, we could solder 2 wires from resistors next to I2C eeprom to the bluepill and...
a) whenever bluepill starts up we could ERASE the eeprom (to factory defaults)
b) emulate the eeprom completely
Whenever printer is turned on / comes back from standby / spool is changed, a read starting from address 0x0040 is initiated...
... as soon as the UID from the currently inserted tag is found the read stops
... it also stops after reading several? empty entries (8 times 0xFF) - looks like it stops as soon as the first eeprom page is read which starts with 8x 0xFF
I will now "clean up" my eeprom, add the "solder blob write protect" and then focus on making everything work again ;-)
JS
So for testing you should:
- make eeprom write protect FIRST
- then pick a never used SLIX2 TAG EMU (e.g. 17) and compile firmware with it (this ensures that your eeprom does not have UID from tag emulation stored with a low or locked counter)
#define SLIX2_TAG_EMU 17
(tag pass through does not work yet, will be fixed soon).