Raptor_Jesus
On Probation
I may have something. In the zip file with the heartbleed update, there is a file called EMMCBOOT.MBN. It shows more information about the write protection that is used:
A little google search on MMC_BOOT_US_PWR_WP_EN resulted in the page https://www.codeaurora.org/cgit/qui.../?id=e9f077b639b8878ba3aa2d832f2708d19e5d647d
Not sure if this is really it though, since this code also appears at https://code.google.com/p/moboot/so...708d19e5d647d&path=/platform/msm_shared/mmc.c and https://github.com/ilarrain/lk-thunderg/commit/e9f077b639b8878ba3aa2d832f2708d19e5d647d
mmcutils can be used to remove write protection. From https://github.com/Hashcode/mmc-utils I downloaded the code in a zip-file. Then I modified the Makefile to compile it for android; I believe only three lines needed to be changed:
If you can't compile it, get my compiled file from here (MD5 ebe3bb5d07f131de40579d0ae83bdefe). After running make, I got an executable 'mcc' that I copied to the ZTE valet via the sd card.
Note the value of USER_WP. A little Google search reveals that 0x10 corresponds to MMC_BOOT_US_PERM_WP_DIS, which means that permanent write protection for user area is not enabled. So, whatever it is, it is reversible. I thought this could fix it, but it does not work:
I think we need to issue a command CLR_WRITE_PROT (see here).
Code:
$ strings EMMCBOOT.MBN | grep -i mmc
mmc init failed!
Failure enabling MMC Clock!
Error No.:%d: Failure resetting MMC cards!
cmmc_structure: %d
Error No. %d: Failure Initializing MMC Card!
mmc_boot_main emmc gpio init start!
Initializing MMC host data structure and clock!
MMC Boot: Error Initializing MMC Card!!!
MMC Boot: Failed detecting MMC/SDC @ slot%d
mmc_boot_set_system_partition_power_on_wp : enable H/W reset function
ERROR : mmc_boot_get_card_status failed , val = %d
ERROR : mmc_enable_hw_reset failed
ERROR : mmc_set_erase_group_def failed
before setting MMC_BOOT_US_PWR_WP_EN: USER_WP[%d] = 0x%x
MMC_BOOT_EXT_US_PERM_WP_DIS is not disabled , disable it now
ERROR : disabling PERM_WP and enable MMC_BOOT_US_PWR_WP_EN for USER AREA failed
enable MMC_BOOT_US_PWR_WP_EN to apply power on write protection
ERROR : enable MMC_BOOT_US_PWR_WP_EN for USER AREA failed
ERROR : mmc_boot_get_card_status failed
ERROR : mmc_boot_send_ext_cmd failed
after setting MMC_BOOT_US_PWR_WP_EN: USER_WP[%d] = 0x%x
MMC_BOOT_EXT_ERASE_GROUP_DEF is defined
ERROR : mmc_boot_get_card_status failed
ERROR : mmc_boot_set_clr_power_on_wp_user failed , val = %d
mmc_boot_set_system_partition_power_on_wp : set ERASE_GROUP_DEF in extended CSD register
mmc_boot_set_system_partition_power_on_wp : apply eMMC power on write protection on system partition
Could not read partition from mmc
MBR written to mmc successfully
Failed to write MBR block to mmc.
GPT: Could not read primary gpt from mmc
GPT: Could not read backup gpt from mmc
GPT: mmc read card failed reading partition entries.
MMC Boot: MBR read failed!
MMC Boot: GPT read failed!
Failed to erase the eMMC card
androidboot.emmc=true
ERROR: Cannot set eMMC power on write protection on system partition
eMMC power on write protection applied on system partition successfully
error in emmc_recovery_init
mmc read failure %s %d
mmc write failure %s %d
So, we need to somehow send a CLEAR_WRITE_PROT.Enable write protection for eMMC partitions based on the write group protection availability in the card. Write group protection availablity is checked by reading CSD. If it is available, then write protect group size is calculated from EXT_CSD or CSD based on ERASE_GROUP_DEF. SET_WRITE_PROT is sent for the number of write protect groups to be protected. For e.g. if 10MB is to be protected from a starting sector and if write protect group size is 4MB, then 3 groups of 4MB i.e. 12MB from the starting sector will be write protected. For clearing user power-on write protect, CLEAR_WRITE_PROT is sent and it is similar to SET_WRITE_PROT.Note that the sector to be write and the size should be specified in sectors.
Not sure if this is really it though, since this code also appears at https://code.google.com/p/moboot/so...708d19e5d647d&path=/platform/msm_shared/mmc.c and https://github.com/ilarrain/lk-thunderg/commit/e9f077b639b8878ba3aa2d832f2708d19e5d647d
mmcutils can be used to remove write protection. From https://github.com/Hashcode/mmc-utils I downloaded the code in a zip-file. Then I modified the Makefile to compile it for android; I believe only three lines needed to be changed:
Code:
CC = arm-linux-gnueabi-gcc
CFLAGS ?= -static -O2 -march=armv5
CHECKFLAGS = -Wall -Wuninitialized -Wundef
Code:
/system # cp /mnt/sdcard/mmc /system/mmc
/system # chmod 700 mmc
/system # ./mmc writeprotect get /dev/block/mmcblk0p19
ioctl: Operation not permitted
Could not read EXT_CSD from /dev/block/mmcblk0p19
/system # ./mmc writeprotect get /dev/block/mmcblk0
Boot write protection status registers [BOOT_WP_STATUS]: 0x00
Boot Area Write protection [BOOT_WP]: 0x00
Power ro locking: possible
Permanent ro locking: possible
ro lock status: not locked
/system # ./mmc extcsd read /dev/block/mmcblk0 | grep WP
High-capacity W protect group size [HC_WP_GRP_SIZE: 0x08]
Boot write protection status registers [BOOT_WP_STATUS]: 0x00
Boot Area Write protection [BOOT_WP]: 0x00
User area write protection register [USER_WP]: 0x10
Code:
/system # ioctl /dev/block/mmcblk0 1 171 0
sending ioctl 0x1 0xab 0x00 0x00 0x00 0x00 0x00 0x00 0x00
ioctl 0x1 failed, -1