Difference between revisions of "IoTGateway/BSP/Android/Gettingstarted/How to use SD/MMC Card"
From ESS-WIKI
Billy.soong (talk | contribs) (Created page with "SD/MMC card is supported in Android system. Starting in Android 6.0, Android supports [https://source.android.com/devices/storage/adoptable.html ''adoptable'' storag...") |
Billy.soong (talk | contribs) |
||
Line 2: | Line 2: | ||
Please refer to "Storage" section on the Android web site [https://source.android.com/devices/storage/index.html https://source.android.com/devices/storage/index.html] | Please refer to "Storage" section on the Android web site [https://source.android.com/devices/storage/index.html https://source.android.com/devices/storage/index.html] | ||
+ | |||
+ | |||
+ | |||
+ | == Check sysfs node == | ||
+ | <pre># cat /sys/block/mmcblk0/device/type | ||
+ | MMC | ||
+ | # cat /sys/block/mmcblk1/device/type | ||
+ | SD | ||
+ | </pre> | ||
+ | |||
+ | SD Card is taken as an example: | ||
+ | |||
+ | == Generate random file == | ||
+ | <pre># dd if=/dev/urandom of=data bs=1 count=1024 | ||
+ | </pre> | ||
+ | |||
+ | Back up | ||
+ | <pre># dd if=/dev/mmcblk1 of=backup bs=1 count=1024 skip=4096 | ||
+ | </pre> | ||
+ | |||
+ | == Write to SD == | ||
+ | <pre># dd if=data of=/dev/mmcblk1 bs=1 seek=4096 | ||
+ | </pre> | ||
+ | |||
+ | == Read and Verify == | ||
+ | <pre># dd if=/dev/mmcblk1 of=data1 bs=1 count=1024 skip=4096 | ||
+ | # diff data data1 | ||
+ | </pre> | ||
+ | |||
+ | If fail, it shows as below: | ||
+ | <pre>Binary files data1 and data differ | ||
+ | </pre> | ||
+ | |||
+ | Restore | ||
+ | <pre># dd if=backup of=/dev/mmcblk1 bs=1 seek=4096</pre> |
Revision as of 09:27, 25 January 2017
SD/MMC card is supported in Android system. Starting in Android 6.0, Android supports adoptable storage, which is provided by physical media, like an SD card or USB, that is encrypted and formatted to behave like internal storage.
Please refer to "Storage" section on the Android web site https://source.android.com/devices/storage/index.html
Check sysfs node
# cat /sys/block/mmcblk0/device/type MMC # cat /sys/block/mmcblk1/device/type SD
SD Card is taken as an example:
Generate random file
# dd if=/dev/urandom of=data bs=1 count=1024
Back up
# dd if=/dev/mmcblk1 of=backup bs=1 count=1024 skip=4096
Write to SD
# dd if=data of=/dev/mmcblk1 bs=1 seek=4096
Read and Verify
# dd if=/dev/mmcblk1 of=data1 bs=1 count=1024 skip=4096 # diff data data1
If fail, it shows as below:
Binary files data1 and data differ
Restore
# dd if=backup of=/dev/mmcblk1 bs=1 seek=4096