summaryrefslogtreecommitdiffstats
path: root/mtdutils/mtdutils.c
diff options
context:
space:
mode:
authorSergey 'Jin' Bostandzhyan <jin@mediatomb.cc>2013-01-04 02:29:03 +0100
committerSergey 'Jin' Bostandzhyan <jin@mediatomb.cc>2013-01-05 00:23:06 +0100
commit80a90edd47d20141cfb7b18ededc9a3090fba58c (patch)
tree024a118fbcbc357158b74862e3381b265076a9b5 /mtdutils/mtdutils.c
parentIncrease array size to fix crashes on some devices (diff)
downloadandroid_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.tar
android_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.tar.gz
android_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.tar.bz2
android_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.tar.lz
android_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.tar.xz
android_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.tar.zst
android_bootable_recovery-80a90edd47d20141cfb7b18ededc9a3090fba58c.zip
Diffstat (limited to '')
-rw-r--r--mtdutils/mtdutils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c
index a76b8e992..032b04bac 100644
--- a/mtdutils/mtdutils.c
+++ b/mtdutils/mtdutils.c
@@ -28,6 +28,10 @@
#include "mtdutils.h"
+#ifdef RK3066
+ #include "rk30hack.h"
+#endif
+
struct MtdReadContext {
const MtdPartition *partition;
char *buffer;
@@ -423,11 +427,19 @@ static int write_block(MtdWriteContext *ctx, const char *data)
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",
@@ -457,7 +469,11 @@ static int write_block(MtdWriteContext *ctx, const char *data)
// Try to erase it once more as we give up on this block
add_bad_block_offset(ctx, pos);
fprintf(stderr, "mtd: skipping write block at 0x%08lx\n", pos);
+#ifdef RK3066
+ rk30_zero_out(fd, pos, size);
+#else
ioctl(fd, MEMERASE, &erase_info);
+#endif
pos += partition->erase_size;
}
@@ -527,9 +543,15 @@ off_t mtd_erase_blocks(MtdWriteContext *ctx, int blocks)
struct erase_info_user erase_info;
erase_info.start = pos;
erase_info.length = ctx->partition->erase_size;
+#ifdef RK3066
+ if (rk30_zero_out(ctx->fd, pos, ctx->partition->erase_size) < 0) {
+ fprintf(stderr, "mtd: erase failure at 0x%08lx\n", pos);
+ }
+#else
if (ioctl(ctx->fd, MEMERASE, &erase_info) < 0) {
fprintf(stderr, "mtd: erase failure at 0x%08lx\n", pos);
}
+#endif
pos += ctx->partition->erase_size;
}