Hi people, I have reprogramed sucessfully the filesystem and kernel in some units runing linux from nand flash with an aditional SD card and using the DD command and mtd-utils, but in others the filesystem does not start or have corrupted libraries, checking this units i have found bad blocks in the problematic units.
I have 3 partitions:
- Boot(2MB): containing bootstrap, uboot enviroment
- Kernel(2MB): containing kernel.
- Filesystem(250MB): containing the root filesystem
- Backup (2MB): an extra empty partition
1º) My process to reprogram the filesystem and kernel at once start reprograming a "mini filesystem" with mtd-utils and busybox (1,5MB) into the "Backup partition" using the DD command, change the uboot enviroment to boot loading the "Backup partition" as root filesystem and rebooting.
$ flash_eraseall /dev/mtd3
$ dd if=/mnt/minifs of=/dev/mtdblock3 bs=128k conv=noerror,notrunc
$ dd if=/mnt/backup_filesystem_enviroment of=/dev/mtdblock0 seek=3 bs=128k conv=sync
2º) When this "mini filesystem" starts it mount the SD card, then erase the "Filesystem partition" and copy the "new filesystem" using the DD command, then erase the "Kernel Partion" and copy the new kernel there and change the uboot enviromet to boot using the "Filesystem Partition"
$ flash_eraseall /dev/mtd2 > /dev/null
$ dd if=/mnt/newfs of=/dev/mtdblock2 bs=128k conv=noerror,notrunc
$ dd if=/mnt/ubootenv of=/dev/mtdblock0 seek=3 bs=128k conv=sync
$ flash_eraseall /dev/mtd1 > /dev/null
$ dd if=/mnt/newknernel of=/dev/mtdblock1 bs=128k conv=sync
This proces Works perfectly with flawless Nand Flash. But when it have Bad Blocks the root filesystem is mounted with some errors inside or some times cant be mounted.
I was using just conv=sync parameter of DD command, then i have tried conv=noerror but it only avoid read errors.
I have tried using nandwrite command, witch should avoid bad blocks writing, with -p (padding) option but it damage the file sytem.
Somebody knows a better way to do this process avoiding the badblocks writing the filesystem?