2

I have connected my circuit as mentioned in the below link:

Writing/Reading an EEPROM chip using 1-wire bus

I am able to read and write through commands mentioned in the link.

I would like to know about write protect command since I do not want to rewrite on first two pages or first 512 bits

Any advice or helpful links that could make this process easier for me? Thanks in advance.

4

It is very helpful when working with electronic devices to read their data sheet. The electronics equivalent of RTFM, "Read the fine manual" is RTFDS. It will explain the features and electrical characteristics of the device as well as often giving example circuits and even example code. Simply typing the part number of the device into a search engine is usually enough to find a PDF data sheet. Link here for DS2431.

According to the memory map from the data sheet, you can put each of the 4 memory pages into write protect mode by writing the hex value "55h" to their corresponding protection control byte.

DS2431 memory map

In your case you will need to write the hex value "55h" to addresses "0080h" and "0081h" to write protect the first two pages.

If you have set up your Pi like the example that you linked, you can do the following (there is probably a more elegant way to do this but this should work) to write the values:

printf '\x55' | sudo dd of=/sys/bus/w1/devices/2d-000022b489f8/eeprom bs=1 seek=128 conv=notrunc

This will use the hex value "55h" as input for the dd command (printf '\x55' | sudo dd), which will then skip to the 128th (128 = 80h) byte (seek=128) of the eeprom device (of=/sys/bus/w1/devices/2d-000022b489f8/eeprom) and write one byte of the input data (bs=1), without affecting the rest of the data (conv=notrunc).

You can repeat the same thing but change to seek=129 to write protect the second memory page (129 = 81h).

Unfortunately the module w1_ds2431 which mounts the EEPROM as a filesystem does not allow access to the protection registers.

7
  • Well said! And welcome to RPi SE. +1 – Seamus Feb 24 '20 at 21:47
  • Thank you @justinjt . I am still not able to write protect. Please find the attached image and let me know if I am doing anything wrong. – Vicky Feb 24 '20 at 23:45
  • @Vicky it seem the w1_ds2431 module does not allow access to the protection registers. Are you able to unload the module "sudo rmmod w1_ds2431" and then try writing to the raw device directly? I would also be careful that once you have write protected a page it might be permanent. – justinjt Feb 25 '20 at 2:16
  • @justinjt I tried sudo rmmod w1_ds2431, it removed eeprom folder from cd /sys/bus/w1/devices/2d-00002b798913, hence I lost access to read or write. I have reinstalled it by rebooting RPi and sudo modprobe w1_ds2431. I was not able to reinstall using sudo insmod w1_ds2431. I understand that once I write protect a page, it will be permanent, I am okay with it since I am currently prototyping phase. – Vicky Feb 25 '20 at 18:43
  • After removing the module, what is the output of ls /sys/bus/w1/devices/2d-00002b798913 – justinjt Feb 26 '20 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.