aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/mtd/src/mtd.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/system/mtd/src/mtd.c')
-rw-r--r--package/system/mtd/src/mtd.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
index 9baed3fd5e..fc7071d940 100644
--- a/package/system/mtd/src/mtd.c
+++ b/package/system/mtd/src/mtd.c
@@ -94,6 +94,7 @@ int mtdsize = 0;
int erasesize = 0;
int jffs2_skip_bytes=0;
int mtdtype = 0;
+uint32_t opt_trxmagic = TRX_MAGIC;
int mtd_open(const char *mtd, bool block)
{
@@ -205,7 +206,7 @@ image_check(int imagefd, const char *mtd)
magic = ((uint32_t *)buf)[0];
- if (be32_to_cpu(magic) == TRX_MAGIC)
+ if (be32_to_cpu(magic) == opt_trxmagic)
imageformat = MTD_IMAGE_FORMAT_TRX;
else if (be32_to_cpu(magic) == SEAMA_MAGIC)
imageformat = MTD_IMAGE_FORMAT_SEAMA;
@@ -810,6 +811,7 @@ static void usage(void)
" -l <length> the length of data that we want to dump\n");
if (mtd_fixtrx) {
fprintf(stderr,
+ " -M <magic> magic number of the image header in the partition (for fixtrx)\n"
" -o offset offset of the image header in the partition(for fixtrx)\n");
}
if (mtd_fixtrx || mtd_fixseama || mtd_fixwrg || mtd_fixwrgg) {
@@ -877,7 +879,7 @@ int main (int argc, char **argv)
#ifdef FIS_SUPPORT
"F:"
#endif
- "frnqe:d:s:j:p:o:c:t:l:")) != -1)
+ "frnqe:d:s:j:p:o:c:t:l:M:")) != -1)
switch (ch) {
case 'f':
force = 1;
@@ -929,6 +931,14 @@ int main (int argc, char **argv)
usage();
}
break;
+ case 'M':
+ errno = 0;
+ opt_trxmagic = strtoul(optarg, 0, 0);
+ if (errno) {
+ fprintf(stderr, "-M: illegal numeric string\n");
+ usage();
+ }
+ break;
case 'o':
errno = 0;
offset = strtoul(optarg, 0, 0);