August 14, 2020, 01:43:32 am

News:

Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/


How to screw up A10 NAND and recover it

Started by ikeeki, July 24, 2013, 06:44:35 pm

Previous topic - Next topic

ikeeki

July 24, 2013, 06:44:35 pm Last Edit: January 03, 2014, 08:55:21 am by admin
How to screw up Cubie A10 NAND and recover it.

A Brick the NAND:

Boot from sdcard.
Open gparted and resize NANDB, NANDA or NAND from there.
or
download Twightlight on desktop, then type in terminal:
dd if=/home/linaro/Desktop/Twightlight of=/dev/nand bs=512.

_______________________________________



B Recover the nand and make it suitable to be flashed with Phoenixcard.


Download:

http://dl.cubieforums.com/loz/boot_partition/bootloader/cubie_nand_uboot_partition_image.bin

cd it and type:

dd if=/path/cubie_nand_uboot_partition_image.bin of=/dev/nand

sync

Type:

sudo su
git clone git://github.com/linux-sunxi/sunxi-tools
cd sunxi-tools
make clean
make


Download

https://groups.google.com/group/linux-sunxi/attach/ac7942ae161ac07e/nand-part2.tar?part=4&authuser=0


Uncompress it into /path/sunxi-tools, cd it and type:

gcc -I include nand-part2.c

./a.out /dev/nand 16 "boot 4096" "linux 6500000" "swap 0"


Now you can flash by Phoenix card procedure


Please tell me if any errors.

Thanks to Patwood (as always)

patwood

July 24, 2013, 10:13:38 pm #1 Last Edit: July 28, 2013, 10:29:55 pm by patwood
Quote from: ikeeki on July 24, 2013, 06:44:35 pm
How to screw up Cubie A10 NAND and recover it.

A Brick the NAND:

Boot from sdcard.
Open gparted and resize NANDB, NANDA or NAND from there.
or
download Twightligh on desktop, then type in terminal:
dd if=/home/linaro/Desktop/Twightlight of=/dev/nand bs=512.

Just two of many ways my friend :)  fdisk is also a good bet for trashing the nand.  This is probably why the standard Android kernel from Allwinner doesn't expose /dev/nand in any way; then the only way to repartition the nand is with a special tool like livesuit or phoenixcard.  Good protection for newbies, major pain for those of us who want to hack the device.

One more time for anyone thinking about repartitioning their on-board nand: the partition layout is a custom Allwinner format that is not compatible with any normal linux tool, including fdisk, sfdisk, parted, gparted, and so on, so don't try to use them!  Use nand-part; it was specifically designed for the Allwinner nand partition layout.

There is now an update to the nand-part tool in https://github.com/linux-sunxi/sunxi-tools; it allows you to force a partition layout to /dev/nand, even if the various checksums and magic fields are trashed.  It also performs the same function as nand-part2, allowing you to overwrite the starting offset and size of the first (boot) partition, while retaining compatibility with the command-line syntax of the original nand-part (if the first "partition" argument is a number instead of "name size", it switches to the nand-part2 behavior).

This means you don't have to dd a boot partition .img to /dev/nand before running nand-part to recover, and you don't have to bother with downloading and compiling nand-part2.c.  See http://www.cubieforums.com/index.php/topic,541.0.html for details, or you can simply download my current version which handles both A10 and A20 partition headers in the same executable: http://dl.cubieforums.com/patwood/nand-part.  Here are examples:

./nand-part -f a10 /dev/nand 16 "boot 4096" "linux 6500000" "swap 0"

or
./nand-part -f a20 /dev/nand 16 "boot 4096" "linux 6500000" "swap 0"

depending on your board version.  It'll complain about bad headers and such and ask you if you're sure, but entering y will force an overwrite.  Be careful! Overwriting an A20 nand with an A10 partition layout (or vice versa) will trash your nand just as effectively as fdisk or gparted!  (But at least you have a tool now for recovery :D)

diogoc

Changing the partition layout brick the nand? But flashing a livesuit image don't restore all including the partition layout?

ikeeki

I firstly tried phoenix card when I changed partitions, but no luck. The diferent outputs I had can be checked in http://www.cubieforums.com/index.php/topic,527.0.html

diogoc

hum.. I modified a livesuit image to enlarge the nandd partition and then after flashing it with livesuit I confirmed the new partition size. So I think livesuit format all nand partitions and create the new.

ikeeki

OK, I'll brick the NAND in the way I did and try livesuit (never tried, to be honest).

The way you point out seems easier, and deserves to be an option (if not the first), thanks for the tip.