[ar71xx] dir-825-b1: Fix wholeflash images: Attempting to flash a wholeflash (-openwr...
authorDaniel Dickinson <crazycshore@gmail.com>
Mon, 17 Sep 2012 14:17:12 +0000 (14:17 +0000)
committerDaniel Dickinson <crazycshore@gmail.com>
Mon, 17 Sep 2012 14:17:12 +0000 (14:17 +0000)
SVN-Revision: 33447

target/linux/ar71xx/base-files/etc/diag.sh
target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration
target/linux/ar71xx/base-files/etc/uci-defaults/leds
target/linux/ar71xx/base-files/etc/uci-defaults/network
target/linux/ar71xx/base-files/lib/ar71xx.sh
target/linux/ar71xx/base-files/lib/upgrade/platform.sh
target/linux/ar71xx/generic/profiles/d-link.mk
target/linux/ar71xx/image/Makefile
target/linux/ar71xx/patches-3.3/640-MIPS-ath79-dir-825-b1-for-owrt-board-def.patch

index 570bdcb845a37d210ee426d651ee4bd3ba9f98a9..52176a85794164acd904f3910eb97287dc5b91e0 100755 (executable)
@@ -65,7 +65,8 @@ get_status_led() {
                status_led="d-link:green:status"
                ;;
        dir-825-b1 |\
-       dir-825-b1-openwrt |\
+       dir-825-b1-towholeflash |\
+       dir-825-b1-wholeflash |\
        dir-825-b1-stock)
                status_led="d-link:orange:power"
                ;;
index 750ff405d339faa342ccd425602367c4f9c5137b..486e4ed7b8c7ab896fd20ae5c38bd4acf1981386 100644 (file)
@@ -44,12 +44,13 @@ getifmac() {
 }
 
 case "$board" in
-dir-825-b1)
+dir-825-b1-towholeflash)
        mac1="$(getcalmac caldata 65440)"
        mac1="$(calcmacX "$mac1" 2)"
        mac2="$(calcmacX "$mac1" 1)"
 
        if grep -q '"owrt_caldata"' /proc/mtd && [ "$mac1" = "$(getifmac eth0)" ] && [ "$mac2" = "$(getifmac eth1)" ]; then
+               mtd erase owrt_caldata
                dd if=/dev/$(findmtd caldata) of=/dev/$(findmtd owrt_caldata) bs=65536 count=1
        fi
        ;;
@@ -58,6 +59,7 @@ dir-825-b1-tostock)
        mac1="$(calcmacX "$mac1" 2)"
        mac2="$(calcmacX "$mac1" 1)"
        if grep -q '"owrt_caldata"' /proc/mtd && [ "$mac1" = "$(getifmac eth0)" ] && [ "$mac2" = "$(getifmac eth1)" ]; then
+               mtd erase caldata
                dd if=/dev/$(findmtd owrt_caldata) of=/dev/$(findmtd caldata) bs=65536 count=1
        fi
        ;;
index 5e2e9acfb76ce6941b9eff3778d524a0feacb3b8..e8daba594a93f570b6af3e6df7ab3df1e807d00c 100755 (executable)
@@ -54,7 +54,10 @@ dir-615-e4)
        ucidef_set_led_switch "lan4" "LAN4" "d-link:green:lan4" "switch0" "0x10"
        ;;
 
-dir-825-b1)
+dir-825-b1|\
+dir-825-b1-towholeflash|\
+dir-825-b1-wholeflash|\
+dir-825-b1-tostock)
        ucidef_set_led_usbdev "usb" "USB" "d-link:blue:usb" "1-1"
        ;;
 
index f749cc668b2b2e6fadc48c118c228e41c8de6245..0b7c6a2400f4f0c5361ae0768fd58adb4e969b4f 100755 (executable)
@@ -33,7 +33,8 @@ rb-2011uas-2hnd)
        ;;
 
 dir-825-b1|\
-dir-825-b1-openwrt|\
+dir-825-b1-towholeflash|\
+dir-825-b1-wholeflash|\
 dir-825-b1-tostock|\
 tew-673gru)
        ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
index 8db983039ce16501c2c50a427d1c6defcd713e1e..2b083e192055ad08a570e10bc183a350e847a869 100755 (executable)
@@ -201,8 +201,11 @@ ar71xx_board_detect() {
        *"DIR-825 rev. B1")
                name="dir-825-b1"
                ;;
-       *"DIR-825 rev. B1 OpenWrt")
-               name="dir-825-b1-openwrt"
+       *"DIR-825 rev. B1 WHOLEFLASH")
+               name="dir-825-b1-wholeflash"
+               ;;
+       *"DIR-825 rev. B1 TOWHOLEFLASH")
+               name="dir-825-b1-towholeflash"
                ;;
        *"DIR-825 rev. B1 TOSTOCK")
                name="dir-825-b1-tostock"
index 2992aed3221d16789b812c5dc749e556fc1f8119..9987b2442e1c019a27cc1b46efbe456eafc0087a 100755 (executable)
@@ -101,7 +101,8 @@ platform_check_image() {
        dir-615-c1 | \
        dir-615-e4 | \
        dir-825-b1 | \
-       dir-825-b1-openwrt | \
+       dir-825-b1-towholeflash | \
+       dir-825-b1-wholeflash | \
        dir-825-b1-tostock | \
        ew-dorin | \
        ew-dorin-router | \
index 1691cade2fddb3d0542fa7133a37bbc8a0ae075d..8fcc77f0f100c9719d0a072b15f040e598084139 100644 (file)
@@ -68,28 +68,46 @@ endef
 
 define Profile/DIR825B1/Description
        Package set optimized for the D-Link DIR-825 rev. B1.
+       WARNING: Flashing wholeflash (openwrt optimized) image may brick your router
+       .  This will occur if your openwrt optimized image is larger than the
+       maximum size for a regular dir-825 b1 image (a little more than 6MB).
+       Please flash a TOWHOLEFLASH image instead of this image before flashing
+a 
+       WHOLEFLASH image.
+endef
+
+$(eval $(call Profile,DIR825B1))
+
+define Profile/DIR825B1_TOWHOLEFLASH
+       NAME:=D-Link DIR-825 rev. B1 designed for transition to image using whole flash
+       PACKAGES:=kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev
+endef
+
+define Profile/DIR825B1_TOWHOLEFLASH/Description
+       Package set optimized for the D-Link DIR-825 rev. B1. design for transtion to
+       image using whole flash.
        Copies the calibration data to the last erase block so that, if desired,
        an image optimized for use with OpenWrt (access to full flash) can be flashed.
 endef
 
-$(eval $(call Profile,DIR825B1))
+$(eval $(call Profile,DIR825B1_TOWHOLEFLASH))
 
-define Profile/DIR825B1_OPENWRT
-       NAME:=D-Link DIR-825 rev. B1 optimized for OpenWrt
+define Profile/DIR825B1_WHOLEFLASH
+       NAME:=D-Link DIR-825 rev. B1 optimized for OpenWrt which uses full 8M flash
        PACKAGES:=kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev
 endef
 
-define Profile/DIR825B1_OPENWRT/Description
-       Package set optimized for the D-Link DIR-825 rev. B1. running OpenWrt
+define Profile/DIR825B1_WHOLEFLASH/Description
+       Package set optimized for the D-Link DIR-825 rev. B1. using wholeflash
        Can only be flashed from OpenWrt because it requires that the calibration data
        be on the last sector of the flash (which the 'standard' version that can be flashed from
        stock will ensure).     
 endef
 
-$(eval $(call Profile,DIR825B1_OPENWRT))
+$(eval $(call Profile,DIR825B1_WHOLEFLASH))
 
 define Profile/DIR825B1_TOSTOCK
-       NAME:=D-Link DIR-825 rev. B1 that undoes OpenWrt optimization
+       NAME:=D-Link DIR-825 rev. B1 that undoes OpenWrt optimization (i.e. wholeflash)
        PACKAGES:=kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-ledtrig-usbdev
 endef
 
index ce24988b24356d77b50e3dd9e9a418d778e89db4..0d474d3374a117366480994cbf3ef96ac4c89037 100644 (file)
@@ -170,8 +170,9 @@ cameo7240_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,960k(kernel),275
 cameo913x_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,960k(kernel),2880k(rootfs),64k(art)ro,3840k@0x30000(firmware)
 cameo933x_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,896k(kernel),2752k(rootfs),3648k@0x70000(firmware)
 db120_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
-dir825b1_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),5184k(rootfs),64k(caldata)ro,1536k(unknown)ro,64k(owrt_caldata),6208k@0x50000(firmware)
-dir825b1_openwrt_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),6784k(rootfs),64k(caldata)ro,7808k@0x50000(firmware)
+dir825b1_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),5184k(rootfs),64k(caldata)ro,1600k(unknown)ro,6208k@0x50000(firmware)
+dir825b1_towholeflash_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),5184k(rootfs),64k(caldata)ro,1536k(unknown)ro,64k(owrt_caldata),7808k@0x50000(firmware)
+dir825b1_wholeflash_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),6784k(rootfs),64k(caldata)ro,7808k@0x50000(firmware)
 ew-dorin_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),1024k(kernel),2688k(rootfs),64k(art),3712k@0x50000(firmware)
 dir825b1_tostock_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),5184k(rootfs),64k(caldata),1536k(unknown)ro,64k(owrt_caldata)ro,6208k@0x50000(firmware)
 pb92_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
