From: Benjamin Larsson <[email protected]>
Signed-off-by: Benjamin Larsson <[email protected]> --- .../arch/mips/include/asm/mach-bcm63xx/bcm_tag.h | 3 +- tools/firmware-utils/src/imagetag.c | 34 +++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h b/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h index c06f668..f1e7c50 100644 --- a/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h +++ b/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h @@ -8,7 +8,7 @@ #define TAGVER_LEN 4 /* Length of Tag Version */ #define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */ -#define NUM_TAGID 5 +#define NUM_TAGID 6 #define IMAGETAG_CRC_START 0xFFFFFFFF struct tagiddesc_t { @@ -24,6 +24,7 @@ struct tagiddesc_t { { "ag306", "Alice Gate (Pirelli, based on Broadcom 3.06)" }, \ { "bc221", "Broadcom code version 2.21" }, \ { "bc310", "Broadcom code version 3.10-3.12" }, \ + { "bc412", "Broadcom code version 4.12" }, \ } struct bcm_tag_bccfe { diff --git a/tools/firmware-utils/src/imagetag.c b/tools/firmware-utils/src/imagetag.c index e93f5f4..9cbdaa4 100644 --- a/tools/firmware-utils/src/imagetag.c +++ b/tools/firmware-utils/src/imagetag.c @@ -225,7 +225,7 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, fflush(binfile); /* Choose and compute the CRC32 that should be inserted in the tag */ - if ( tagid && ( (strncmp(tagid, "bccfe", TAGID_LEN) == 0)) || ( strncmp(tagid, "bc300", TAGID_LEN) == 0)) { + if ( tagid && ( (strncmp(tagid, "bccfe", TAGID_LEN) == 0)) || ( strncmp(tagid, "bc300", TAGID_LEN) == 0) || ( strncmp(tagid, "bc412", TAGID_LEN) == 0)) { /* Compute the crc32 of the entire image (deadC0de included) */ imagecrc = compute_crc32(imagecrc, binfile, kerneloff - fwaddr, imagelen); } else if ( tagid && (strncmp(tagid, "ag306", TAGID_LEN) == 0)) { @@ -286,6 +286,38 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, int2tag(tag.bccfe.tagIdCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&(tag.bccfe.tagId[0]), TAGID_LEN)); int2tag(tag.bccfe.imageCRC, imagecrc); int2tag(tag.bccfe.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20)); + } else if ( tagid && (strcmp(tagid, "bc412") == 0)) { + /* Build the tag */ + strncpy(tag.bccfe.tagVersion, ver, TAGVER_LEN); + strncpy(tag.bccfe.sig_1, IMAGETAG_MAGIC1, sizeof(tag.bccfe.sig_1) - 1); + strncpy(tag.bccfe.sig_2, magic2, sizeof(tag.bccfe.sig_2) - 1); + strcpy(tag.bccfe.chipid, chipid); + strcpy(tag.bccfe.boardid, boardid); + strcpy(tag.bccfe.big_endian, "1"); + sprintf(tag.bccfe.totalLength, "%lu", imagelen); + + /* We don't include CFE */ + strcpy(tag.bccfe.cfeAddress, "0"); + strcpy(tag.bccfe.cfeLength, "0"); + + /* The kernel is located after the CFE+nvram+scratchpad area, usually the first + * block of the flash. And then there is the image tag. */ + if (kernelfile) { + sprintf(tag.bccfe.kernelAddress, "%lu", fwaddr+sizeof(tag)); + sprintf(tag.bccfe.kernelLength, "%lu", kernellen + rootfsoffpadlen); + } + + /* CFE flashes the firmware starting at rootAddress - tag_size */ + if (rootfsfile) { + sprintf(tag.bccfe.rootAddress, "%lu", fwaddr+sizeof(tag)); + sprintf(tag.bccfe.rootLength, "%lu", rootfslen); + } + + strncpy(tag.bccfe.tagId, "bccfe", TAGID_LEN); + + int2tag(tag.bccfe.tagIdCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&(tag.bccfe.tagId[0]), TAGID_LEN)); + int2tag(tag.bccfe.imageCRC, imagecrc); + int2tag(tag.bccfe.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20)); } else if ( tagid && (strcmp(tagid, "bc300") == 0)) { /* Build the tag */ strncpy(tag.bc300.tagVersion, ver, TAGVER_LEN); -- 1.7.1 _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
