Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check flash cards integrity
// SCRIPT
#!/bin/bash
dd if=/dev/urandom bs=1M count=1 of=somerandom
for i in $(seq 1 1000)
do
thisblock=$(shuf -i 0-63999 -n 1)
sudo dd if=somerandom of=/dev/mmcblk0 bs=1M seek=$thisblock
sudo sync
sudo dd if=/dev/mmcblk0 skip=$thisblock bs=1M count=1 | diff - somerandom
if [ $? == 1 ]
then
echo "bad"
echo $thisblock >> badblocks
else
echo "good"
echo $thisblock >> goodblocks
fi
done
// CHECK RESULTS
$ wc -l goodblocks badblocks
240 goodblocks
760 badblocks
1000 total
// PLOT RESULTS
goodblocks=dlmread("goodblocks");
badblocks=dlmread("badblocks");
image=zeros(320,200);
for i=goodblocks'
x=floor(i/200)+1;
y=(mod(i,200))+1;
image(x,y)=1;
end
for i=badblocks'
x=floor(i/200)+1;
y=(mod(i,200))+1;
image(x,y)=2;
end
colourmap=[0 0 0; 0 1 0; 1 0 0];
imshow(image+1,colourmap);
imwrite(image+1,colourmap,"image.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.