If BOARD_SUPPRESS_EMMC_WIPE is true, the EMMC wipe command will not be
issued. This works around a bug in some firmware revisions of Samsung EMMC's
that permanently damages the device when the wipe command is issued.
For affected devices with kernel source, MMC_CAP_ERASE should be removed
from the kernel instead.
This is only part of the solution but it does handle the "flashing CM9
for the first time on an unsafe kernel" situation.
Change-Id: Ie4e31f9268a65218e5d344ae3068b021790fc33c
libsparse \
libz
LOCAL_CFLAGS := -DREAL_UUID
+
+ifeq ($(BOARD_SUPPRESS_EMMC_WIPE),true)
+ LOCAL_CFLAGS += -DSUPPRESS_EMMC_WIPE
+endif
+
include $(BUILD_SHARED_LIBRARY)
libsparse_static \
libselinux \
libbase
+
+ifeq ($(BOARD_SUPPRESS_EMMC_WIPE),true)
+ LOCAL_CFLAGS += -DSUPPRESS_EMMC_WIPE
+endif
+
include $(BUILD_STATIC_LIBRARY)
int wipe_block_device(int fd, s64 len)
{
+#ifndef SUPPRESS_EMMC_WIPE
u64 range[2];
int ret;
range[1] = len;
ret = ioctl(fd, BLKSECDISCARD, &range);
if (ret < 0) {
-#endif
+#endif /* NO_SECURE_DISCARD */
range[0] = 0;
range[1] = len;
ret = ioctl(fd, BLKDISCARD, &range);
}
#ifndef NO_SECURE_DISCARD
}
-#endif
+#endif /* NO_SECURE_DISCARD */
return 0;
+#else
+ warn("Wipe via secure discard suppressed due to bug in EMMC firmware\n");
+ return 1;
+#endif /* SUPPRESS_EMMC_WIPE */
}
#else /* __linux__ */