EVGA

Hot!My DDR4 SPD reader/writer, now with RSWP (write protection) clearing and enabling options

Author
a213m
SSC Member
  • Total Posts : 506
  • Reward points : 0
  • Joined: 2006/02/08 11:10:24
  • Location: Canada
  • Status: offline
  • Ribbons : 11
2020/05/13 23:27:32 (permalink)
Update (24.05.2020)
 
Guide:
 
Part 1 - hardware
 
Wire up your Arduino + DDR4 DIMM according to the schematic below:
 

 
 (Numbers in brackets indicate DDR4 pin).
  1. Connect DDR4 SDA (285) to Arduino's SDA **
  2. Connect DDR4 SCL (141) to Arduino's SCL ***
  3. Connect DDR4 VDDSPD (284) to Arduino's +3.3V source
  4. Connect DDR4 SA1 (140), DDR4 SA2 (238), DDR4 EVENT_N (78), and any DDR4 VSS (*) to ground.
  5. Connect DDR4 SA0 (139) to the emitter of the optocoupler (U1)
  6. Connect positive terminal (+) of 9V battery to collector of the optocoupler
  7. Connect negative terminal (-) of the 9V battery to ground.
  8. Connect optocoupler's anode in series with a resistor (R1) to Adruino's pin D6 ****
  9. Connect optocoupler's cathode to ground.
  10. Optionally connect optocoupler's emitter in series with resistor (R2) to ground. This resistor is optional, I used 10k. Using lower values caused issues when executing WP-related command on the device. Works fine without one.
  11. Optionally connect SDA and SCL to 3.3V via pull-up resistors (R3, R4). I used 2kOhm, but everything works without them, since most Arduinos have internal pull-up resistors.
  12. Optionally connect a capacitor (C1) in parallel with VDDSPD and GND to stabilize input voltage to the EEPROM.
 
* There are multiple VSS (GND) pins on DDR4, use any of them, I prefer to use one of the ones close to the edge, where most of the used pins are. Refer to DDR4 pinout table below.
 

 
**, *** Refer to your Arduino model pinout, on my Nano model SDA and SCL are A4 and A5, respectively: https://www.arduino.cc/en/reference/wire

**** You may use a different pin to turn on an optocoupler, just edit the value of "OPTCO" constant in the sketch accordingly.
 
Parts list:
 
