aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/mtd/src/mtd.c
diff options
context:
space:
mode:
authorINAGAKI Hiroshi <musashino.open@gmail.com>2021-03-07 16:47:17 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2021-03-15 16:57:34 +0100
commitb5b0796a13223b56f1c2e13e2697c92dec22e9c2 (patch)
treef4a37b4d962f62829660206b2d5abad43d9d9942 /package/system/mtd/src/mtd.c
parent4d9f69322cdaaec10a8f37c67c772f5c3b21e841 (diff)
downloadupstream-b5b0796a13223b56f1c2e13e2697c92dec22e9c2.tar.gz
upstream-b5b0796a13223b56f1c2e13e2697c92dec22e9c2.tar.bz2
upstream-b5b0796a13223b56f1c2e13e2697c92dec22e9c2.zip
mtd: add option for TRX magic to fixtrx
Buffalo uses the TRX header with a different magic and even changes this magic with different devices. This change allows to specify the header to use as a command line argument. This is needed for the Buffalo WSR-2533DHP2 based on mt7622. Co-Developed-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
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);