@@ -220,8 +221,27 @@ define Image/Build/DIR825B1
        fi
 endef
 
-define Image/Build/DIR825B1_OPENWRT
-       $(call MkuImageLzma,$(2),$(3) $(dir825b1_openwrt_mtdlayout))
+define Image/Build/DIR825B1_TOWHOLEFLASH
+       $(call MkuImageLzma,$(2),$(3) $(dir825b1_towholeflash_mtdlayout))
+       $(call Sysupgrade/KRuImage,$(1),$(2),1048576,5308416)
+       if [ -e "$(call sysupname,$(1),$(2))" ]; then \
+               ( \
+                       dd if=$(call sysupname,$(1),$(2)); \
+                       echo -n "$(4)"; \
+               ) > $(call imgname,$(1),$(2))-backup-loader.bin; \
+               if [ `stat -c%s $(call sysupname,$(1),$(2))` -gt 4194304 ]; then \
+                       echo "Warning: $(call sysupname,$(1),$(2)) is too big"; \
+               else \
+                       ( \
+                               dd if=$(call sysupname,$(1),$(2)) bs=4096k conv=sync; \
+                               echo -n "$(5)"; \
+                       ) > $(call factoryname,$(1),$(2)); \
+               fi; \
+       fi
+endef
+
+define Image/Build/DIR825B1_WHOLEFLASH
+       $(call MkuImageLzma,$(2),$(3) $(dir825b1_wholeflash_mtdlayout))
        $(call Sysupgrade/KRuImage,$(1),$(2),1048576,6946816)
 endef
 
