In case of future corruption of the flash memory chip on your iSpot (especially if you are ‘hacking’ your device), it’s a good idea to make a backup of the contents. Hopefully, having this backup will make it possible to recover from ‘bricking’/etc in the future.
There are 10 ‘partitions’ on the flash memory chip in the iSpot (at least on my device). You can get a list of the partitions by dumping the contents of the file “/proc/mtd”:
# cat /proc/mtd dev: size erasesize name mtd0: 00040000 00020000 "RedBoot" mtd1: 00020000 00020000 "param" mtd2: 00120000 00020000 "linux" mtd3: 00600000 00020000 "rootfs" mtd4: 00100000 00020000 "system" mtd5: 00120000 00020000 "linux_2" mtd6: 00600000 00020000 "rootfs_2" mtd7: 00020000 00020000 "ver_1" mtd8: 00020000 00020000 "ver_2" mtd9: 0001f000 00020000 "FIS directory" mtd10: 00001000 00020000 "RedBoot config"
Each of the partitions has a pair of corresponding “device files” in “/dev” (one ‘character’ device, one ‘block’ device). For example, for “mtd0” you’ll find “/dev/mtd0” and “/dev/mtdblock0” files.
NOTE: Actually, “mtd10” doesn’t seem to have these device files by default. If you’d like to be able to access “mtd10” like other partitions, then type the following commands to create them:
mknod /dev/mtd10 c 90 20 mknod /dev/mtdblock10 b 31 10
To ‘back up’ a partition, use the “dd” command to dump the contents of the ‘character’ device file (“/dev/mtd0”, for example):
dd if=/dev/mtd0 of=/tmp/mtd0_backup.bin
Be careful about the “if=” (input file) and “of=” (output file) arguments – don’t mix them up!
Execute the “dd” command on each of the 10 partitions in order to have a complete backup.
The above example leaves the backup binary file in “/tmp”. I’ve found that backing up to “/var/wwwroot” instead makes it easy to get the files off of the iSpot (and on to your PC). “/var/wwwroot” points to the root of the iSpot’s web server, so you can download the backup file by downloading http://192.168.1.1/mtd0_backup.bin from your PC.
Don’t forget to remove the mtd backup files from “/var/wwwroot” once you’ve grabbed it using your PC!
In order to make things easier/less prone to error, I’ve written a little script to backup all of the partitions to files in “/var/wwwroot/mtd_backup”. Once you run the script, you can then browse to “http://192.168.1.1/mtd_backup”, then right-click on each link and “Save Target As…” to save each file.
Here’s a link to an mtd_backup.sh, and here’s the contents of the script:
#! /bin/sh DESTDIR=/var/wwwroot/mtd_backup mkdir -p $DESTDIR echo "<HTML><body>" > $DESTDIR/index.html echo "<br>Right-click and 'Save Target As...' on all of the following:<br>" >> $DESTDIR/index.html let x=0 while [[ $x -le 10 ]] do if [[ -c /dev/mtd$x ]]; then echo "--- Backing up mtd$x ---" dd if=/dev/mtd$x of=$DESTDIR/mtd$x.bin if [[ $? -ne 0 ]]; then echo "=== ERROR backing up mtd$x! Check free space in $DESTDIR! ===" exit 1 fi echo "<br><br><A HREF=\"mtd$x.bin\">mtd$x.bin</A>" >> $DESTDIR/index.html fi let x=$x+1 done echo "</body></html>" >> $DESTDIR/index.html echo "=== Backup to $DESTDIR complete:" ls -l $DESTDIR/mtd*.bin
The script creates a backup directory (“/var/wwwroot/mtd_backup”), backs-up all of the “/dev/mtd#” device files, and in the process creates an “index.html” file in “/var/wwwroot/mtd_backup” (makes it easier to download the files from your PC).
Don’t forget to remove the mtd backup files from “/var/wwwroot/mtd_backup” once you’ve grabbed them using your PC!
A future article will give some tips on recovering a device by making use of these backup files.
Disclaimer: information on this site is for educational purposes only, and intended to help iSpot owners experiment with their own devices. I do not condone any hacking for illegal purposes, such as stealing service, etc.
Pingback: A closer look at flash memory partitions (with some insight on the firmware update process) | Hacking the iSpot