rework imagetag firmware generator and MTD partition parser to accomodate with all known imagetag versions from Broadcom and vendors, patch from Daniel Dickinson (fixes#4987).
#define ADDRESS_LEN 12 /* Length of Address field */
#define TAGID_LEN 6 /* Length of tag ID */
#define TAGINFO_LEN 20 /* Length of vendor information field in tag */
#define TAGVER_LEN 4 /* Length of Tag Version */
structbcm_tag{
unsignedchartagVersion[4];// Version of the image tag
unsignedcharsig_1[20];// Company Line 1
unsignedcharsig_2[14];// Company Line 2
unsignedcharchipid[6];// Chip this image is for
unsignedcharboardid[16];// Board name
unsignedcharbig_endian[2];// Map endianness -- 1 BE 0 LE
unsignedchartotalLength[IMAGE_LEN];//Total length of image
unsignedcharcfeAddress[ADDRESS_LEN];// Address in memory of CFE
unsignedcharcfeLength[IMAGE_LEN];// Size of CFE
unsignedcharcfeRootAddress[ADDRESS_LEN];// Address in memory of rootfs
unsignedcharcfeRootLength[IMAGE_LEN];// Size of rootfs
unsignedcharkernelAddress[ADDRESS_LEN];// Address in memory of kernel
unsignedcharkernelLength[IMAGE_LEN];// Size of kernel
unsignedchardualImage[2];// Unused at present
unsignedcharinactiveFlag[2];// Unused at present
unsignedcharreserved1[74];// Reserved area not in use
unsignedcharimageCRC[4];// CRC32 of images
// unsigned char reserved2[16]; // Unused at present
unsignedcharreserved2[4];//Unused
unsignedcharrootAddress[ADDRESS_LEN];// Address in memory of rootfs
unsignedcharheaderCRC[4];// CRC32 of header excluding tagVersion
// unsigned char reserved3[16]; // Unused at present
unsignedcharreserved3[6];// Unused at present
unsignedcharrootLength[IMAGE_LEN];// Size of rootfs
#define NUM_TAGID 5
#define IMAGETAG_CRC_START 0xFFFFFFFF
structtagiddesc_t{
chartagid[TAGID_LEN+1];
chartagiddesc[80];
};
// what is called bc308 may actually be BT Voyager-specific
// bc310 should be right
#define TAGID_DEFINITIONS { \
{"bccfe","Broadcom CFE flash image"}, \
{"bc300","Broadcom code version 3.00-3.06 and all ftp/tftp flash"}, \
{"ag306","Alice Gate (Pirelli, based on Broadcom 3.06)"}, \
{"bc308","Broadcom code version 3.08"}, \
{"bc310","Broadcom code version 3.10-3.12"}, \
}
structbcm_tag_bccfe{
unsignedchartagVersion[TAGVER_LEN];// 0-3: Version of the image tag
unsignedcharsig_1[20];// 4-23: Company Line 1
unsignedcharsig_2[14];// 24-37: Company Line 2
unsignedcharchipid[6];// 38-43: Chip this image is for
unsignedcharboardid[16];// 44-59: Board name
unsignedcharbig_endian[2];// 60-61: Map endianness -- 1 BE 0 LE
unsignedchartotalLength[IMAGE_LEN];// 62-71: Total length of image
unsignedcharcfeAddress[ADDRESS_LEN];// 72-83: Address in memory of CFE
unsignedcharcfeLength[IMAGE_LEN];// 84-93: Size of CFE
unsignedcharrootAddress[ADDRESS_LEN];// 94-105: Address in memory of rootfs
unsignedcharrootLength[IMAGE_LEN];// 106-115: Size of rootfs
unsignedcharkernelAddress[ADDRESS_LEN];// 116-127: Address in memory of kernel
unsignedcharkernelLength[IMAGE_LEN];// 128-137: Size of kernel
unsignedchardualImage[2];// 138-139: Unused at present
unsignedcharinactiveFlag[2];// 140-141: Unused at present
unsignedcharinformation1[TAGINFO_LEN];// 142-161: Unused at present
unsignedchartagId[TAGID_LEN];// 162-167: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
unsignedchartagIdCRC[4];// 168-171: CRC32 of tagId
unsignedcharreserved1[44];// 172-215: Reserved area not in use
unsignedcharimageCRC[4];// 216-219: CRC32 of images
unsignedcharreserved2[16];// 220-235: Unused at present
unsignedcharheaderCRC[4];// 236-239: CRC32 of header excluding tagVersion
unsignedcharreserved3[16];// 240-255: Unused at present
};
structbcm_tag_bc300{
unsignedchartagVersion[4];// 0-3: Version of the image tag
unsignedcharsig_1[20];// 4-23: Company Line 1
unsignedcharsig_2[14];// 24-37: Company Line 2
unsignedcharchipid[6];// 38-43: Chip this image is for
unsignedcharboardid[16];// 44-59: Board name
unsignedcharbig_endian[2];// 60-61: Map endianness -- 1 BE 0 LE
unsignedchartotalLength[IMAGE_LEN];// 62-71: Total length of image
unsignedcharcfeAddress[ADDRESS_LEN];// 72-83: Address in memory of CFE
unsignedcharcfeLength[IMAGE_LEN];// 84-93: Size of CFE
unsignedcharflashImageStart[ADDRESS_LEN];// 94-105: Address in memory of kernel (start of image)
unsignedcharflashRootLength[IMAGE_LEN];// 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
unsignedcharkernelAddress[ADDRESS_LEN];// 116-127: Address in memory of kernel
unsignedcharkernelLength[IMAGE_LEN];// 128-137: Size of kernel
unsignedchardualImage[2];// 138-139: Unused at present
unsignedcharinactiveFlag[2];// 140-141: Unused at present
unsignedcharinformation1[TAGINFO_LEN];// 142-161: Unused at present
unsignedchartagId[TAGID_LEN];// 162-167: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
unsignedchartagIdCRC[4];// 168-173: CRC32 to ensure validity of tagId
unsignedcharrootAddress[ADDRESS_LEN];// 174-183: Address in memory of rootfs partition
unsignedcharrootLength[IMAGE_LEN];// 184-193: Size of rootfs partition
unsignedcharreserved1[22];// 194-215: Reserved area not in use
unsignedcharimageCRC[4];// 216-219: CRC32 of images
unsignedcharreserved2[16];// 220-235: Unused at present
unsignedcharheaderCRC[4];// 236-239: CRC32 of header excluding tagVersion
unsignedcharreserved3[16];// 240-255: Unused at present
};
structbcm_tag_ag306{
unsignedchartagVersion[4];// 0-3: Version of the image tag
unsignedcharsig_1[20];// 4-23: Company Line 1
unsignedcharsig_2[14];// 24-37: Company Line 2
unsignedcharchipid[6];// 38-43: Chip this image is for
unsignedcharboardid[16];// 44-59: Board name
unsignedcharbig_endian[2];// 60-61: Map endianness -- 1 BE 0 LE
unsignedchartotalLength[IMAGE_LEN];// 62-71: Total length of image
unsignedcharcfeAddress[ADDRESS_LEN];// 72-83: Address in memory of CFE
unsignedcharcfeLength[IMAGE_LEN];// 84-93: Size of CFE
unsignedcharflashImageStart[ADDRESS_LEN];// 94-105: Address in memory of kernel (start of image)
unsignedcharflashRootLength[IMAGE_LEN];// 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
unsignedcharkernelAddress[ADDRESS_LEN];// 116-127: Address in memory of kernel
unsignedcharkernelLength[IMAGE_LEN];// 128-137: Size of kernel
unsignedchardualImage[2];// 138-139: Unused at present
unsignedcharinactiveFlag[2];// 140-141: Unused at present
unsignedcharinformation1[TAGINFO_LEN];// 142-161: Unused at present
unsignedcharinformation2[54];// 162-215: Compilation and related information (not generated/used by OpenWRT)
unsignedcharkernelCRC[4];// 216-219: CRC32 of images
unsignedcharrootAddress[ADDRESS_LEN];// 220-231: Address in memory of rootfs partition
unsignedchartagIdCRC[4];// 232-235: Checksum to ensure validity of tagId
unsignedcharheaderCRC[4];// 236-239: CRC32 of header excluding tagVersion
unsignedcharrootLength[IMAGE_LEN];// 240-249: Size of rootfs
unsignedchartagId[TAGID_LEN];// 250-255: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
};
structbcm_tag_bc308{
unsignedchartagVersion[4];// 0-3: Version of the image tag
unsignedcharsig_1[20];// 4-23: Company Line 1
unsignedcharsig_2[14];// 24-37: Company Line 2
unsignedcharchipid[6];// 38-43: Chip this image is for
unsignedcharboardid[16];// 44-59: Board name
unsignedcharbig_endian[2];// 60-61: Map endianness -- 1 BE 0 LE
unsignedchartotalLength[IMAGE_LEN];// 62-71: Total length of image
unsignedcharcfeAddress[ADDRESS_LEN];// 72-83: Address in memory of CFE
unsignedcharcfeLength[IMAGE_LEN];// 84-93: Size of CFE
unsignedcharflashImageStart[ADDRESS_LEN];// 94-105: Address in memory of kernel (start of image)
unsignedcharflashRootLength[IMAGE_LEN];// 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
unsignedcharkernelAddress[ADDRESS_LEN];// 116-127: Address in memory of kernel
unsignedcharkernelLength[IMAGE_LEN];// 128-137: Size of kernel
unsignedchardualImage[2];// 138-139: Unused at present
unsignedcharinactiveFlag[2];// 140-141: Unused at present
unsignedcharinformation1[TAGINFO_LEN+2];// 142-163: Unused at present
unsignedchartagId[TAGID_LEN];// 164-169: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
unsignedcharrootAddress[ADDRESS_LEN];// 170-181: Address in memory of rootfs partition
unsignedcharrootLength[IMAGE_LEN];// 182-191: Size of rootfs partition
unsignedcharflashLayoutVer[2];// 192-193: Version flash layout
unsignedcharcurflashLayoutVer[2];// 194-195: Unused at present
unsignedcharkernelCRC[4];// 196-199: Guessed to be kernel CRC
unsignedcharreserved4[16];// 200-215: Reserved area; unused at present
unsignedcharimageCRC[4];// 216-219: CRC32 of images
unsignedcharreserved2[12];// 220-231: Unused at present
unsignedchartagIdCRC[4];// 232-235: CRC32 to ensure validity of tagId
unsignedcharheaderCRC[4];// 236-239: CRC32 of header excluding tagVersion
unsignedcharreserved3[16];// 240-255: Unused at present
};
structbcm_tag_bc310{
unsignedchartagVersion[4];// 0-3: Version of the image tag
unsignedcharsig_1[20];// 4-23: Company Line 1
unsignedcharsig_2[14];// 24-37: Company Line 2
unsignedcharchipid[6];// 38-43: Chip this image is for
unsignedcharboardid[16];// 44-59: Board name
unsignedcharbig_endian[2];// 60-61: Map endianness -- 1 BE 0 LE
unsignedchartotalLength[IMAGE_LEN];// 62-71: Total length of image
unsignedcharcfeAddress[ADDRESS_LEN];// 72-83: Address in memory of CFE
unsignedcharcfeLength[IMAGE_LEN];// 84-93: Size of CFE
unsignedcharflashImageStart[ADDRESS_LEN];// 94-105: Address in memory of kernel (start of image)
unsignedcharflashRootLength[IMAGE_LEN];// 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image)
unsignedcharkernelAddress[ADDRESS_LEN];// 116-127: Address in memory of kernel
unsignedcharkernelLength[IMAGE_LEN];// 128-137: Size of kernel
unsignedchardualImage[2];// 138-139: Unused at present
unsignedcharinactiveFlag[2];// 140-141: Unused at present
unsignedcharinformation1[TAGINFO_LEN];// 142-161: Unused at present; Some vendors use this for optional information
unsignedchartagId[6];// 162-167: Identifies which type of tag this is, currently two-letter company code, and then three digits for version of broadcom code in which this tag was first introduced
unsignedchartagIdCRC[4];// 168-171: CRC32 to ensure validity of tagId
unsignedcharrootAddress[ADDRESS_LEN];// 172-183: Address in memory of rootfs partition
unsignedcharrootLength[IMAGE_LEN];// 184-193: Size of rootfs partition
unsignedcharreserved1[22];// 193-215: Reserved area not in use
unsignedcharimageCRC[4];// 216-219: CRC32 of images
unsignedcharrootfsCRC[4];// 220-227: CRC32 of rootfs partition
unsignedcharkernelCRC[4];// 224-227: CRC32 of kernel partition
unsignedcharreserved2[8];// 228-235: Unused at present
unsignedcharheaderCRC[4];// 235-239: CRC32 of header excluding tagVersion
unsignedcharreserved3[16];// 240-255: Unused at present