Last active
March 21, 2023 08:41
-
-
Save r0mdau/8d9ebfde39ae2ae109738a41c740b0e3 to your computer and use it in GitHub Desktop.
Python script to check raspberry pi SD card health
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
def writeSomeBytesSucceed(datas): | |
filepath = "/sdCardTest.raw" | |
testpattern = bytes(datas) | |
writer = open(filepath, "wb", buffering=0) | |
writer.write(testpattern) | |
writer.close() | |
reader = open(filepath, "rb", buffering=0) | |
reader.seek(0) | |
testpattern_read = reader.read(8) | |
result = testpattern_read == testpattern | |
reader.close() | |
os.remove(filepath) | |
return result | |
if writeSomeBytesSucceed([0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55]) is False or writeSomeBytesSucceed( | |
[0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa]) is False: | |
print("ERROR writing test pattern !") | |
exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment