Work around MEMERASE ioctl for rk3066 compatibility

Due to a kernel bug and no available sources we have to work around the
MEMERASE ioctl - if used, it hangs and never returns. I straced the original
recovery executable and could see that it is simply calling write() with a
bunch of zeroes instead of using MEMERASE.

Added a hack that does the same and now the resulting TWRP recovery image works.

Change-Id: I1b1c1c9e870e350776346bdca5d442c7ef565aa0
diff --git a/mtdutils/bml_over_mtd.c b/mtdutils/bml_over_mtd.c
index c401792..a68950e 100644
--- a/mtdutils/bml_over_mtd.c
+++ b/mtdutils/bml_over_mtd.c
@@ -31,6 +31,10 @@
 
 #include "mtdutils.h"
 
+#ifdef RK3066
+    #include "rk30hack.h"
+#endif
+
 typedef struct BmlOverMtdReadContext {
 	const MtdPartition *partition;
 	char *buffer;
@@ -518,11 +522,19 @@
 	erase_info.length = size;
 	int retry;
 	for (retry = 0; retry < 2; ++retry) {
+#ifdef RK3066
+		if (rk30_zero_out(fd, pos, size) < 0) {
+			fprintf(stderr, "mtd: erase failure at 0x%08lx (%s)\n",
+					pos, strerror(errno));
+			continue;
+		}
+#else
 		if (ioctl(fd, MEMERASE, &erase_info) < 0) {
 			fprintf(stderr, "mtd: erase failure at 0x%08lx (%s)\n",
 					pos, strerror(errno));
 			continue;
 		}
+#endif
 		if (lseek(fd, pos, SEEK_SET) != pos ||
 				write(fd, data, size) != size) {
 			fprintf(stderr, "mtd: write error at 0x%08lx (%s)\n",