Created
July 11, 2017 12:39
-
-
Save rodrigoalviani/d9267df0974fcd393b1615aeece6ec2e to your computer and use it in GitHub Desktop.
Check flash cards integrity
This file contains hidden or 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
| // 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