(parts in orange are needed to work with write protection instructions, you may assemble the programmer without these parts, but you won't be able to set or clear write protection)
  • Arduino Nano V3 (or any model with I2C / TWI interface)
  • U1 = Any optocoupler with a maximum collector to emitter voltage above 10V and a diode current below 40mA and forward voltage below 5V.
  • Battery = any battery (or batteries in series) with a voltage of between 8.1V and 10V.
  • R1 = 220 - 330 ohm
  • R2 (optional) = 10k
  • R3, R4 (optional) = 2k - 4.7k
  • C1 (optional) = 6.3V, 560uF
 
DDR4 DIMM pins location:
 

(photo borrowed from wikipedia)
 
Obviously don't solder wires directly to DIMM contacts or motherboard solder points, get a spare slot from components resellers, like Digikey, or get a DDR4 DIMM adapter, like the one pictured below. Those are cheap, and have pins labeled for easy identification.
 

 
Part 2 - Firmware and basic usage

Upload firmware to your Arduino once everything is assembled. Then open Serial Monitor, and enter 
t
into the text field and press "send" or enter key. If everything works, you'll receive an "!" in response.
 
To find an address of your EEPROM, enter
s 80 87
. The first parameter is a starting address, the second parameter is the ending address. The device will respond with an address (or addresses) of all EEPROM devices found. The device will respond in binary format, so the responses will be translated into ASCII symbols in the response window. If you have an EEPROM at address 80 (0x50 in HEX, or 01010000 in binary), the response will be shown as letter "P", because 0x50 (80) matches "P" in ASCII.
 
To read a byte, enter
r 80 0
, where 80 is the device address and 0 is the byte offset. You might not see any response, unless the byte value matches one from ASCII symbol set.
 
To write byte 0xFF at offset 16, enter
w 80 16 255
. When the byte is successfully written, the device will respond with 0x00, but because it doesn't match any symbol from ASCII  set, you'll not see any response in serial monitor.
 
Please note, all numbers, including offset positions and byte values must be entered in decimal notation to work.
 
If your EEPROM is write-protected, you may disable the protection with command
c
. There are no parameter and it doesn't use device address.
 
To enable write protection again, enter
e 0
. The last number specifies which of 4 blocks to be protected, from 0 to 3. The device address isn't used, so all devices will act simultaneously on the same bus.
 
The commands can be combined into one line. To enable write protection on all blocks, enter:
 
e 0 e 1 e 2 e 3

 
Of course this isn't very convenient to work with the device like that by manually typing commands into the serial monitor window, so I wrote a program which communicates with the device over serial port by automating all commands the device is programmed to respond to and properly handling all responses. Proceed onto the next section.
 
Part 3 - Windows application
 
The Windows application is a сonsole program, there's no GUI, and I'm not planning on making one, so don't ask for one. Once you wired everything up and uploaded the sketch to your Arduino, download the binary or compile it from the source code.
 
The program can read and write bytes, and enable or disable write protection. The operation depends on its command line arguments. The supported arguments are:
 
  1. /help
  2. /find
  3. /scan <PORT>
  4. /read <PORT> <ADDRESS#> <filepath> /silent
  5. /write <PORT> <ADDRESS#> <FILEPATH> /silent
  6. /writeforce <PORT> <ADDRESS#> <FILEPATH> /silent
  7. /enablewriteprotection <PORT>
  8. /enablewriteprotection <PORT> <block#>
  9. /disablewriteprotection <PORT>
 
The parameters in CAPS are mandatory. Parameter <filepath> is optional when 
/read
switch is used, output will be printed to console only.
 
You'll need to know two parameters to work your DIMM - port name and EEPROM address. To find out what port your device is using, run this command:
 
SpdReaderWriter.exe /find

 
If everything works, you'll get a port name your device is connected to:
 
 
 
Found Device on Serial Port: COM3

 
In my case it is COM3. If the program can't find any devices, make sure the sketch is properly uploaded to your Arduino and no other application is using your Arduino's serial port - that includes Arduino IDE Serial Monitor. Close it, if you have it open.
 
With a DDR4 DIMM present you'll want to scan your device for EEPROM addresses on I2C bus. With SA0-SA2 connected to ground, the address will be 80, however, it is still recommended to run this test to ensure the EEPROM is detected:
 
SpdReaderWriter.exe /scan COM3

 
In most cases, if everything is fine, you'll see a device at address 80 detected:
 
 
 
Found EEPROM at address: 80

 
When I used DDR4 slots cut out of an old motherboard with both DIMMs populated, both were detected at addresses 80 and 82, even though I soldered wires to one slot only:
 
 
 
Found EEPROM at address: 80
Found EEPROM at address: 82

 
To read SPD from your DIMM, run:
 
SpdReaderWriter.exe /read COM3 80

 
This will output SPD contents in HEX on screen. Plain and simple.
 

Reading EEPROM at address 80

000: 23 10 0C 02 84 19 00 08 00 00 00 03 01 03 00 00
010: 00 00 08 0C F4 1B 00 00 6C 6C 6C 11 00 74 20 08
020: 00 05 70 03 00 A8 1E 2B 2B 00 00 00 00 00 00 00
--edited on purpose--
1D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
1E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Read 512 bytes from EEPROM at address 80 on port COM3 in 1547 ms

 
To save SPD to file, add a file path at the end. File path can be absolute or relative. If file path has spaces in it, enclose it in "double quotes":
 
SpdReaderWriter.exe /read COM3 80 C:\temp\spdoutput.bin

SpdReaderWriter.exe /read COM3 80 "C:\temp\my ddr4 spd file.bin"

 

Reading EEPROM at address 80 to C:\temp\my ddr4 spd file.bin

000: 23 10 0C 02 84 19 00 08 00 00 00 03 01 03 00 00
--edited on purpose--
1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Read 512 bytes from EEPROM at address 80 on port COM3 in 1562 ms to file "C:\temp\my ddr4 spd file.bin"

 
Edit your SPD in a HEX editor or any specialized program, like Thaiphoon Burner. 
 
To write your new SPD to DIMM, run:
 
SpdReaderWriter.exe /write COM3 80 C:\temp\newspd.bin

 
EEPROMs have limited number of write cycles, sometimes between 10,000 and 1,000,000. By default, the program writes bytes only if they differ from existing values. By doing that, it first reads a byte and if it matches the input value, the write operation is skipped. Byte is written only it it needs to. If you want to force writes, regardless of existing SPD data, use 
/writeforce
switch instead of
/write
.
It will take a bit longer (5-10 s.) because of required delays after each write.
 

Writing "C:\temp\my ddr4 spd file.bin" (512 bytes) to EEPROM at address 80

000: 23 10 0C 02 84 19 00 08 00 00 00 03 01 03 00 00
010: 00 00 08 0C F4 1B 00 00 6C 6C 6C 11 00 74 20 08
020: 00 05 70 03 00 A8 1E 2B 2B 00 00 00 00 00 00 00
--edited on purpose--
1D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
1E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
1F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Written 512 bytes to EEPROM at address 80 on port COM3 in 7093 ms

 
Optionally, to hide progress you may add 
/silent
switch at the end after a file path is specified when using
/read
,
/write
, or
/writeforce
switches:
 
SpdReaderWriter.exe /read COM3 80 C:\temp\spdoutput.bin /silent

SpdReaderWriter.exe /write COM3 80 C:\temp\newspd.bin /silent

 
You may protect the entire EEPROM from writing with this command:
 
SpdReaderWriter.exe /enablewriteprotection COM3

 
If the blocks weren't write-protected previously, you'll receive a response like this:
 

Block 0 is now read-only
Block 1 is now read-only
Block 2 is now read-only
Block 3 is now read-only

 
Or enable write protection on each individual block by specifying block number (0-3):
 
SpdReaderWriter.exe /enablewriteprotection COM3 0

SpdReaderWriter.exe /enablewriteprotection COM3 2

 
Each block specifies a section of 128 bytes. Block 0 is bytes at offset 0-127, block 1 is bytes 128-255, and so on.
 
Please note the address isn't used, only port number. That's because RSWP commands don't use addresses, all devices on the I2C bus will act simultaneously.
 
To clear write protection, run the following command:
 
SpdReaderWriter.exe /disablewriteprotection COM3

 
Again, the device address isn't used.
 
Once write-protection is cleared, you'll see this response:
 

Write protection successfully disabled.

 
That's all for now.
 
For advanced uses, see "Examples" class in the source code.
 
 
~~~Original post:
I'm currently working on an Arduino based DDR4 SPD reader/writer to read and write SPDs from and to DDR4 RAM modules.
 
The hardware prototype is finished and is working perfectly. The software is 99% ready and just needs to have some bugs ironed out, but originally planned basic functionality (which is reading and writing SPDs) is fully implemented is bug free.
 
If anyone's is interested I'm ready to release schematic, firmware source (Arduino sketch), and Windows executable (C# source and compiled binary). Or, if nobody cares, I'll just keep it as private project for myself only.
 



post edited by a213m - 2020/05/24 11:23:19


        9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
---
DDR4 SPD reader/writer
#1

10 Replies Related Threads

    jfw06013
    SSC Member
    • Total Posts : 507
    • Reward points : 0
    • Joined: 2017/02/14 10:26:10
    • Status: offline
    • Ribbons : 4
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/14 00:10:21 (permalink)
    I just started with Arduino and I am very interested in you project.


    #2
    a213m
    SSC Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2006/02/08 11:10:24
    • Location: Canada
    • Status: offline
    • Ribbons : 11
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/15 03:06:16 (permalink)
    Almost there, everything is working properly now.
     

     



     


            9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
    ---
    DDR4 SPD reader/writer
    #3
    Cool GTX
    EVGA Forum Moderator
    • Total Posts : 22641
    • Reward points : 0
    • Joined: 2010/12/12 14:22:25
    • Location: Folding for the Greater Good
    • Status: offline
    • Ribbons : 117
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/15 07:02:49 (permalink)
    sounds interesting
     
    can damaged/ corrupted SPD code be overwritten -- Recovered ? 

    Cause you know someone will OC it too far 

    RTX Project EVGA X99 FTWK-5930K 2xEVGA2080Ti EVGA-1200P2  Nibbler EVGA X99 3-GPU Water Loop 1600P2  AIO Folding  X99 2x1080Ti FTW3 Hybrid, 1200P
    Thank You for Your Support


    #4
    a213m
    SSC Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2006/02/08 11:10:24
    • Location: Canada
    • Status: offline
    • Ribbons : 11
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/15 22:19:07 (permalink)
    Look what came in the mail today after weeks months of waiting. Now I no longer have to use slots I cut out of a dead motherboard.
     

     
    Cool GTX
    sounds interesting
     
    can damaged/ corrupted SPD code be overwritten -- Recovered ? 

    Cause you know someone will OC it too far

     
    Yes, provided you have a backup of correct SPD data, or a working DIMM.
     
    I'll aslo implement a CRC checker into the Windows app. In won't be accessible via command line switches initially, but rather by calling a function directly.

    Edit: Arduino sketch is posted, link is in the first post.
    post edited by a213m - 2020/05/15 22:32:31


            9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
    ---
    DDR4 SPD reader/writer
    #5
    TiN_EE
    EVGA Forum Moderator
    • Total Posts : 343
    • Reward points : 0
    • Joined: 2010/01/22 21:30:49
    • Location: xDevs.com
    • Status: offline
    • Ribbons : 13
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/16 10:55:55 (permalink)
    Nice work. You can just buy slots from component retailers such as Digikey.
     
    I've did this back in 2014 for internal use and testing at EVGA R&D lab :)
    My box designed for onboard MCU or couples with Raspberry Pi. Worklog and code : https://xdevs.com/article/ddr4s/
     
    Beware, many SPDs on memories are actually write-protected, so you can read them, but cannot write/modify. :)
    post edited by TiN_EE - 2020/05/16 11:01:01

    If you have question, please post in public forum. I do not reply PMs, so all in community can benefit the answer. 
    #6
    a213m
    SSC Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2006/02/08 11:10:24
    • Location: Canada
    • Status: offline
    • Ribbons : 11
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/16 14:41:47 (permalink)
    Thanks. So far I haven't encountered any write protected EEPROMs, in fact the DIMMs I used in my tests use EEPROMs which lack permanent write protection capabilities.
     
    I'll start working on software write protection enabling/disabling capabilities soon. It will require a couple more components added to the circuit and an additional 9V source.
     
    The project is complete. Windows binary and sources + updated Arduino sketch are up.
     
    Links are in the first post.
    post edited by a213m - 2020/05/16 14:44:22


            9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
    ---
    DDR4 SPD reader/writer
    #7
    a213m
    SSC Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2006/02/08 11:10:24
    • Location: Canada
    • Status: offline
    • Ribbons : 11
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/20 00:49:17 (permalink)
    I got some bad news and (as a result) good news.
     
    Today I finally stumbled upon a kit of G.Skill DIMMs with write-protected EEPROMs, which can be read, but can't be modified, unless write protection is reversed.
     
    But that's history now, I just wanted to announce I implemented a software reversible write protection clearing function in my project.
     
    It can't be implemented with software alone as it requires an update to both hardware and software, since it requires an additional external DC power source from 7V-10V, which Arduino alone isn't capable of providing, so stay tuned for updated schematics and code.
     



            9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
    ---
    DDR4 SPD reader/writer
    #8
    a213m
    SSC Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2006/02/08 11:10:24
    • Location: Canada
    • Status: offline
    • Ribbons : 11
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/22 04:24:54 (permalink)
    Update: 22.05.2020 - now with write protection reversing and enabling options 
     
    Updated schematics, description, firmware, binary, and sources are in the first post.


            9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
    ---
    DDR4 SPD reader/writer
    #9
    a213m
    SSC Member
    • Total Posts : 506
    • Reward points : 0
    • Joined: 2006/02/08 11:10:24
    • Location: Canada
    • Status: offline
    • Ribbons : 11
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/24 01:29:34 (permalink)
    May 24 update - fixed an issue where bytes were not written to higher half of EEPROM, if the second half was identical to the first half when using "/write" switch.
     
    Updated links are in the first post, as usual.
     
    PS: Aslo, because in 2020 RGB has to be everywhere, I added a color byte display.
     
    It's enabled by default, to disable it, set "color" boolean parameter to "false" where DisplayByte() function is called.
     

     
    Random bytes written to show as many colors as possible:
     

     
     


            9980XE / R6EE / 64GB / 2 x 1080Ti / 1TB / 1600W
    ---
    DDR4 SPD reader/writer
    #10
    TiN_EE
    EVGA Forum Moderator
    • Total Posts : 343
    • Reward points : 0
    • Joined: 2010/01/22 21:30:49
    • Location: xDevs.com
    • Status: offline
    • Ribbons : 13
    Re: Would anyone be interested in open source and free DDR4 SPD reader/writer? 2020/05/24 10:18:36 (permalink)
    Nice work.
    I'd suggest upload your project to github or smth, so others can contribute too :)

    If you have question, please post in public forum. I do not reply PMs, so all in community can benefit the answer. 
    #11
    Jump to:
  • Back to Mobile