diff options
author | INAGAKI Hiroshi <musashino.open@gmail.com> | 2021-03-07 16:47:17 +0100 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2021-03-15 16:57:34 +0100 |
commit | b5b0796a13223b56f1c2e13e2697c92dec22e9c2 (patch) | |
tree | f4a37b4d962f62829660206b2d5abad43d9d9942 /package/system/mtd/src/trx.c | |
parent | 4d9f69322cdaaec10a8f37c67c772f5c3b21e841 (diff) | |
download | upstream-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/trx.c')
-rw-r--r-- | package/system/mtd/src/trx.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/package/system/mtd/src/trx.c b/package/system/mtd/src/trx.c index 3e3b5d220c..d7c5d832c4 100644 --- a/package/system/mtd/src/trx.c +++ b/package/system/mtd/src/trx.c @@ -35,7 +35,6 @@ #include "mtd.h" #include "crc32.h" -#define TRX_MAGIC 0x30524448 /* "HDR0" */ #define TRX_CRC32_DATA_OFFSET 12 /* First 12 bytes are not covered by CRC32 */ #define TRX_CRC32_DATA_SIZE 16 struct trx_header { @@ -92,7 +91,7 @@ trx_fixup(int fd, const char *name) } trx = ptr; - if (trx->magic != TRX_MAGIC) { + if (ntohl(trx->magic) != opt_trxmagic) { fprintf(stderr, "TRX header not found\n"); goto err; } @@ -127,7 +126,8 @@ trx_check(int imagefd, const char *mtd, char *buf, int *len) } } - if (trx->magic != TRX_MAGIC || trx->len < sizeof(struct trx_header)) { + if (ntohl(trx->magic) != opt_trxmagic || + trx->len < sizeof(struct trx_header)) { if (quiet < 2) { fprintf(stderr, "Bad trx header\n"); fprintf(stderr, "This is not the correct file format; refusing to flash.\n" @@ -200,7 +200,7 @@ mtd_fixtrx(const char *mtd, size_t offset, size_t data_size) } trx = (struct trx_header *)(first_block + offset); - if (trx->magic != STORE32_LE(0x30524448)) { + if (ntohl(trx->magic) != opt_trxmagic) { fprintf(stderr, "No trx magic found\n"); exit(1); } |