@@ -769,7 +789,8 @@ $(eval $(call SingleProfile,Cameo933x,$(fs_squash),TEW712BR,tew-712br,TEW-712BR,
 $(eval $(call SingleProfile,CyberTAN,$(fs_64k),WRT160NL,wrt160nl,WRT160NL,ttyS0,115200,1.00.01))
 
 $(eval $(call SingleProfile,DIR825B1,$(fs_64k),DIR825B1,dir-825-b1,DIR-825-B1,ttyS0,115200,01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
-$(eval $(call SingleProfile,DIR825B1_OPENWRT,$(fs_64k),DIR825B1_OPENWRT,dir-825-b1-openwrt,DIR-825-B1_OPENWRT,ttyS0,115200,01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
+$(eval $(call SingleProfile,DIR825B1_TOWHOLEFLASH,$(fs_64k),DIR825B1_TOWHOLEFLASH,dir-825-b1-towholeflash,DIR-825-B1_TOWHOLEFLASH,ttyS0,115200,01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
+$(eval $(call SingleProfile,DIR825B1_WHOLEFLASH,$(fs_64k),DIR825B1_WHOLEFLASH,dir-825-b1-wholeflash,DIR-825-B1_WHOLEFLASH,ttyS0,115200,01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
 $(eval $(call SingleProfile,DIR825B1_TOSTOCK,$(fs_64k),DIR825B1_TOSTOCK,dir-825-b1-tostock,DIR-825-B1_TOSTOCK,ttyS0,115200,01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
 $(eval $(call SingleProfile,DIR825B1,$(fs_64k),TEW673GRU,tew-637gru,TEW-673GRU,ttyS0,115200,01AP94-AR7161-RT-080619-01,00AP94-AR7161-RT-080619-01))
 
@@ -861,7 +882,7 @@ $(eval $(call SingleProfile,ZyXEL,$(fs_64k),NBG_460N_550N_550NH,nbg460n_550n_550
 
 
 $(eval $(call MultiProfile,AP121,AP121_2M AP121_4M))
-$(eval $(call MultiProfile,DIR825B1_ALL,DIR825B1 DIR825B1_OPENWRT DIR825B1_TOSTOCK))
+$(eval $(call MultiProfile,DIR825B1_ALL,DIR825B1 DIR825B1_TOWHOLEFLASH DIR825B1_WHOLEFLASH DIR825B1_TOSTOCK))
 $(eval $(call MultiProfile,EWDORIN, EWDORINAP EWDORINRT))
 $(eval $(call MultiProfile,TEW652BRP,TEW652BRP_FW TEW652BRP_RECOVERY))
 $(eval $(call MultiProfile,TLWA901,TLWA901NV1 TLWA901NV2))
index c3c383b0aeb16c4e3513ddae248f2e659ac55436..4afd72aa330e99821fa7d4831833428c8692383f 100644 (file)
@@ -4,11 +4,11 @@
  #define DIR825B1_MAC_LOCATION_0                       0x1f66ffa0
  #define DIR825B1_MAC_LOCATION_1                       0x1f66ffb4
  
-+#define DIR825B1_OPENWRT_CAL_LOCATION_0               0x1f7f1000
-+#define DIR825B1_OPENWRT_CAL_LOCATION_1               0x1f7f5000
++#define DIR825B1_WHOLEFLASH_CAL_LOCATION_0            0x1f7f1000
++#define DIR825B1_WHOLEFLASH_CAL_LOCATION_1            0x1f7f5000
 +
-+#define DIR825B1_OPENWRT_MAC_LOCATION_0               0x1f7fffa0
-+#define DIR825B1_OPENWRT_MAC_LOCATION_1               0x1f7fffb4
++#define DIR825B1_WHOLEFLASH_MAC_LOCATION_0            0x1f7fffa0
++#define DIR825B1_WHOLEFLASH_MAC_LOCATION_1            0x1f7fffb4
 +
  static struct gpio_led dir825b1_leds_gpio[] __initdata = {
        {
@@ -30,7 +30,7 @@
  
        ath79_register_mdio(0, 0x0);
  
-@@ -165,9 +171,27 @@ static void __init dir825b1_setup(void)
+@@ -165,9 +171,30 @@ static void __init dir825b1_setup(void)
        ap9x_pci_setup_wmac_led_pin(0, 5);
        ap9x_pci_setup_wmac_led_pin(1, 5);
  
 +              DIR825B1_CAL_LOCATION_0, DIR825B1_CAL_LOCATION_1);
 +}
 +
-+static void __init dir825b1_openwrt_setup(void)
++static void __init dir825b1_wholeflash_setup(void)
 +{
-+      dir825b1_common_setup(DIR825B1_OPENWRT_MAC_LOCATION_0, DIR825B1_OPENWRT_MAC_LOCATION_1,
-+              DIR825B1_OPENWRT_CAL_LOCATION_0, DIR825B1_OPENWRT_CAL_LOCATION_1);
++      dir825b1_common_setup(DIR825B1_WHOLEFLASH_MAC_LOCATION_0, DIR825B1_WHOLEFLASH_MAC_LOCATION_1,
++              DIR825B1_WHOLEFLASH_CAL_LOCATION_0, DIR825B1_WHOLEFLASH_CAL_LOCATION_1);
  }
  
  MIPS_MACHINE(ATH79_MACH_DIR_825_B1, "DIR-825-B1", "D-Link DIR-825 rev. B1",
             dir825b1_setup);
 +
-+MIPS_MACHINE(ATH79_MACH_DIR_825_B1_OPENWRT, "DIR-825-B1_OPENWRT", "D-Link DIR-825 rev. B1 OpenWrt",
-+           dir825b1_openwrt_setup);
++MIPS_MACHINE(ATH79_MACH_DIR_825_B1_TOWHOLEFLASH, "DIR-825-B1_TOWHOLEFLASH", "D-Link DIR-825 rev. B1 TOWHOLEFLASH",
++           dir825b1_setup);
 +
-+MIPS_MACHINE(ATH79_MACH_DIR_825_B1_TOSTOCK, "DIR-825-B1_TOSTOCK", "D-Link DIR-825 rev. B1 TOSTOCK", dir825b1_openwrt_setup);
++MIPS_MACHINE(ATH79_MACH_DIR_825_B1_WHOLEFLASH, "DIR-825-B1_WHOLEFLASH", "D-Link DIR-825 rev. B1 WHOLEFLASH",
++           dir825b1_wholeflash_setup);
++
++MIPS_MACHINE(ATH79_MACH_DIR_825_B1_TOSTOCK, "DIR-825-B1_TOSTOCK", "D-Link DIR-825 rev. B1 TOSTOCK", dir825b1_wholeflash_setup);
 +
 --- a/arch/mips/ath79/machtypes.h
 +++ b/arch/mips/ath79/machtypes.h
-@@ -35,6 +35,8 @@ enum ath79_mach_type {
+@@ -35,6 +35,9 @@ enum ath79_mach_type {
        ATH79_MACH_DIR_615_C1,          /* D-Link DIR-615 rev. C1 */
        ATH79_MACH_DIR_615_E4,          /* D-Link DIR-615 rev. E4 */
        ATH79_MACH_DIR_825_B1,          /* D-Link DIR-825 rev. B1 */
-+      ATH79_MACH_DIR_825_B1_OPENWRT,  /* D-Link DIR-825 rev. B1 OpenWrt */
++      ATH79_MACH_DIR_825_B1_TOWHOLEFLASH, /* D-Link DIR-825 rev. B1 TOWHOLEFLASH */
++      ATH79_MACH_DIR_825_B1_WHOLEFLASH, /* D-Link DIR-825 rev. B1 WHOLEFLASH */
 +      ATH79_MACH_DIR_825_B1_TOSTOCK,  /* D-Link DIR-825 rev. B1 TOSTOCK */
        ATH79_MACH_EW_DORIN,            /* embedded wireless Dorin Platform */
        ATH79_MACH_EW_DORIN_ROUTER,     /* embedded wireless Dorin Router Platform */