Changing Filesystem and Kernel - Problem with Bad Blocks NandFlash
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 4 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.
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/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
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.
$ 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
I was using just sync in conv parameter of DD command, then i have tried 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?
I Still need to reprogram this units at least once
Thanks for you answer.
I know that bad blocks will keep appearing. But anyway I need to change the actual filesystem an kernel at least once, this units are installed so far away from my location, that is why I can't reprograming this units by usb port (Using SAMBA, SAM boot assistant for ARM microcontrolers, which can write files directly to NandFlash skiping the bad blocks).
I am sending via FTP the files and a script that is executed doing the process detailed before.