+ if ( tagid && (strcmp(tagid, "bccfe") == 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");
+
+ if (kernelfile) {
+ sprintf(tag.bccfe.kernelAddress, "%lu", kerneloff);
+ sprintf(tag.bccfe.kernelLength, "%lu", kernellen + rootfsoffpadlen);
+ }
+
+ if (rootfsfile) {
+ sprintf(tag.bccfe.rootAddress, "%lu", rootfsoff);
+ 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);
+ strncpy(tag.bc300.sig_1, IMAGETAG_MAGIC1, sizeof(tag.bc300.sig_1) - 1);
+ strncpy(tag.bc300.sig_2, magic2, sizeof(tag.bc300.sig_2) - 1);
+ strcpy(tag.bc300.chipid, chipid);
+ strcpy(tag.bc300.boardid, boardid);
+ strcpy(tag.bc300.big_endian, "1");
+ sprintf(tag.bc300.totalLength, "%lu", imagelen);
+
+ /* We don't include CFE */
+ strcpy(tag.bc300.cfeAddress, "0");
+ strcpy(tag.bc300.cfeLength, "0");
+
+ if (kernelfile) {
+ sprintf(tag.bc300.kernelAddress, "%lu", kerneloff);
+ sprintf(tag.bc300.kernelLength, "%lu", kernellen + rootfsoffpadlen);
+ }
+
+ if (rootfsfile) {
+ sprintf(tag.bc300.flashImageStart, "%lu", kerneloff);
+ sprintf(tag.bc300.flashRootLength, "%lu", rootfslen + sizeof(deadcode));
+ sprintf(tag.bc300.rootAddress, "%lu", rootfsoff);
+ sprintf(tag.bc300.rootLength, "%lu", rootfslen);
+ }
+
+ strncpy(tag.bc300.tagId, "bc300", TAGID_LEN);
+
+ int2tag(tag.bc300.tagIdCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&(tag.bc300.tagId[0]), TAGID_LEN));
+ int2tag(tag.bc300.imageCRC, imagecrc);
+ int2tag(tag.bc300.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20));
+ } else if ( tagid && (strcmp(tagid, "ag306") == 0)) {
+ /* Build the tag */
+ strncpy(tag.ag306.tagVersion, ver, TAGVER_LEN);
+ strncpy(tag.ag306.sig_1, IMAGETAG_MAGIC1, sizeof(tag.ag306.sig_1) - 1);
+ strncpy(tag.ag306.sig_2, magic2, sizeof(tag.ag306.sig_2) - 1);
+ strcpy(tag.ag306.chipid, chipid);
+ strcpy(tag.ag306.boardid, boardid);
+ strcpy(tag.ag306.big_endian, "1");
+ sprintf(tag.ag306.totalLength, "%lu", imagelen);
+
+ /* We don't include CFE */
+ strcpy(tag.ag306.cfeAddress, "0");
+ strcpy(tag.ag306.cfeLength, "0");
+
+ if (kernelfile) {
+ sprintf(tag.ag306.kernelAddress, "%lu", kerneloff);
+ sprintf(tag.ag306.kernelLength, "%lu", kernellen + rootfsoffpadlen);
+ }
+
+ if (rootfsfile) {
+ sprintf(tag.ag306.flashImageStart, "%lu", kerneloff);
+ sprintf(tag.ag306.flashRootLength, "%lu", rootfslen + sizeof(deadcode));
+ sprintf(tag.ag306.rootAddress, "%lu", rootfsoff);
+ sprintf(tag.ag306.rootLength, "%lu", rootfslen);
+ }
+
+ strncpy(tag.ag306.tagId, "ag306", TAGID_LEN);
+
+ int2tag(tag.ag306.tagIdCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&(tag.ag306.tagId[0]), TAGID_LEN));
+ int2tag(tag.ag306.kernelCRC, kernelcrc);
+ int2tag(tag.ag306.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20));
+ } else if ( tagid && (strcmp(tagid, "bc221") == 0)) {
+ /* Build the tag */
+ strncpy(tag.bc221.tagVersion, ver, TAGVER_LEN);
+ strncpy(tag.bc221.sig_1, IMAGETAG_MAGIC1, sizeof(tag.bc221.sig_1) - 1);
+ strncpy(tag.bc221.sig_2, magic2, sizeof(tag.bc221.sig_2) - 1);
+ strcpy(tag.bc221.chipid, chipid);
+ strcpy(tag.bc221.boardid, boardid);
+ strcpy(tag.bc221.big_endian, "1");
+ sprintf(tag.bc221.totalLength, "%lu", imagelen);
+
+ /* We don't include CFE */
+ strcpy(tag.bc221.cfeAddress, "0");
+ strcpy(tag.bc221.cfeLength, "0");
+
+ if (kernelfile) {
+ sprintf(tag.bc221.kernelAddress, "%lu", kerneloff);
+ sprintf(tag.bc221.kernelLength, "%lu", kernellen + rootfsoffpadlen);
+ }
+
+ if (rootfsfile) {
+ sprintf(tag.bc221.flashImageStart, "%lu", kerneloff);
+ sprintf(tag.bc221.flashRootLength, "%lu", rootfslen + sizeof(deadcode));
+ sprintf(tag.bc221.rootAddress, "%lu", rootfsoff);
+ sprintf(tag.bc221.rootLength, "%lu", rootfslen);
+ }
+
+ strncpy(tag.bc221.tagId, "bc221", TAGID_LEN);
+ if (layoutver) {
+ strncpy(tag.bc221.flashLayoutVer, layoutver, TAGLAYOUT_LEN);
+ }
+
+ int2tag(tag.bc221.tagIdCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&(tag.bc221.tagId[0]), TAGID_LEN));
+ int2tag(tag.bc221.imageCRC, imagecrc);
+ int2tag(tag.bc221.fskernelCRC, kernelfscrc);
+ int2tag(tag.bc221.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20));
+ } else if ( tagid && (strcmp(tagid, "bc310") == 0)) {
+ /* Build the tag */
+ strncpy(tag.bc310.tagVersion, ver, TAGVER_LEN);
+ strncpy(tag.bc310.sig_1, IMAGETAG_MAGIC1, sizeof(tag.bc310.sig_1) - 1);
+ strncpy(tag.bc310.sig_2, magic2, sizeof(tag.bc310.sig_2) - 1);
+ strcpy(tag.bc310.chipid, chipid);
+ strcpy(tag.bc310.boardid, boardid);
+ strcpy(tag.bc310.big_endian, "1");
+ sprintf(tag.bc310.totalLength, "%lu", imagelen);
+
+ /* We don't include CFE */
+ strcpy(tag.bc310.cfeAddress, "0");
+ strcpy(tag.bc310.cfeLength, "0");
+
+ if (kernelfile) {
+ sprintf(tag.bc310.kernelAddress, "%lu", kerneloff);
+ sprintf(tag.bc310.kernelLength, "%lu", kernellen + rootfsoffpadlen);
+ }
+
+ if (rootfsfile) {
+ sprintf(tag.bc310.flashImageStart, "%lu", kerneloff);
+ sprintf(tag.bc310.flashRootLength, "%lu", rootfslen + sizeof(deadcode));
+ sprintf(tag.bc310.rootAddress, "%lu", rootfsoff);
+ sprintf(tag.bc310.rootLength, "%lu", rootfslen);
+ }
+
+ strncpy(tag.bc310.tagId, "bc310", TAGID_LEN);
+ if (information) {
+ strncpy(tag.bc310.information1, information, TAGINFO_LEN);
+ }
+
+ int2tag(tag.bc310.tagIdCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&(tag.bc310.tagId[0]), TAGID_LEN));
+ int2tag(tag.bc310.imageCRC, imagecrc);
+ int2tag(tag.bc310.kernelCRC, kernelcrc);
+ int2tag(tag.bc310.rootfsCRC, rootfscrc);
+ int2tag(tag.bc310.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20));