brcm63xx: Add BT Home Hub 2A support.
[openwrt.git] / target / linux / brcm63xx / image / Makefile
index d467d8c..bae025f 100755 (executable)
@@ -7,7 +7,7 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
 
-LOADADDR = 0x80010000          # RAM start + 64K
+LOADADDR = 0x80800000          # RAM start + 8MB
 KERNEL_ENTRY = $(LOADADDR)     # Newer kernels add a jmp to the kernel_entry at the start of the binary
 RAMSIZE = 0x02000000           # 32MB
 LZMA_TEXT_START = 0x81800000   # 32MB - 8MB
@@ -38,17 +38,6 @@ TARGET_IMAGES:=
 TARGET_Default_DTBS:=
 TARGET_Default_IMAGES:=
 
-define Image/Build/CFE
-       # Generate the tagged image
-       $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
-               --output $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin \
-               --boardid $(2) --chipid $(3) --entry $(KERNEL_ENTRY) \
-               --load-addr $(LOADADDR) --rsa-signature "$(5)" \
-               --info1 "-$(call Image/LimitName16,$(4))" --info2 $(1) \
-               $(call rootfspad/$(1)) \
-               $(6) $(7) $(8) $(9)
-endef
-
 define Image/Build/CFEDTB
        # Generate the tagged image
        $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux-$(3).lzma.cfe -f $(KDIR)/root.$(1) \
@@ -97,16 +86,52 @@ define Image/Build/ZYXCFEDTB
 endef
 
 define Image/Build/RedBootDTB
+       # Prepare kernel and rootfs
        gzip -9 -c $(KDIR)/vmlinux-$(3) > $(KDIR)/vmlinux-$(3).bin.gz
-       $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux-$(3) $(KDIR)/vmlinux-$(3).bin.l7
-       dd if=$(KDIR)/vmlinux-$(3).bin.l7 of=$(BIN_DIR)/openwrt-$(2)-vmlinux.lzma bs=65536 conv=sync
        dd if=$(KDIR)/vmlinux-$(3).bin.gz of=$(BIN_DIR)/openwrt-$(2)-vmlinux.gz bs=65536 conv=sync
+       dd if=$(KDIR)/root.squashfs of="$(BIN_DIR)/openwrt-$(2)-root.squashfs" bs=64k conv=sync
+       echo -ne \\xDE\\xAD\\xC0\\xDE >> "$(BIN_DIR)/openwrt-$(2)-root.squashfs"
+       # Generate the scripted image
+       $(CP) ./redbootscript.template $(BIN_DIR)/redbootscript
+       let \
+               kernellen="$$$$(stat -c%s $(BIN_DIR)/openwrt-$(2)-vmlinux.gz)" \
+               rootfsdatalen="$$$$(stat -c %s $(BIN_DIR)/openwrt-$(2)-root.squashfs)" \
+               rootfsaddr="0xBE430000 + kernellen" \
+               rootfslen="0xBEBF0000 - rootfsaddr" \
+               offset2="0x1000 + kernellen"; \
+               $(SED)  "s,%loadaddr,$(strip $(LOADADDR)),g" \
+                       -e "s,%kernellen,$$$$(printf '%#x' $$$$kernellen),g" \
+                       -e "s,%offset2,$$$$(printf '%#x' $$$$offset2),g" \
+                       -e "s,%rootfsdatalen,$$$$(printf '%#x' $$$$rootfsdatalen),g" \
+                       -e "s,%rootfsaddr,$$$$(printf '%#x' $$$$rootfsaddr),g" \
+                       -e "s,%rootfslen,$$$$(printf '%#x' $$$$rootfslen),g" \
+               "$(BIN_DIR)/redbootscript"
+
+       dd if="$(BIN_DIR)/redbootscript" of="$(BIN_DIR)/redbootscript.padded" bs=4096 conv=sync
+       cat \
+               "$(BIN_DIR)/redbootscript.padded" \
+               "$(BIN_DIR)/openwrt-$(2)-vmlinux.gz" \
+               "$(BIN_DIR)/openwrt-$(2)-root.squashfs" \
+               > "$(BIN_DIR)/openwrt-$(2)-redboot.bin"
 endef
 
 define Image/Build/HCSDTB
+       # Generate the image
        $(STAGING_DIR_HOST)/bin/hcsmakeimage --magic_byte=$(4) \
                --rev_maj=$(5) --rev_min=$(6) --input_file=$(KDIR)/$(7) \
-               --output_file=$(BIN_DIR)/openwrt-$(2)-$(1).bin
+               --output_file=$(BIN_DIR)/openwrt-$(2)-$(1).bin \
+               --ldaddress=$(LOADADDR)
+endef
+
+define Image/Build/ChkDTB
+       # Generate Netgear factory image
+       $(STAGING_DIR_HOST)/bin/mkchkimg -o $(BIN_DIR)/openwrt-$(2)-$(1)-factory.chk \
+       -k $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin -b $(5) -r $(6)
+endef
+
+define Image/Build/Dummy
+       # for boards without a flashable image yet
+       true
 endef
 
 define Build/Clean
