brcm63xx: add Livebox 1 firmware image generation
[openwrt.git] / target / linux / brcm63xx / image / Makefile
index 0e59ab5..1913feb 100755 (executable)
@@ -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,18 +86,53 @@ 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
 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
        $(MAKE) -C lzma-loader clean
 endef
@@ -298,9 +322,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
@@ -336,6 +366,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))