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)
{
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;
" -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) {
#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;
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);
extern int quiet;
extern int mtdsize;
extern int erasesize;
+extern uint32_t opt_trxmagic;
extern int mtd_open(const char *mtd, bool block);
extern int mtd_check_open(const char *mtd);
#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 {
}
trx = ptr;
- if (trx->magic != TRX_MAGIC) {
+ if (ntohl(trx->magic) != opt_trxmagic) {
fprintf(stderr, "TRX header not found\n");
goto err;
}
}
}
- 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"
}
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);
}