From 2a4fb82289872eaf4be51465bcd1208a2286e4c1 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Thu, 1 Apr 2010 21:20:43 +0000 Subject: [PATCH] flashmap and image generation: reduced union bcm_tag to a single struct combining the elements so that it is no longer necessary to create an openwrt-only tagid and tagcrc, and elimate the tagid detection and switch statements which made dealing with imagetags overly complicated, especially since the logic would need analogs in all code that touched the imagetag. Patch from cshore. SVN-Revision: 20652 --- .../mips/include/asm/mach-bcm63xx/bcm_tag.h | 219 +++--------- target/linux/brcm63xx/image/Makefile | 98 +++--- .../brcm63xx/image/README.images-bcm63xx | 91 +++-- .../040-bcm963xx_flashmap.patch | 211 +++--------- tools/firmware-utils/src/imagetag.c | 326 +++++------------- 5 files changed, 266 insertions(+), 679 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 c06f668942..d792562728 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 @@ -1,178 +1,69 @@ #ifndef __BCM63XX_TAG_H #define __BCM63XX_TAG_H -#define IMAGE_LEN 10 /* Length of Length Field */ -#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 */ #define TAGLAYOUT_LEN 4 /* Length of FlashLayoutVer */ +#define SIG1_LEN 20 /* Company Signature 1 Length */ +#define SIG2_LEN 14 /* Company Signature 2 Lenght */ +#define BOARDID_LEN 16 /* Length of BoardId */ +#define ENDIANFLAG_LEN 2 /* Endian Flag Length */ +#define CHIPID_LEN 6 /* Chip Id Length */ +#define IMAGE_LEN 10 /* Length of Length Field */ +#define ADDRESS_LEN 12 /* Length of Address field */ +#define DUALFLAG_LEN 2 /* Dual Image flag Length */ +#define INACTIVEFLAG_LEN 2 /* Inactie Flag Length */ +#define RSASIG_LEN 20 /* Length of RSA Signature in tag */ +#define TAGINFO1_LEN 30 /* Length of vendor information field1 in tag */ +#define FLASHLAYOUTVER_LEN 4 /* Length of Flash Layout Version String tag */ +#define TAGINFO2_LEN 16 /* Length of vendor information field2 in tag */ +#define CRC_LEN 4 /* Length of CRC in bytes */ +#define ALTTAGINFO_LEN 54 /* Alternate length for vendor information; Pirelli */ -#define NUM_TAGID 5 +#define NUM_PIRELLI 2 #define IMAGETAG_CRC_START 0xFFFFFFFF -struct tagiddesc_t { - char tagid[TAGID_LEN + 1]; - char tagiddesc[80]; -}; - - // bc221 is used by BT Voyager and should be right - // bc310 should be right, and may apply to 3.08 code as well -#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)" }, \ - { "bc221", "Broadcom code version 2.21" }, \ - { "bc310", "Broadcom code version 3.10-3.12" }, \ +#define PIRELLI_BOARDS { \ + "AGPF_S0", \ + "DWV_SO", \ } -struct bcm_tag_bccfe { - unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag - unsigned char sig_1[20]; // 4-23: Company Line 1 - unsigned char sig_2[14]; // 24-37: Company Line 2 - unsigned char chipid[6]; // 38-43: Chip this image is for - unsigned char boardid[16]; // 44-59: Board name - unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE - unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image - unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE - unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE - unsigned char rootAddress[ADDRESS_LEN]; // 94-105: Address in memory of rootfs - unsigned char rootLength[IMAGE_LEN]; // 106-115: Size of rootfs - unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel - unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel - unsigned char dualImage[2]; // 138-139: Unused at present - unsigned char inactiveFlag[2]; // 140-141: Unused at present - unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present - unsigned char tagId[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 - unsigned char tagIdCRC[4]; // 168-171: CRC32 of tagId - unsigned char reserved1[44]; // 172-215: Reserved area not in use - unsigned char imageCRC[4]; // 216-219: CRC32 of images - unsigned char reserved2[16]; // 220-235: Unused at present - unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion - unsigned char reserved3[16]; // 240-255: Unused at present -}; - -struct bcm_tag_bc300 { - unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag - unsigned char sig_1[20]; // 4-23: Company Line 1 - unsigned char sig_2[14]; // 24-37: Company Line 2 - unsigned char chipid[6]; // 38-43: Chip this image is for - unsigned char boardid[16]; // 44-59: Board name - unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE - unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image - unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE - unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE - unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image) - unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image) - unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel - unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel - unsigned char dualImage[2]; // 138-139: Unused at present - unsigned char inactiveFlag[2]; // 140-141: Unused at present - unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present - unsigned char tagId[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 - unsigned char tagIdCRC[4]; // 168-173: CRC32 to ensure validity of tagId - unsigned char rootAddress[ADDRESS_LEN]; // 174-183: Address in memory of rootfs partition - unsigned char rootLength[IMAGE_LEN]; // 184-193: Size of rootfs partition - unsigned char reserved1[22]; // 194-215: Reserved area not in use - unsigned char imageCRC[4]; // 216-219: CRC32 of images - unsigned char reserved2[16]; // 220-235: Unused at present - unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion - unsigned char reserved3[16]; // 240-255: Unused at present -}; - -struct bcm_tag_ag306 { - unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag - unsigned char sig_1[20]; // 4-23: Company Line 1 - unsigned char sig_2[14]; // 24-37: Company Line 2 - unsigned char chipid[6]; // 38-43: Chip this image is for - unsigned char boardid[16]; // 44-59: Board name - unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE - unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image - unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE - unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE - unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image) - unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image) - unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel - unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel - unsigned char dualImage[2]; // 138-139: Unused at present - unsigned char inactiveFlag[2]; // 140-141: Unused at present - unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present - unsigned char information2[54]; // 162-215: Compilation and related information (not generated/used by OpenWRT) - unsigned char kernelCRC[4] ; // 216-219: CRC32 of images - unsigned char rootAddress[ADDRESS_LEN]; // 220-231: Address in memory of rootfs partition - unsigned char tagIdCRC[4]; // 232-235: Checksum to ensure validity of tagId - unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion - unsigned char rootLength[IMAGE_LEN]; // 240-249: Size of rootfs - unsigned char tagId[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 -}; - -struct bcm_tag_bc221 { - unsigned char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag - unsigned char sig_1[20]; // 4-23: Company Line 1 - unsigned char sig_2[14]; // 24-37: Company Line 2 - unsigned char chipid[6]; // 38-43: Chip this image is for - unsigned char boardid[16]; // 44-59: Board name - unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE - unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image - unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE - unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE - unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image) - unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image) - unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel - unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel - unsigned char dualImage[2]; // 138-139: Unused at present - unsigned char inactiveFlag[2]; // 140-141: Unused at present - unsigned char rsa_signature[TAGINFO_LEN]; // 142-161: RSA Signature (unused at present; some vendors may use this) - unsigned char reserved5[2]; // 162-163: Unused at present - unsigned char tagId[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 - unsigned char rootAddress[ADDRESS_LEN]; // 170-181: Address in memory of rootfs partition - unsigned char rootLength[IMAGE_LEN]; // 182-191: Size of rootfs partition - unsigned char flashLayoutVer[4]; // 192-195: Version flash layout - unsigned char fskernelCRC[4]; // 196-199: Guessed to be kernel CRC - unsigned char reserved4[16]; // 200-215: Reserved area; unused at present - unsigned char imageCRC[4]; // 216-219: CRC32 of images - unsigned char reserved2[12]; // 220-231: Unused at present - unsigned char tagIdCRC[4]; // 232-235: CRC32 to ensure validity of tagId - unsigned char headerCRC[4]; // 236-239: CRC32 of header excluding tagVersion - unsigned char reserved3[16]; // 240-255: Unused at present -}; - -struct bcm_tag_bc310 { - unsigned char tagVersion[4]; // 0-3: Version of the image tag - unsigned char sig_1[20]; // 4-23: Company Line 1 - unsigned char sig_2[14]; // 24-37: Company Line 2 - unsigned char chipid[6]; // 38-43: Chip this image is for - unsigned char boardid[16]; // 44-59: Board name - unsigned char big_endian[2]; // 60-61: Map endianness -- 1 BE 0 LE - unsigned char totalLength[IMAGE_LEN]; // 62-71: Total length of image - unsigned char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE - unsigned char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE - unsigned char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of kernel (start of image) - unsigned char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs + deadcode (web flash uses this + kernelLength to determine the size of the kernel+rootfs flash image) - unsigned char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel - unsigned char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel - unsigned char dualImage[2]; // 138-139: Unused at present - unsigned char inactiveFlag[2]; // 140-141: Unused at present - unsigned char information1[TAGINFO_LEN]; // 142-161: Unused at present; Some vendors use this for optional information - unsigned char tagId[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 - unsigned char tagIdCRC[4]; // 168-171: CRC32 to ensure validity of tagId - unsigned char rootAddress[ADDRESS_LEN]; // 172-183: Address in memory of rootfs partition - unsigned char rootLength[IMAGE_LEN]; // 184-193: Size of rootfs partition - unsigned char reserved1[22]; // 193-215: Reserved area not in use - unsigned char imageCRC[4]; // 216-219: CRC32 of images - unsigned char rootfsCRC[4]; // 220-227: CRC32 of rootfs partition - unsigned char kernelCRC[4]; // 224-227: CRC32 of kernel partition - unsigned char reserved2[8]; // 228-235: Unused at present - unsigned char headerCRC[4]; // 235-239: CRC32 of header excluding tagVersion - unsigned char reserved3[16]; // 240-255: Unused at present -}; +/* + * The broadcom firmware assumes the rootfs starts the image, + * therefore uses the rootfs start (flashImageAddress) + * to determine where to flash the image. Since we have the kernel first + * we have to give it the kernel address, but the crc uses the length + * associated with this address (rootLength), which is added to the kernel + * length (kernelLength) to determine the length of image to flash and thus + * needs to be rootfs + deadcode (jffs2 EOF marker) +*/ -union bcm_tag { - struct bcm_tag_bccfe bccfe; - struct bcm_tag_bc300 bc300; - struct bcm_tag_ag306 ag306; - struct bcm_tag_bc221 bc221; - struct bcm_tag_bc310 bc310; +struct bcm_tag { + char tagVersion[TAGVER_LEN]; // 0-3: Version of the image tag + char sig_1[SIG1_LEN]; // 4-23: Company Line 1 + char sig_2[SIG2_LEN]; // 24-37: Company Line 2 + char chipid[CHIPID_LEN]; // 38-43: Chip this image is for + char boardid[BOARDID_LEN]; // 44-59: Board name + char big_endian[ENDIANFLAG_LEN]; // 60-61: Map endianness -- 1 BE 0 LE + char totalLength[IMAGE_LEN]; // 62-71: Total length of image + char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE + char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE + char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of image start (kernel for OpenWRT, rootfs for stock firmware) + char rootLength[IMAGE_LEN]; // 106-115: Size of rootfs + char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel + char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel + char dualImage[DUALFLAG_LEN]; // 138-139: Unused at present + char inactiveFlag[INACTIVEFLAG_LEN]; // 140-141: Unused at present + char rsa_signature[RSASIG_LEN]; // 142-161: RSA Signature (unused at present; some vendors may use this) + char information1[TAGINFO1_LEN]; // 162-191: Compilation and related information (not generated/used by OpenWRT) + char flashLayoutVer[FLASHLAYOUTVER_LEN];// 192-195: Version flash layout + char fskernelCRC[CRC_LEN]; // 196-199: kernel+rootfs CRC32 + char information2[TAGINFO2_LEN]; // 200-215: Unused at present except Alice Gate where is is information + char imageCRC[CRC_LEN]; // 216-219: CRC32 of image less imagetag (kernel for Alice Gate) + char rootfsCRC[CRC_LEN]; // 220-223: CRC32 of rootfs partition + char kernelCRC[CRC_LEN]; // 224-227: CRC32 of kernel partition + char reserved1[8]; // 228-235: Unused at present + char headerCRC[CRC_LEN]; // 236-239: CRC32 of header excluding tagVersion + char reserved2[16]; // 240-255: Unused at present }; #endif /* __BCM63XX_TAG_H */ diff --git a/target/linux/brcm63xx/image/Makefile b/target/linux/brcm63xx/image/Makefile index 5d17c2baf9..f7d1473ada 100644 --- a/target/linux/brcm63xx/image/Makefile +++ b/target/linux/brcm63xx/image/Makefile @@ -30,9 +30,9 @@ endef define Image/Build/CFE # Generate the tagged image $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \ - -o $(BIN_DIR)/openwrt-$(2)-$(1)-$(6)-cfe.bin \ + -o $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin \ -b $(2) -c $(3) -e $(LOADADDR) -l $(LOADADDR) \ - -t $(4) -d "$(5)" $(7) + -r "$(5)" $(6) # -b $(2) -c $(3) -e $(KERNEL_ENTRY) -l $(LOADADDR) endef @@ -40,17 +40,17 @@ endef define Image/Build/CFEAGPF # Generate the tagged image $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \ - -o $(BIN_DIR)/openwrt-$(2)-$(1)-$(7)-cfe.bin \ + -o $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin \ -b $(2) -c $(3) -e $(LOADADDR) -l $(LOADADDR) \ - -v 8 -m IMAGE -k 0x20000 -n $(4) -t $(5) + -v 8 -m IMAGE -k 0x20000 -n $(4) endef define Image/Build/RG100A # Generate the tagged image $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \ - -o $(BIN_DIR)/openwrt-$(6)-$(1)-$(7)-cfe.bin \ + -o $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin \ -b $(2) -c $(3) -e $(LOADADDR) -l $(LOADADDR) \ - -k 0x20000 -n $(4) -t $(5) + -k 0x20000 -n $(4) endef @@ -105,84 +105,70 @@ endef define Image/Build dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/openwrt-$(BOARD)-root.$(1) bs=128k conv=sync # Various routers - $(call Image/Build/CFE,$(1),96345GW2,6345,bccfe,,bccfe,) - $(call Image/Build/CFE,$(1),96345GW2,6345,bc221,,bc221,-y 5) - $(call Image/Build/CFE,$(1),96345GW2,6345,bc300,,bc300,) - $(call Image/Build/CFE,$(1),96345GW2,6345,bc310,OpenWRT-$(REVISION),bc310,) - $(call Image/Build/CFE,$(1),96348GW,6348,bccfe,,bccfe,) - $(call Image/Build/CFE,$(1),96348GW,6348,bc221,,bc221,-y 5) + $(call Image/Build/CFE,$(1),96345GW2,6345,96345GW2-generic) + $(call Image/Build/CFE,$(1),96345GW2,6345,96348GW2-bc221,,-y 5) + $(call Image/Build/CFE,$(1),96345GW2,6345,92345GW2-revision,OpenWRT-$(REVISION)) + $(call Image/Build/CFE,$(1),96348GW,6348,96348GW-generic,,) + $(call Image/Build/CFE,$(1),96348GW,6348,96348GW-bc221,,-y 5) + $(call Image/Build/CFE,$(1),6338GW,6338,6338GW-generic,,) + $(call Image/Build/CFE,$(1),6338W,6338,6338W-generic,,) + # BT Voyager V210_BTR - $(call Image/Build/CFE,$(1),V210_BB,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),V210_BB,6348,BTV210_BTR,,-y 5) # BT Voyager V210_ROI, V210_WB - $(call Image/Build/CFE,$(1),V210,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),V210,6348,BTV210_ROI_WB,,-y 5) # BT Voyager V2091_BTR - $(call Image/Build/CFE,$(1),V2091_BB,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),V2091_BB,6348,BTV2091_BTR,,y 5) # BT Voyager V2091_ROI, V2091_WB - $(call Image/Build/CFE,$(1),V2091,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),V2091,6348,BTV2091_ROI_WB,,-y 5) # BT Voyager V220V, V220V_MGCP_BTR - $(call Image/Build/CFE,$(1),RTA1052V,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),RTA1052V,6348,BTV220V_MGCP_BTR,,-y 5) # BT Voyager V2110, V2110_AA, V2110_ROI - $(call Image/Build/CFE,$(1),V2110,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),V2110,6348,BTV2110,,-y 5) # BT Voyager V2500V, V2500V_SIP_CLUB, V2500V_AA - $(call Image/Build/CFE,$(1),V2500V_BB,6348,bc221,,btvgr,-y 5) + $(call Image/Build/CFE,$(1),V2500V_BB,6348,BTV2500V,,-y 5) # RTA1025W_16 (numerous routers) - $(call Image/Build/CFE,$(1),RTA1025W_16,6348,bc221,,btrta,-y 5) + $(call Image/Build/CFE,$(1),RTA1025W_16,6348,RTA1025W_16,,-y 5) # Tecom GW6000 - $(call Image/Build/CFE,$(1),96348GW,6348,bc300,,bc300,) + $(call Image/Build/CFE,$(1),96348GW,6348,GW6000) # Tecom GW6200 - $(call Image/Build/CFE,$(1),96348GW,6348,bc310,$(shell printf '\x99'),gw6200) + $(call Image/Build/CFE,$(1),96348GW,6348,GW6200,$(shell printf '\x99')) # Neufbox4 - $(call Image/Build/CFE,$(1),96358VW,6358,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),96358VW,6358,bc310,OpenWRT-$(REVISION),nb4) + $(call Image/Build/CFE,$(1),96358VW,6358,NEUFBOX4,OpenWRT-$(REVISION)) # Comtrend 536, 5621 - $(call Image/Build/CFE,$(1),96348GW-11,6348,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),96348GW-11,6348,bc300,,bc300) - # TP-Link 8900GB - $(call Image/Build/CFE,$(1),96348GW-11,6348,bc310,$(shell printf 'PRID\x89\x10\x00\x02'),td8900GB) + $(call Image/Build/CFE,$(1),96348GW-11,6348,CT536_CT5621) # Davolink DV201AMR $(call Image/Build/CFEOLD,$(1),DV201AMR,6348) # USR 9108 - $(call Image/Build/CFE,$(1),96348GW-A,6348,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),96348GW-A,6348,bc300,,bc300) + $(call Image/Build/CFE,$(1),96348GW-A,6348,USR9108) # NetGear DG834GT, DG834PN - $(call Image/Build/CFE,$(1),96348GW-10,6348,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),96348GW-10,6348,bc300,,bc300) + $(call Image/Build/CFE,$(1),96348GW-10,6348,DG834GT_DG834PN) # Belkin f5d7633 - $(call Image/Build/CFE,$(1),96348GW-10,6348,bc310,,bc310) + $(call Image/Build/CFE,$(1),96348GW-10,6348,F5D7633) # D-Link DSL-2640B - $(call Image/Build/CFE,$(1),D-4P-W,6348,bc310,,bc310) + $(call Image/Build/CFE,$(1),D-4P-W,6348,DSL2640B) + # D-Link DSL-2740B + $(call Image/Build/CFE,$(1),96358GW,6358,DSL2740B) # TP-Link TD-8810A, TD-8810B, TD-8811A, TD-8811B - $(call Image/Build/CFE,$(1),8L-2M-8M,6338,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),8L-2M-8M,6338,bc300,,bc300) - - # Generic 6338 images - $(call Image/Build/CFE,$(1),6338GW,6338,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),6338GW,6338,bc221,,bc221) - $(call Image/Build/CFE,$(1),6338GW,6338,bc300,,bc300) - $(call Image/Build/CFE,$(1),6338GW,6338,bc310,,bc310) - $(call Image/Build/CFE,$(1),6338W,6338,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),6338W,6338,bc221,,bc221) - $(call Image/Build/CFE,$(1),6338W,6338,bc300,,bc300) - $(call Image/Build/CFE,$(1),6338W,6338,bc310,,bc310) + $(call Image/Build/CFE,$(1),8L-2M-8M,6338,TP8810_8811) + # TP-Link 8900GB + $(call Image/Build/CFE,$(1),96348GW-11,6348,TD8900GB,$(shell printf 'PRID\x89\x10\x00\x02')) # Sagem F@ST2404 - $(call Image/Build/CFE,$(1),F@ST2404,6348,bccfe,,bccfe) - $(call Image/Build/CFE,$(1),F@ST2404,6348,bc300,,bc300) - $(call Image/Build/CFE,$(1),F@ST2404,6348,bc310,OpenWRT-$(REVISION),bc310) + $(call Image/Build/CFE,$(1),F@ST2404,6348,F@ST2404-cfe) + $(call Image/Build/CFE,$(1),F@ST2404,6348,F@ST2404,OpenWRT-$(REVISION)) # Inventel Livebox $(call Image/Build/RedBoot,livebox) - # D-Link DSL-2740B - $(call Image/Build/CFE,$(1),96358GW,6358,bc310,,dsl2740b) # Pirelli Alice Gate VoIP 2 Plus Wi-Fi AGPF-S0 - $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358,0x20000,bccfe,,bccfe) - $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358,0x20000,ag306,,agv2+w) + $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358,0x20000,AGV2+W-cfe) + $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358,0x20000,AGV2+W) # Pirelli A226G - $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x10000,bccfe,,bccfe) - $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x10000,ag306,DWV_96358,a226g) + $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x10000,A226G-cfe) + $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x10000,A226G) # RG100A,DB120 etc. - $(call Image/Build/RG100A,$(1),96358VW2,6358,0x20000,bc310,rg100a,bc310) + $(call Image/Build/RG100A,$(1),96358VW2,6358,0x20000,RG100A_DB120) endef diff --git a/target/linux/brcm63xx/image/README.images-bcm63xx b/target/linux/brcm63xx/image/README.images-bcm63xx index 9cf05743ab..91b6d019ee 100644 --- a/target/linux/brcm63xx/image/README.images-bcm63xx +++ b/target/linux/brcm63xx/image/README.images-bcm63xx @@ -16,6 +16,11 @@ Images flashable using cfe are labelled openwrt---cfe.bin The imagetags for tftp/ftp flashing is based on Broadcom 3.00-3.04 imagetags and is known to be correct as the source code GPL and is available for reading. +Broadcom code 2.21 is based on the BT Voyager firmware image I looked at. It +may in fact be BT Voyager-specific. 2.21 is actually more difficult to deal +with the imagetag from 3.00 as it has three different CRC calculations in +addtition to the header CRC. + Broadcom 3.00-3.02 flashing has been tested on Comtrend CT-5261, CT-536 and Tecom GW6000, and is the version of the flashing that was present before the imagetags were split by broadcom code version (early June 2009) @@ -27,16 +32,11 @@ this author (Daniel Dickinson) has seen is the Alice Gate (Pirelli) firmware which is known to be different due to vendor (Pirelli) modifications to the Broadcom code. -Broadcom 3.08 introduced changes to the imagetag to deal with TR69 (a remote -router management system developed by the DSL Forum). The version we are -using as 3.08 is based on the BT Voyager firmware image I looked at. It may -in fact be BT Voyager-specific, and may in fact not be 3.08, but modified 3.06 -and not apply to all 3.08 versions. - Broadcom 3.10 uses an imagetag that is believed to apply to all 3.10 and 3.12 -versions, and has been tested on the Tecom GW6200. It is similar to 3.08. -There is a field for vendor-specific information, that at least in some cases -is not optional. It is based on the hexedit of a neufbox4 firmware image, the +versions, and has been tested on the Tecom GW6200. This version introdec changes to +the imagetag to deal with TR69 (a remote rouer management system developed by the +DSL forum). There is a field for vendor-specific information, that at least in some +cases is not optional. It is based on the hexedit of a neufbox4 firmware image, the information in https://dev.openwrt.org/ticket/4987, and the hexedit of a Tecom GW6200 image. @@ -44,43 +44,41 @@ Some boards share the same tag format, but require vendor-specific fields in the board. In that case the tagid is shared, but the filename of the generated image reflects the router for which the image was created. -router |method| codever |tagid |filename -+-------------+------+---------+------+---------------------------------------- -|any |cfe | any |bccfe |openwrt---bccfe-cfe.bin -|any |t/ftp | any |bc300 |openwrt---bc300-cfe.bin -| |web |3.00-3.06|bc300 |openwrt---bc300-cfe.bin -| |web |3.10-3.12|bc310 |openwrt---bc310-cfe.bin -|AGVoIP2+WiFi |web |alice3.06|ag306 |openwrt-AGPF-S0--agv2+w-cfe.bin -|CT536 |web |3.02 |bc300 |openwrt-96348GW-11--bc300-cfe.bin -|CT5621 |web |3.02 |bc300 |openwrt-96348GW-11--bc300-cfe.bin -|DG834GT |web |3.02 |bc300 |openwrt-96348GW-10--bc300-cfe.bin -|DG834PN |web |3.02 |bc300 |openwrt-96348GW-10--bc300-cfe.bin -|DSL-2640B |web |3.10 |bc310 |openwrt-D-4P-W--bc310-cfe.bin -|DSL-2740B |web |3.10 |bc310 |openwrt-96358GW--dsl2740b-cfe.bin -|F5D7633 |web |3.10 |bc310 |openwrt-96348GW-10--bc310-cfe.bin -|F@ST2404 |web |? |bc300 |openwrt-F@ST2404--bc300-cfe.bin -|F@ST2404 |web |? |bc310 |openwrt-F@ST2404--bc310-cfe.bin -|GW6000 |web |3.00 |bc300 |openwrt-96348GW--bc300-cfe.bin -|GW6200 |web |3.10 |bc310 |openwrt-96348GW--gw6200-cfe.bin -|Neufbox4 |web |3.12 |bc310 |openwrt-96358VW--nb4-cfe.bin -|TD8810A |web |3.06 |bc300 |openwrt-8L-2M-8M--bc306-cfe.bin -|TD8810B |web |3.06 |bc300 |openwrt-8L-2M-8M--bc306-cfe.bin -|TD8811A |web |3.06 |bc300 |openwrt-8L-2M-8M--bc306-cfe.bin -|TD8811B |web |3.06 |bc300 |openwrt-8L-2M-8M--bc306-cfe.bin -|TD8900GB |web |3.06 |bc300 |openwrt-96348GW-11--td8900gb-cfe.bin -|USR9108 |web |? |bc300 |openwrt-96348GW-A--bc300-cfe.bin -|V2091_BTR |web |2.21 |bc221 |openwrt-V2091_BB--btvgr-cfe.bin -|V2091_ROI |web |2.21 |bc221 |openwrt-V2091--btvgr-cfe.bin -|V2091_WB |web |2.21 |bc221 |openwrt-V2091--btvgr-cfe.bin -|V210_BTR |web |2.21 |bc221 |openwrt-V210_BB--btvgr-cfe.bin -|V210_ROI |web |2.21 |bc221 |openwrt-V210--btvgr-cfe.bin -|V210_WB |web |2.21 |bc221 |openwrt-V210--btvgr-cfe.bin -|V2110 |web |2.21 |bc221 |openwrt-V2110--btvgr-cfe.bin -|V2110_AA |web |2.21 |bc221 |openwrt-V2110--btvgr-cfe.bin -|V2110_ROI |web |2.21 |bc221 |openwrt-V2110--btvgr-cfe.bin -|V2500V |web |2.21 |bc221 |openwrt-V2500V_BB--btvgr-cfe.bin -|V2500V_AA |web |2.21 |bc221 |openwrt-V2500V_BB--btvgr-cfe.bin -|V2500V_SIP_CLUB |web|2.21 |bc221 |openwrt-V2500V_BB--btvgr-cfe.bin +router |method | codever |filename ++-------------+-------------+---------+--------------------------------------- +|any |cfe+most web | any |openwrt---cfe.bin +|AGVoIP2+WiFi |cfe |alice3.06|openwrt-AGV2+W-cfe--cfe.bin +|AGVoIP2+WiFi |web |alice3.06|openwrt-AGV2+W-cfe--cfe.bin +|CT536 |web |3.02 |openwrt-CT536_CT5621--cfe.bin +|CT5621 |web |3.02 |openwrt-CT536_CT5621--cfe.bin +|DG834GT |web |3.02 |openwrt-DG834GT_DG834PN--cfe.bin +|DG834PN |web |3.02 |openwrt-DG834GT_DG834PN--cfe.bin +|DSL-2640B |web |3.10 |openwrt-DSL2640B--cfe.bin +|DSL-2740B |web |3.10 |openwrt-DSL2670B--cfe.bin +|F5D7633 |web |3.10 |openwrt-F5D7633--cfe.bin +|F@ST2404 |web |3.0X? |openwrt-F@ST2404-cfe--cfe.bin +|F@ST2404 |web |3.1X? |openwrt-F@ST2404--cfe.bin +|GW6000 |web |3.00 |openwrt-GW6000--cfe.bin +|GW6200 |web |3.10 |openwrt-GW6200--cfe.bin +|Neufbox4 |web |3.12 |openwrt-NEUFBOX4--cfe.bin +|TD8810A |web |3.06 |openwrt-TD8810--cfe.bin +|TD8810B |web |3.06 |openwrt-TD8810--cfe.bin +|TD8811A |web |3.06 |openwrt-TD8811--cfe.bin +|TD8811B |web |3.06 |openwrt-TD881--cfe.bin +|TD8900GB |web |3.06 |openwrt-TD8900DB-cfe.bin +|USR9108 |web |3.0X? |openwrt-USR9108--cfe.bin +|V2091_BTR |web |2.21 |openwrt-V2091_BTR--cfe.bin +|V2091_ROI |web |2.21 |openwrt-V2091--cfe.bin +|V2091_WB |web |2.21 |openwrt-V2091--cfe.bin +|V210_BTR |web |2.21 |openwrt-V210_BTR--cfe.bin +|V210_ROI |web |2.21 |openwrt-V210-ROI_WB-cfe.bin +|V210_WB |web |2.21 |openwrt-V210-ROI_WB-cfe.bin +|V2110 |web |2.21 |openwrt-V2110--cfe.bin +|V2110_AA |web |2.21 |openwrt-V2110--cfe.bin +|V2110_ROI |web |2.21 |openwrt-V2110--cfe.bin +|V2500V |web |2.21 |openwrt-V2500V-cfe.bin +|V2500V_AA |web |2.21 |openwrt-V2500V--cfe.bin +|V2500V_SIP_CLUB |web |2.21 |openwrt-V2500V--cfe.bin Old imagetag routers -------------------- @@ -126,3 +124,4 @@ TP-Link |TD-W8900GB |3.06 Tecom |GW6000 |3.00 Tecom |GW6200 |3.10 USR |9108 |? + diff --git a/target/linux/brcm63xx/patches-2.6.32/040-bcm963xx_flashmap.patch b/target/linux/brcm63xx/patches-2.6.32/040-bcm963xx_flashmap.patch index 556e8cb858..117074b994 100644 --- a/target/linux/brcm63xx/patches-2.6.32/040-bcm963xx_flashmap.patch +++ b/target/linux/brcm63xx/patches-2.6.32/040-bcm963xx_flashmap.patch @@ -11,9 +11,11 @@ Signed-off-by: Axel Gembe drivers/mtd/redboot.c | 13 ++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) ---- a/drivers/mtd/maps/Kconfig -+++ b/drivers/mtd/maps/Kconfig -@@ -259,6 +259,13 @@ config MTD_ALCHEMY +Index: linux-2.6.32.10/drivers/mtd/maps/Kconfig +=================================================================== +--- linux-2.6.32.10.orig/drivers/mtd/maps/Kconfig 2010-03-29 06:35:59.987293878 -0400 ++++ linux-2.6.32.10/drivers/mtd/maps/Kconfig 2010-03-29 06:37:14.968545954 -0400 +@@ -259,6 +259,13 @@ help Flash memory access on AMD Alchemy Pb/Db/RDK Reference Boards @@ -27,9 +29,11 @@ Signed-off-by: Axel Gembe config MTD_DILNETPC tristate "CFI Flash device mapped on DIL/Net PC" depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT && BROKEN ---- a/drivers/mtd/redboot.c -+++ b/drivers/mtd/redboot.c -@@ -39,7 +39,7 @@ static inline int redboot_checksum(struc +Index: linux-2.6.32.10/drivers/mtd/redboot.c +=================================================================== +--- linux-2.6.32.10.orig/drivers/mtd/redboot.c 2010-03-29 06:36:00.017292877 -0400 ++++ linux-2.6.32.10/drivers/mtd/redboot.c 2010-03-29 06:37:14.968545954 -0400 +@@ -39,7 +39,7 @@ return 1; } @@ -38,7 +42,7 @@ Signed-off-by: Axel Gembe struct mtd_partition **pparts, unsigned long fis_origin) { -@@ -162,6 +162,14 @@ static int parse_redboot_partitions(stru +@@ -162,6 +162,14 @@ goto out; } @@ -53,7 +57,7 @@ Signed-off-by: Axel Gembe for (i = 0; i < numslots; i++) { struct fis_list *new_fl, **prev; -@@ -184,9 +192,8 @@ static int parse_redboot_partitions(stru +@@ -184,9 +192,8 @@ new_fl->img = &buf[i]; if (fis_origin) { buf[i].flash_base -= fis_origin; @@ -64,16 +68,20 @@ Signed-off-by: Axel Gembe /* I'm sure the JFFS2 code has done me permanent damage. * I now think the following is _normal_ ---- a/drivers/mtd/maps/Makefile -+++ b/drivers/mtd/maps/Makefile -@@ -61,3 +61,4 @@ obj-$(CONFIG_MTD_BFIN_ASYNC) += bfin-asy +Index: linux-2.6.32.10/drivers/mtd/maps/Makefile +=================================================================== +--- linux-2.6.32.10.orig/drivers/mtd/maps/Makefile 2010-03-29 06:35:59.947294290 -0400 ++++ linux-2.6.32.10/drivers/mtd/maps/Makefile 2010-03-29 06:37:14.968545954 -0400 +@@ -61,3 +61,4 @@ obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o obj-$(CONFIG_MTD_VMU) += vmu-flash.o obj-$(CONFIG_MTD_GPIO_ADDR) += gpio-addr-flash.o +obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o ---- /dev/null -+++ b/drivers/mtd/maps/bcm963xx-flash.c -@@ -0,0 +1,399 @@ +Index: linux-2.6.32.10/drivers/mtd/maps/bcm963xx-flash.c +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ linux-2.6.32.10/drivers/mtd/maps/bcm963xx-flash.c 2010-03-29 13:33:58.797288897 -0400 +@@ -0,0 +1,266 @@ +/* + * Copyright (C) 2006-2008 Florian Fainelli + * Mike Albon @@ -119,179 +127,46 @@ Signed-off-by: Axel Gembe + .bankwidth = BUSWIDTH, +}; + -+static struct tagiddesc_t tagidtab[NUM_TAGID] = TAGID_DEFINITIONS; -+ -+static uint32_t tagcrc32tab[256] = { -+ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, -+ 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, -+ 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, -+ 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, -+ 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, -+ 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, -+ 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, -+ 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, -+ 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, -+ 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, -+ 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, -+ 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, -+ 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, -+ 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, -+ 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, -+ 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, -+ 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, -+ 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, -+ 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, -+ 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, -+ 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, -+ 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, -+ 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, -+ 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, -+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, -+ 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, -+ 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, -+ 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, -+ 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, -+ 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, -+ 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, -+ 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -+}; -+ -+static uint32_t tagcrc32(uint32_t crc, uint8_t *data, size_t len) -+{ -+ while (len--) -+ crc = (crc >> 8) ^ tagcrc32tab[(crc ^ *data++) & 0xFF]; -+ -+ return crc; -+} + +static int parse_cfe_partitions( struct mtd_info *master, struct mtd_partition **pparts) +{ + int nrparts = 3, curpart = 0; /* CFE,NVRAM and global LINUX are always present. */ -+ union bcm_tag *buf; ++ struct bcm_tag *buf; + struct mtd_partition *parts; + int ret; + size_t retlen; + unsigned int rootfsaddr, kerneladdr, spareaddr; + unsigned int rootfslen, kernellen, sparelen, totallen; -+ unsigned char *tagid; + int namelen = 0; + int i; -+ uint32_t tagidcrc; -+ uint32_t calctagidcrc; -+ bool tagid_match = false; + char *boardid; + char *tagversion; -+ char *matchtagid; + + /* Allocate memory for buffer */ -+ buf = vmalloc(sizeof(union bcm_tag)); ++ buf = vmalloc(sizeof(struct bcm_tag)); + if (!buf) + return -ENOMEM; + + /* Get the tag */ -+ ret = master->read(master,master->erasesize,sizeof(union bcm_tag), &retlen, (void *)buf); -+ if (retlen != sizeof(union bcm_tag)){ ++ ret = master->read(master,master->erasesize,sizeof(struct bcm_tag), &retlen, (void *)buf); ++ if (retlen != sizeof(struct bcm_tag)){ + vfree(buf); + return -EIO; + } + -+ /* tagId isn't in the same location, so we check each tagid against the -+ * tagid CRC. If the CRC is valid we have found the right tag and so -+ * use that tag -+ */ -+ -+ for (i = 0; i < NUM_TAGID; i++) { -+ switch(i) { -+ case 0: -+ matchtagid = "bccfe"; -+ tagid = &(buf->bccfe.tagId[0]); -+ sscanf(buf->bccfe.rootAddress,"%u", &rootfsaddr); -+ sscanf(buf->bccfe.rootLength, "%u", &rootfslen); -+ sscanf(buf->bccfe.kernelAddress, "%u", &kerneladdr); -+ sscanf(buf->bccfe.kernelLength, "%u", &kernellen); -+ sscanf(buf->bccfe.totalLength, "%u", &totallen); -+ tagidcrc = *(uint32_t *)&(buf->bccfe.tagIdCRC[0]); -+ tagversion = &(buf->bccfe.tagVersion[0]); -+ boardid = &(buf->bccfe.boardid[0]); -+ break; -+ case 1: -+ matchtagid = "bc300"; -+ tagid = &(buf->bc300.tagId[0]); -+ sscanf(buf->bc300.rootAddress,"%u", &rootfsaddr); -+ sscanf(buf->bc300.rootLength, "%u", &rootfslen); -+ sscanf(buf->bc300.kernelAddress, "%u", &kerneladdr); -+ sscanf(buf->bc300.kernelLength, "%u", &kernellen); -+ sscanf(buf->bc300.totalLength, "%u", &totallen); -+ tagidcrc = *(uint32_t *)&(buf->bc300.tagIdCRC[0]); -+ tagversion = &(buf->bc300.tagVersion[0]); -+ boardid = &(buf->bc300.boardid[0]); -+ break; -+ case 2: -+ matchtagid = "ag306"; -+ tagid = &(buf->ag306.tagId[0]); -+ sscanf(buf->ag306.rootAddress,"%u", &rootfsaddr); -+ sscanf(buf->ag306.rootLength, "%u", &rootfslen); -+ sscanf(buf->ag306.kernelAddress, "%u", &kerneladdr); -+ sscanf(buf->ag306.kernelLength, "%u", &kernellen); -+ sscanf(buf->ag306.totalLength, "%u", &totallen); -+ tagidcrc = *(uint32_t *)&(buf->ag306.tagIdCRC[0]); -+ tagversion = &(buf->ag306.tagVersion[0]); -+ boardid = &(buf->ag306.boardid[0]); -+ break; -+ case 3: -+ matchtagid = "bc221"; -+ tagid = &(buf->bc221.tagId[0]); -+ sscanf(buf->bc221.rootAddress,"%u", &rootfsaddr); -+ sscanf(buf->bc221.rootLength, "%u", &rootfslen); -+ sscanf(buf->bc221.kernelAddress, "%u", &kerneladdr); -+ sscanf(buf->bc221.kernelLength, "%u", &kernellen); -+ sscanf(buf->bc221.totalLength, "%u", &totallen); -+ tagidcrc = *(uint32_t *)&(buf->bc221.tagIdCRC[0]); -+ tagversion = &(buf->bc221.tagVersion[0]); -+ boardid = &(buf->bc221.boardid[0]); -+ break; -+ case 4: -+ matchtagid = "bc310"; -+ tagid = &(buf->bc310.tagId[0]); -+ sscanf(buf->bc310.rootAddress,"%u", &rootfsaddr); -+ sscanf(buf->bc310.rootLength, "%u", &rootfslen); -+ sscanf(buf->bc310.kernelAddress, "%u", &kerneladdr); -+ sscanf(buf->bc310.kernelLength, "%u", &kernellen); -+ sscanf(buf->bc310.totalLength, "%u", &totallen); -+ tagidcrc = *(uint32_t *)&(buf->bc310.tagIdCRC[0]); -+ tagversion = &(buf->bc310.tagVersion[0]); -+ boardid = &(buf->bc310.boardid[0]); -+ break; -+ } -+ if (strncmp(tagid, matchtagid, TAGID_LEN) != 0) { -+ continue; -+ } -+ -+ calctagidcrc = htonl(tagcrc32(IMAGETAG_CRC_START, tagid, TAGID_LEN)); -+ if (tagidcrc == calctagidcrc) { -+ tagid_match = true; -+ break; -+ } -+ } -+ -+ if (!tagid_match) { -+ tagid = "bcram"; -+ sscanf(buf->bccfe.rootAddress,"%u", &rootfsaddr); -+ sscanf(buf->bccfe.rootLength, "%u", &rootfslen); -+ sscanf(buf->bccfe.kernelAddress, "%u", &kerneladdr); -+ sscanf(buf->bccfe.kernelLength, "%u", &kernellen); -+ sscanf(buf->bccfe.totalLength, "%u", &totallen); -+ tagidcrc = *(uint32_t *)&(buf->bccfe.tagIdCRC[0]); -+ tagversion = &(buf->bccfe.tagVersion[0]); -+ boardid = &(buf->bccfe.boardid[0]); -+ } ++ sscanf(buf->kernelAddress, "%u", &kerneladdr); ++ sscanf(buf->kernelLength, "%u", &kernellen); ++ sscanf(buf->totalLength, "%u", &totallen); ++ tagversion = &(buf->tagVersion[0]); ++ boardid = &(buf->boardid[0]); + -+ printk(KERN_INFO PFX "CFE boot tag found with version %s, board type %s, and tagid %s.\n",tagversion,boardid,tagid); ++ printk(KERN_INFO PFX "CFE boot tag found with version %s and board type %s\n",tagversion, boardid); + -+ rootfsaddr = rootfsaddr - EXTENDED_SIZE; + kerneladdr = kerneladdr - EXTENDED_SIZE; -+ spareaddr = roundup(totallen,master->erasesize) + master->erasesize; ++ rootfsaddr = kerneladdr + kernellen; ++ spareaddr = roundup(totallen, master->erasesize) + master->erasesize; + sparelen = master->size - spareaddr - master->erasesize; ++ rootfslen = spareaddr - rootfsaddr; + + /* Determine number of partitions */ + namelen = 8; @@ -342,9 +217,9 @@ Signed-off-by: Axel Gembe + parts[curpart].name = "linux"; + parts[curpart].offset = parts[0].size; + parts[curpart].size = master->size - parts[0].size - parts[3].size; -+ ++ + for (i = 0; i < nrparts; i++) -+ printk(KERN_INFO PFX "Partition %d is %s offset %lx and length %lx\n", i, parts[i].name, parts[i].offset, parts[i].size); ++ printk(KERN_INFO PFX "Partition %d is %s offset %lx and length %lx\n", i, parts[i].name, (long unsigned int)(parts[i].offset), (long unsigned int)(parts[i].size)); + + printk(KERN_INFO PFX "Spare partition is %x offset and length %x\n", spareaddr, sparelen); + *pparts = parts; @@ -375,7 +250,7 @@ Signed-off-by: Axel Gembe + char *part_type; + struct resource *r; + -+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0); ++ r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + bcm963xx_map.phys = r->start; + bcm963xx_map.size = (r->end - r->start) + 1; + bcm963xx_map.virt = ioremap(r->start, r->end - r->start + 1); @@ -473,9 +348,11 @@ Signed-off-by: Axel Gembe +MODULE_DESCRIPTION("Broadcom BCM63xx MTD partition parser/mapping for CFE and RedBoot"); +MODULE_AUTHOR("Florian Fainelli "); +MODULE_AUTHOR("Mike Albon "); ---- a/arch/mips/bcm63xx/boards/board_bcm963xx.c -+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c -@@ -722,20 +722,6 @@ static int board_get_mac_address(u8 *mac +Index: linux-2.6.32.10/arch/mips/bcm63xx/boards/board_bcm963xx.c +=================================================================== +--- linux-2.6.32.10.orig/arch/mips/bcm63xx/boards/board_bcm963xx.c 2010-03-29 06:35:59.927292275 -0400 ++++ linux-2.6.32.10/arch/mips/bcm63xx/boards/board_bcm963xx.c 2010-03-29 06:37:35.178541753 -0400 +@@ -722,20 +722,6 @@ return 0; } @@ -496,7 +373,7 @@ Signed-off-by: Axel Gembe static struct resource mtd_resources[] = { { .start = 0, /* filled at runtime */ -@@ -745,12 +731,9 @@ static struct resource mtd_resources[] = +@@ -745,12 +731,9 @@ }; static struct platform_device mtd_dev = { diff --git a/tools/firmware-utils/src/imagetag.c b/tools/firmware-utils/src/imagetag.c index e93f5f45e8..658674ec78 100644 --- a/tools/firmware-utils/src/imagetag.c +++ b/tools/firmware-utils/src/imagetag.c @@ -29,7 +29,7 @@ union int2char { uint32_t input; - unsigned char output[4]; + char output[4]; }; /* This appears to be necessary due to alignment issues */ @@ -43,7 +43,7 @@ struct kernelhdr { uint32_t lzmalen; /* Compressed length of the LZMA data that follows */ }; -static struct tagiddesc_t tagidtab[NUM_TAGID] = TAGID_DEFINITIONS; +static char pirellitab[NUM_PIRELLI][BOARDID_LEN] = PIRELLI_BOARDS; static uint32_t crc32tab[256] = { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, @@ -130,9 +130,9 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, const char *boardid, const char *chipid, const uint32_t fwaddr, const uint32_t loadaddr, const uint32_t entry, const char *ver, const char *magic2, const uint32_t flash_bs, - const char *tagid, const char *information, const char *layoutver) + const char *rsignature, const char *layoutver) { - union bcm_tag tag; + struct bcm_tag tag; struct kernelhdr khdr; FILE *kernelfile = NULL, *rootfsfile = NULL, *binfile; size_t kerneloff, kernellen, rootfsoff, rootfslen, read, imagelen, rootfsoffpadlen, kernelfslen; @@ -143,23 +143,26 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, uint32_t kernelfscrc = IMAGETAG_CRC_START; const uint32_t deadcode = htonl(DEADCODE); union int2char intchar; + int i; + int is_pirelli = 0; - memset(&tag, 0, sizeof(union bcm_tag)); + memset(&tag, 0, sizeof(struct bcm_tag)); - /* All imagetags have boardid in the same location and of the same - * size, so we just use the bccfe one - */ - if (strlen(boardid) >= sizeof(tag.bccfe.boardid)) { + if (strlen(boardid) >= sizeof(tag.boardid)) { fprintf(stderr, "Board id is too long!\n"); return 1; } /* Likewise chipid */ - if (strlen(chipid) >= sizeof(tag.bccfe.chipid)) { + if (strlen(chipid) >= sizeof(tag.chipid)) { fprintf(stderr, "Chip id is too long!\n"); return 1; } + if (!kernel || !rootfs) { + fprintf(stderr, "imagetag can't create an image without both kernel and rootfs\n"); + } + if (kernel && !(kernelfile = fopen(kernel, "rb"))) { fprintf(stderr, "Unable to open kernel \"%s\"\n", kernel); return 1; @@ -224,203 +227,70 @@ 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)) { - /* 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)) { - /* Compute the crc32 of the kernel and padding between kernel and rootfs) */ - kernelcrc = compute_crc32(kernelcrc, binfile, kerneloff - fwaddr, kernellen + rootfsoffpadlen); - } else if ( tagid && ( (strncmp(tagid, "bc221", TAGID_LEN) == 0))) { - /* Compute the crc32 of the entire image (deadC0de included) */ - imagecrc = compute_crc32(imagecrc, binfile, kerneloff - fwaddr, imagelen); - /* Compute the crc32 of the kernel and padding between kernel and rootfs) */ - kernelfscrc = compute_crc32(kernelfscrc, binfile, kerneloff - fwaddr, kernellen + rootfsoffpadlen + rootfslen + sizeof(deadcode)); - } else if ( tagid && (strncmp(tagid, "bc310", TAGID_LEN) == 0) ) { - /* Compute the crc32 of the entire image (deadC0de included) */ - imagecrc = compute_crc32(imagecrc, binfile, kerneloff - fwaddr, imagelen); - /* Compute the crc32 of the kernel and padding between kernel and rootfs) */ - kernelcrc = compute_crc32(kernelcrc, binfile, kerneloff - fwaddr, kernellen + rootfsoffpadlen); - /* Compute the crc32 of the flashImageStart to rootLength. - * The broadcom firmware assumes the rootfs starts the image, - * therefore uses the rootfs start to determine where to flash - * the image. Since we have the kernel first we have to give - * it the kernel address, but the crc uses the length - * associated with this address, which is added to the kernel - * length to determine the length of image to flash and thus - * needs to be rootfs + deadcode - */ - rootfscrc = compute_crc32(rootfscrc, binfile, kerneloff - fwaddr, rootfslen + sizeof(deadcode)); - } + /* Compute the crc32 of the entire image (deadC0de included) */ + imagecrc = compute_crc32(imagecrc, binfile, kerneloff - fwaddr, imagelen); + /* Compute the crc32 of the kernel and padding between kernel and rootfs) */ + kernelcrc = compute_crc32(kernelcrc, binfile, kerneloff - fwaddr, kernellen + rootfsoffpadlen); + /* Compute the crc32 of the kernel and padding between kernel and rootfs) */ + kernelfscrc = compute_crc32(kernelfscrc, binfile, kerneloff - fwaddr, kernellen + rootfsoffpadlen + rootfslen + sizeof(deadcode)); + /* Compute the crc32 of the flashImageStart to rootLength. + * The broadcom firmware assumes the rootfs starts the image, + * therefore uses the rootfs start to determine where to flash + * the image. Since we have the kernel first we have to give + * it the kernel address, but the crc uses the length + * associated with this address, which is added to the kernel + * length to determine the length of image to flash and thus + * needs to be rootfs + deadcode + */ + rootfscrc = compute_crc32(rootfscrc, binfile, kerneloff - fwaddr, rootfslen + sizeof(deadcode)); /* Close the files */ fclose(kernelfile); fclose(rootfsfile); - 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)); + /* Build the tag */ + strncpy(tag.tagVersion, ver, TAGVER_LEN); + strncpy(tag.sig_1, IMAGETAG_MAGIC1, sizeof(tag.sig_1) - 1); + strncpy(tag.sig_2, magic2, sizeof(tag.sig_2) - 1); + strcpy(tag.chipid, chipid); + strcpy(tag.boardid, boardid); + strcpy(tag.big_endian, "1"); + sprintf(tag.totalLength, "%lu", imagelen); + + /* We don't include CFE */ + strcpy(tag.cfeAddress, "0"); + strcpy(tag.cfeLength, "0"); + + sprintf(tag.kernelAddress, "%lu", kerneloff); + sprintf(tag.kernelLength, "%lu", kernellen + rootfsoffpadlen); + sprintf(tag.flashImageStart, "%lu", kerneloff); + sprintf(tag.rootLength, "%lu", rootfslen + sizeof(deadcode)); + + if (rsignature) { + strncpy(tag.rsa_signature, rsignature, RSASIG_LEN); + } + + if (layoutver) { + strncpy(tag.flashLayoutVer, layoutver, TAGLAYOUT_LEN); + } + + for (i = 0; i < NUM_PIRELLI; i++) { + if (strncmp(boardid, pirellitab[i], BOARDID_LEN) == 0) { + is_pirelli = 1; + break; + } } + if ( !is_pirelli ) { + int2tag(tag.imageCRC, imagecrc); + } else { + int2tag(tag.imageCRC, kernelcrc); + } + int2tag(tag.kernelCRC, kernelcrc); + int2tag(tag.rootfsCRC, rootfscrc); + int2tag(tag.fskernelCRC, kernelfscrc); + int2tag(tag.headerCRC, crc32(IMAGETAG_CRC_START, (uint8_t*)&tag, sizeof(tag) - 20)); + fseek(binfile, 0L, SEEK_SET); fwrite(&tag, sizeof(uint8_t), sizeof(tag), binfile); @@ -432,12 +302,12 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, int main(int argc, char **argv) { int c, i; - char *kernel, *rootfs, *bin, *boardid, *chipid, *magic2, *ver, *tagid, *information, *layoutver; + char *kernel, *rootfs, *bin, *boardid, *chipid, *magic2, *ver, *tagid, *rsignature, *layoutver; uint32_t flashstart, fwoffset, loadaddr, entry; uint32_t fwaddr, flash_bs; int tagidfound = 0; - kernel = rootfs = bin = boardid = chipid = magic2 = ver = tagid = information = layoutver = NULL; + kernel = rootfs = bin = boardid = chipid = magic2 = ver = rsignature = layoutver = NULL; entry = 0; flashstart = DEFAULT_FLASH_START; @@ -445,11 +315,11 @@ int main(int argc, char **argv) loadaddr = IMAGETAG_DEFAULT_LOADADDR; flash_bs = DEFAULT_FLASH_BS; - printf("Broadcom image tagger - v0.2.0\n"); + printf("Broadcom image tagger - v1.0.0\n"); printf("Copyright (C) 2008 Axel Gembe\n"); - printf("Copyright (C) 2009 Daniel Dickinson\n"); + printf("Copyright (C) 2009-2010 Daniel Dickinson\n"); - while ((c = getopt(argc, argv, "i:f:o:b:c:s:n:v:m:k:l:e:h:t:d:y:")) != -1) { + while ((c = getopt(argc, argv, "i:f:o:b:c:s:n:v:m:k:l:e:h:r:y:")) != -1) { switch (c) { case 'i': kernel = optarg; @@ -487,11 +357,8 @@ int main(int argc, char **argv) case 'e': entry = strtoul(optarg, NULL, 16); break; - case 't': - tagid = optarg; - break; - case 'd': - information = optarg; + case 'r': + rsignature = optarg; break; case 'y': layoutver = optarg; @@ -511,9 +378,8 @@ int main(int argc, char **argv) fprintf(stderr, " -k - flash erase block size\n"); fprintf(stderr, " -l - Address where the kernel expects to be loaded (defaults to 0x80010000)\n"); fprintf(stderr, " -e - Address where the kernel entry point will end up\n"); - fprintf(stderr, " -t - type if imagetag to create, use 'list' to see available choices"); - fprintf(stderr, " -d - vendor specific information, for those that need it"); - fprintf(stderr, " -y - Flash Layout Version (2.2x code versions need this)"); + fprintf(stderr, " -r - vendor specific signature, for those that need it"); + fprintf(stderr, " -y - Flash Layout Version (2.2x code versions need this)"); fprintf(stderr, " -h - Displays this text\n\n"); return 1; } @@ -529,38 +395,6 @@ int main(int argc, char **argv) return 1; } - tagidfound = 0; - if (!tagid) { - fprintf(stderr, "You must specify a tagid (-t)\n"); - } else { - if (strncmp(tagid, "list", 4) == 0) { - fprintf(stderr, "\n----------------------------------------\n"); - fprintf(stderr, "\tAvailable tagId:"); - fprintf(stderr, "\n\n"); - for (i = 0; i < NUM_TAGID; i++) { - fprintf(stderr, "\t%s\t%s", tagidtab[i].tagid, tagidtab[i].tagiddesc); - } - fprintf(stderr, "\n----------------------------------------\n"); - return 0; - } - } - - if (tagid) { - for(i = 0; i < NUM_TAGID; i++) { - if (strncmp(tagid, tagidtab[i].tagid, TAGID_LEN) == 0) { - tagidfound = 1; - break; - } - } - if (!tagidfound) { - if (tagid) { - fprintf(stderr, "The tagid you selected '%s' does't exist.\n", tagid); - } - fprintf(stderr, "Use -t list to see the list of available ids"); - return 1; - } - } - /* Fallback to defaults */ fwaddr = flashstart + fwoffset; @@ -584,5 +418,5 @@ int main(int argc, char **argv) } - return tagfile(kernel, rootfs, bin, boardid, chipid, fwaddr, loadaddr, entry, ver, magic2, flash_bs, tagid, information, layoutver); + return tagfile(kernel, rootfs, bin, boardid, chipid, fwaddr, loadaddr, entry, ver, magic2, flash_bs, rsignature, layoutver); } -- 2.30.2