Flashing NAND from user-level

From Openlgtv
Jump to: navigation, search

Before you'll try to flash any partition make sure you know what it was used for, even if it look unused!
NAND flash and MTD partitions are managed differently than partitions on hard disk or USB stick.
It's really very easy to kill your TV!

We already know safe but slow method to write mtd's (loadz from u-boot).

I found very fast, but not very safe method. From linux shell.

This method already tested on LH3000, PK (Saturn 6 platform) and LE5500 (Broadcom platform).

/dev/mtdX is not read-only device. It's possible to write in it using "cat image >/dev/mtdX"

But before this, NAND must be erased.

For this I recompile flash_eraseall utility from mtd-utils-lg from MSTAR Saturn 7 opensource package: GP2_MSTAR_2.tar.gz.

Also flash_eraseall from LGMOD's busybox works fine on Saturn 6.

It was tested on rootfs (mtd3 on Saturn 6) partition.

  1. cat /dev/mtd3 > mtd3.pre
  2. flash_eraseall /dev/mtd3
  3. cat /dev/mtd3 > mtd3.erased
  4. cat rootfs.sqfs > /dev/mtd3
  5. cat /dev/mtd3 > mtd3.after
  6. reboot

Steps 1, 3, 5 is just for testing.

file mtd3.erased - full of 0xFF (erased). But system still works =)

mtd3.after equal to rootfs.sqfs

Package mtd-utils-lg also contain a lot of utils to work with NAND devices (nanddump, nandwrite, mtd_debug, sumtool, flash_info, flash_lock, flash_unlock). But LG modify and use on Saturn 7 only flash_eraseall.

I tried make a dump using nanddump, but dump contain every 0x100 bytes 16 bytes of checksum.

Any way - write to /dev/mtdX works. Just need to erase partition before.

Why I call this method not very safe? If you don't erase partition before writing you'll get ECC errors, but this can be fixed with flashing partition from u-boot using loadz.