@@ -199,9 +224,6 @@ endef
 define Image/Build
        dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
 
-       # BT Voyager V2500V, V2500V_SIP_CLUB, V2500V_AA
-       $(call Image/Build/CFE,$(1),V2500V_BB,6348,BTV2500V,,--layoutver 5)
-
        # build dtb image list
        $(foreach image,$(TARGET_$(PROFILE)_IMAGES),$(call Image/Build/$(image),$(1)))
 
@@ -253,6 +275,10 @@ $(eval $(call ImageDTB,CFEDTB,RG100A,RG100A,rg100a,96358VW2,6358,--block-size 0x
 $(eval $(call ImageDTB,CFEDTB,AR1004G,AR1004G,ar1004g,96348GW-10,6348))
 # Belkin F5D7633
 $(eval $(call ImageDTB,CFEDTB,F5D7633,F5D7633,f5d7633,96348GW-10,6348,--block-size 0x20000 --image-offset 0x20000))
+# BT Home Hub 2.0 A
+$(eval $(call ImageDTB,CFEDTB,BTHOMEHUB2A,HomeHub2A,homehub2a,HOMEHUB2A,6358,--image-offset 0x20000 --block-size 0x20000))
+# BT Voyager V2500V, V2500V_SIP_CLUB, V2500V_AA
+$(eval $(call ImageDTB,CFEDTB,BTV2500V,BTV2500V,v2500v-bb,V2500V_BB,6348,--layoutver 5))
 # Comtrend AR-5381u
 $(eval $(call ImageDTB,CFEDTB,AR5381u,AR-5381u,ar-5381u,96328A-1241N,6328,--pad 8))
 # Comtrend AR-5387un
@@ -299,9 +325,15 @@ $(eval $(call ImageDTB,CFEDTB,HG556a_C,HG556a_C,hg556a-c,HW556,6358,--rsa-signat
 # Inventel Livebox 1
 $(eval $(call ImageDTB,RedBootDTB,Livebox,livebox,livebox-blue-5g))
 # Netgear CVG834G
-$(eval $(call ImageDTB,HCSDTB,CVG834G,,cvg834g,a020,0001,0022,vmlinux-cvg834g))
+$(eval $(call ImageDTB,Dummy,CVG834G,cvg834g,cvg834g,a020,0001,0022,vmlinux-cvg834g))
 # Netgear DG834GT/PN
 $(eval $(call ImageDTB,CFEDTB,DG834GTPN,DG834GT_PN,dg834gtpn,96348GW-10,6348))
+# Netgear DGND3700 v1 / DGND3800B
+$(eval $(call ImageDTB,CFEDTB,DGND3700v1_3800B,DGND3700v1_3800B,dgnd3700v1,96368MVWG,6368,--image-offset 0x20000 --block-size 0x20000))
+#Netgear DGND3700 v1 factory firmware
+$(eval $(call ImageDTB,ChkDTB,DGND3700v1_3800B,DGND3700v1,,DGND3700v1_3800B,U12L144T01_NETGEAR_NEWLED,1))
+#Netgear DGND3800B factory firmware
+$(eval $(call ImageDTB,ChkDTB,DGND3700v1_3800B,DGND3800B,,DGND3700v1_3800B,U12L144T11_NETGEAR_NEWLED,1))
 # Pirelli Alice Gate VoIP 2 Plus Wi-Fi AGPF-S0
 $(eval $(call ImageDTB,CFEDTB,AGPF_S0,AGV2+W,agpf-s0,AGPF-S0,6358,--block-size 0x20000 --image-offset 0x20000 --signature2 IMAGE --tag-version 8))
 # Pirelli A226G
@@ -337,6 +369,6 @@ $(eval $(call ImageDTB,CFEDTB,TDW8900GB,TD-W8900GB,td-w8900gb,96348GW-11,6348,--
 # USRobotics 9108
 $(eval $(call ImageDTB,CFEDTB,USR9108,USR9108,usr9108,96348GW-A,6348))
 # ZyXEL P870HW-51a v2
-$(eval $(call ImageDTB,ZYXCFEDTB,P870HW_51a_v2,96368VVW,p870hw-51a-v2,6368,P870HW-51a_v2,--rsa-signature "ZyXEL" --signature "ZyXEL_0001"))
+$(eval $(call ImageDTB,ZYXCFEDTB,P870HW_51a_v2,P870HW-51a_v2,p870hw-51a-v2,96368VVW,6368,--rsa-signature "ZyXEL" --signature "ZyXEL_0001"))
 
 $(eval $(call BuildImage))