[Galaxy S II Android Development] Phil3759:
<<< Built for the i9100 in mind, but fine on any Samsung phone >>>

<<< check your mount points before using this on another phone >>>

<<< Backup, Backaup and Backup your Data >>>

<<< Never use it on a non Samsung Phone >>>

<<< Read before flash, you are warned >>>

​

Update 08.10.2012:

Since the superbrick bug story on 4.0.4 firmwares for the i9100 and the Note, wiping and factory reset became a tragedy for many.

many users in N7000 forum asked me for these scripts. Here are they!

shoey63 took my attention to a discussion by Entropy512, Elite Recognized Developer who contributed to a better knowledge of the superbrick bug.

I quote him here:

To sum it:

- wipe / factory reset from CWM is extremely risky on broken chipsets and vulnerable kernels

- wipe / factory reset in stock recovery is not without risks, even if probably less

- delete operations, even on big data packets is safe

So, here comes the idea: build some wipe scripts that can run in recovery (be it stock recovery or CWM) to complete the wipe operations using safe delete command to avoid brick risks on these affected phones

I attach these scripts to just run in recovery (will work in stock recovery)

Here's the edify code used, for teach purpose (in v2.0, delete_recursive is now replaced by format commands)

ui_print("***************************");
ui_print("Wipe data-cache-system");
ui_print("Samsung Phones Only");
ui_print("***************************");
show_progress(1.000000, 0);

ui_print("Checking Samsung Phone...");
assert(getprop("ro.product.manufacturer") == "samsung");
set_progress(0.100000);

ui_print("Mounting partitions");
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p7", "/cache");
mount("ext4", "EMMC", "/dev/block/mmcblk0p10", "/data");
set_progress(0.200000);

ui_print("Delete Cache Partition");
delete_recursive("/cache");
set_progress(0.400000);

ui_print("Delete Data Partition");
delete_recursive("/data");
set_progress(0.600000);

ui_print("Delete System Partition");
delete_recursive("/system");
set_progress(0.900000);

###############################################################################
############################ Formatting partitions ############################
#### You need to unmount (ALL?) partitions before formatting one partition ####
# unmount("/cache");
# unmount("/data");
# unmount("/system");
# format("ext4", "EMMC", "/dev/block/mmcblk0p9", "0");

#### Then remount if you intend to use it later in teh script ####
# mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
# mount("ext4", "EMMC", "/dev/block/mmcblk0p7", "/cache");
# mount("ext4", "EMMC", "/dev/block/mmcblk0p10", "/data");

#### wipe dalvik-cache ####
# mount("ext4", "EMMC", "/dev/block/mmcblk0p10", "/data");
# delete_recursive("/data/dalvik-cache");
# unmount("/data");
#### wipe dalvik-cache done ####

#### Mount in busybox ####
# run_program("/sbin/mount", "/dev/block/mmcblk0p7", "/cache");
# run_program("/sbin/mount", "/dev/block/mmcblk0p10", "/data");
# run_program("/sbin/mount", "/dev/block/mmcblk0p9", "/system");
#### internal sd ####
# run_program("/sbin/mount", "/dev/block/mmcblk0p11", "/sdcard");
###############################################################################

ui_print("Unmounting Partitions");
unmount("/cache");
unmount("/data");
unmount("/system");
set_progress(1.000000);
show_progress(1.000000, 0);

ui_print("Wipe complete!");
ui_print("Reboot in download mode");
ui_print("Flash a full ROM in Odin");
ui_print("by Phil3759@xda-developers.com");