- if (trx_check) {
- ret = trx_check(imagefd, mtd, buf, &buflen);
+
+ if (buflen < sizeof(magic)) {
+ buflen += read(imagefd, buf + buflen, sizeof(magic) - buflen);
+ if (buflen < sizeof(magic)) {
+ fprintf(stdout, "Could not get image magic\n");
+ return 0;
+ }
+ }
+ magic = ((uint32_t *)buf)[0];
+
+ if (be32_to_cpu(magic) == TRX_MAGIC)
+ imageformat = MTD_IMAGE_FORMAT_TRX;
+ else if (be32_to_cpu(magic) == SEAMA_MAGIC)
+ imageformat = MTD_IMAGE_FORMAT_SEAMA;
+
+ switch (imageformat) {
+ case MTD_IMAGE_FORMAT_TRX:
+ if (trx_check)
+ ret = trx_check(imagefd, mtd, buf, &buflen);
+ break;
+ case MTD_IMAGE_FORMAT_SEAMA:
+ break;
+ default:
+#ifdef target_brcm
+ if (!strcmp(mtd, "firmware"))
+ ret = 0;
+#endif
+ break;