From 0f254b4b67b400e093b8e8e0e22144dbdddcb7ad Mon Sep 17 00:00:00 2001 From: Daniel Dickinson Date: Mon, 17 Sep 2012 14:17:12 +0000 Subject: dir-825-b1: Fix wholeflash images: Attempting to flash a wholeflash (-openwrt) image from the normal image would brick (but recoverable via emergency flash) the router if the wholeflash image was larger than the maximum size for a normal image. First we rename the -openwrt images to -wholeflash since -openwrt is really too generic. We also revert the changes to the regular dir-825-b1 image, which now is the same as before, but add a -towholeflash image which is almost the same as the regular dir-825-b1 image, but copies caldata to new location and allows flashing of images that use the full flash (except u-boot, u-boot-env, and caldata paritition space) (these are the -wholeflash images). SVN-Revision: 33447 --- target/linux/ar71xx/base-files/etc/diag.sh | 3 +- .../base-files/etc/uci-defaults/caldata-migration | 4 ++- .../linux/ar71xx/base-files/etc/uci-defaults/leds | 5 +++- .../ar71xx/base-files/etc/uci-defaults/network | 3 +- target/linux/ar71xx/base-files/lib/ar71xx.sh | 7 +++-- .../ar71xx/base-files/lib/upgrade/platform.sh | 3 +- target/linux/ar71xx/generic/profiles/d-link.mk | 32 ++++++++++++++++----- target/linux/ar71xx/image/Makefile | 33 ++++++++++++++++++---- ...-MIPS-ath79-dir-825-b1-for-owrt-board-def.patch | 30 +++++++++++--------- 9 files changed, 87 insertions(+), 33 deletions(-) (limited to 'target') diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 570bdcb845..52176a8579 100755 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -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" ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration b/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration index 750ff405d3..486e4ed7b8 100644 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/caldata-migration @@ -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 ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/leds b/target/linux/ar71xx/base-files/etc/uci-defaults/leds index 5e2e9acfb7..e8daba594a 100755 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/leds +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/leds @@ -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" ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/network b/target/linux/ar71xx/base-files/etc/uci-defaults/network index f749cc668b..0b7c6a2400 100755 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/network +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/network @@ -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" diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 8db983039c..2b083e1920 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -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" diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 2992aed322..9987b2442e 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -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 | \ diff --git a/target/linux/ar71xx/generic/profiles/d-link.mk b/target/linux/ar71xx/generic/profiles/d-link.mk index 1691cade2f..8fcc77f0f1 100644 --- a/target/linux/ar71xx/generic/profiles/d-link.mk +++ b/target/linux/ar71xx/generic/profiles/d-link.mk @@ -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 diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index ce24988b24..0d474d3374 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -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)) diff --git a/target/linux/ar71xx/patches-3.3/640-MIPS-ath79-dir-825-b1-for-owrt-board-def.patch b/target/linux/ar71xx/patches-3.3/640-MIPS-ath79-dir-825-b1-for-owrt-board-def.patch index c3c383b0ae..4afd72aa33 100644 --- a/target/linux/ar71xx/patches-3.3/640-MIPS-ath79-dir-825-b1-for-owrt-board-def.patch +++ b/target/linux/ar71xx/patches-3.3/640-MIPS-ath79-dir-825-b1-for-owrt-board-def.patch @@ -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); @@ -46,27 +46,31 @@ + 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 */ -- cgit v1.2.3