Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
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, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12

    Unhappy 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.

    Code:
    $ 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
    $ reboot
    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"

    Code:
    $ 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 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?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    Unfortunately, nand flash memory has a limited number of write cycles per sector, about 10,000 max. Newer systems/controllers are able to wear-level the devices by moving written sectors behind the scenes so that a single sector won't be written to excessively, at least for awhile. However, if your device does a lot of file output, you may just have to replace the flash with a new one. In any case, nand flash should ONLY be used for read-mostly applications. Assuming this is an embedded system, you might be better off if files that have to be written to extensively are kept in RAM disc and only written back to the nand flash store at intervals if you need to preserve the data.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12

    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.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    How old are these units, and what do they do?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #5
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12
    Its just display some pictures and videos stored in a sd card. I have checked some of this and there ware just 10 bad blocks of 0x20000 bytes each one in a 256MB nand flash.

    About one year running.
    Last edited by lucasct; 07-29-2011 at 04:05 PM. Reason: additional info

  7. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    Can you run fsck with the -c (check for and map out bad blocks) option? You may have to remount the drive read-only first assuming it is already mounted before you can run fsck on it. If you can, then the blocks will be mapped out at the file system level.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #7
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12
    I just need some way to make my process to write the kernel and filesystem like the software used from PC do. It is skip the bad blocks witing the block in the next.

    Original File: Block1 - Block2 - Block3

    NAND: GoodBlock - BadBlock - GoodBlock - GoodBlock

    Expected Result: Block1 - NULLBlock - Block2 - Block3

    The nandwrite function did it ok with a little file, but when I reprogram the whole filesystem it give a lot of fails. comparing the finaries it is very diferent, it don't just skip blocks.

  9. #8
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12
    I can use that function, I will make the first step of my process to install the backup filesystem and check the main partition.

  10. #9
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12
    I have tried to use FSCK with this results.

    Executing it without arguments it has tried to check "/dev/root"
    Code:
    # fsck
    fsck (busybox 1.16.0, 2010-08-25 16:35:42 ART)
    e2fsck 1.41.9 (22-Aug-2009)
    /dev/root is mounted.
    
    WARNING!!!  Running e2fsck on a mounted filesystem may cause
    SEVERE filesystem damage.
    
    Do you really want to continue (y/n)? no
    
    check aborted.
    #
    I can't umount the root filesystem to check it. If I made it Read Only from mount table I think I will can't change it again (it is in the same partition).



    Then I have reprogramed my mini filesystem in the backup partition and tried to use FSCK mounting that partition as read only.
    Code:
    # mount -t jffs2 /dev/mtdblock3 /mnt -o ro
    # cd /mnt
    # ls
    bin      dev      lib      opt      sbin     usr
    boot     etc      linuxrc  proc     sys      var
    config   home     mnt      root     tmp
    
    # echo 1 > testreadonly
    -sh: can't create hola: Read-only file system
    # ls
    bin      dev      lib      opt      sbin     usr
    boot     etc      linuxrc  proc     sys      var
    config   home     mnt      root     tmp
    # cd ..
    
    # fsck /mnt
    fsck (busybox 1.16.0, 2010-08-25 16:35:42 ART)
    fsck: fsck.auto: No such file or directory
    
    # fsck /dev/mtdblock3
    fsck (busybox 1.16.0, 2010-08-25 16:35:42 ART)
    fsck: fsck.auto: No such file or directory
    #
    What is my mistake?

  11. #10
    Just Joined!
    Join Date
    Jul 2011
    Posts
    12
    any other test?

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •