[OpenWrt-Devel] [PATCH] ramips: add support for Airlink101 AR670W

Claudio Leite leitec at staticky.com
Fri Oct 31 21:51:37 EDT 2014


This is a RT2880-based board, 32MB RAM, 4MB flash. The bootloader
is a hacked u-Boot that reads an LZMA image directly, so we skip
generating the uImage header and enable the lzma mtdsplit parser.

Signed-off-by: Claudio Leite <leitec at staticky.com>
---
 target/linux/ramips/base-files/etc/board.d/01_leds |   5 +-
 .../linux/ramips/base-files/etc/board.d/02_network |   1 +
 target/linux/ramips/base-files/etc/diag.sh         |   3 +
 target/linux/ramips/base-files/lib/ramips.sh       |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh      |   7 ++
 target/linux/ramips/dts/AR670W.dts                 | 103 +++++++++++++++++++++
 target/linux/ramips/image/Makefile                 |  27 ++++++
 target/linux/ramips/rt288x/config-3.14             |   1 +
 8 files changed, 147 insertions(+), 3 deletions(-)
 create mode 100644 target/linux/ramips/dts/AR670W.dts

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
index 4a482b3..bd8c779 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -41,12 +41,11 @@ case $board in
 		ucidef_set_led_rssi "rssihigh" "RSSIHIGH" "all0256n:green:rssihigh" "wlan0" "70" "100" "-69" "8"
 		set_wifi_led "rt2800pci-phy0::radio"
 		;;
+	ar670w|\
+	ar725w|\
 	awapn2403)
 		set_wifi_led "rt2800soc-phy0::radio"
 		;;
-	ar725w)
-		set_wifi_led "rt2800soc-phy0::radio"
-		;;
 	asl26555)
 		ucidef_set_led_default "power" "POWER" "asl26555:green:power" "1"
 		ucidef_set_led_netdev "eth" "ETH" "asl26555:green:eth" "eth0"
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
index 1c7d80c..cedcb8b 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -157,6 +157,7 @@ ramips_setup_interfaces()
 		ucidef_add_switch_vlan "switch0" "2" "0 5t"
 		;;
 
+	ar670w | \
 	ar725w | \
 	rt-n15 | \
 	wl-351)
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
index 2977099..709158b 100755
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -12,6 +12,9 @@ get_status_led() {
 	3g300m | w150m)
 		status_led="tenda:blue:ap"
 		;;
+	ar670w)
+		status_led="ar670w:green:power"
+		;;
 	ar725w)
 		status_led="ar725w:green:power"
 		;;
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index e3977aa..a02bcf9 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -28,6 +28,9 @@ ramips_board_detect() {
 	*"A5-V11")
 		name="a5-v11"
 		;;
+	*"Airlink101 AR670W")
+		name="ar670w"
+		;;
 	*"Airlink101 AR725W")
 		name="ar725w"
 		;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 4fe0ef4..decbc54 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -110,6 +110,13 @@ platform_check_image() {
 		}
 		return 0
 		;;
+	ar670w)
+		[ "$magic" != "6d000080" ] && {
+			echo "Invalid image type."
+			return 1
+		}
+		return 0
+		;;
 	cy-swr1100 |\
 	dir-610-a1 |\
 	dir-645)
diff --git a/target/linux/ramips/dts/AR670W.dts b/target/linux/ramips/dts/AR670W.dts
new file mode 100644
index 0000000..07497cb
--- /dev/null
+++ b/target/linux/ramips/dts/AR670W.dts
@@ -0,0 +1,103 @@
+/dts-v1/;
+
+/include/ "rt2880.dtsi"
+
+/ {
+	compatible = "AR670W", "ralink,rt2880-soc";
+	model = "Airlink101 AR670W";
+
+	palmbus at 300000 {
+		gpio0: gpio at 600 {
+			status = "okay";
+		};
+	};
+
+	pinctrl {
+		state_default: pinctrl0 {
+			gpio {
+				ralink,group = "i2c", "spi", "uartlite";
+				ralink,function = "gpio";
+			};
+		};
+	};
+
+	ethernet at 400000 {
+		status = "okay";
+		mtd-mac-address = <&factory 0x2004>;
+
+		port at 0 {
+			phy-handle = <&phy0>;
+			phy-mode = "mii";
+		};
+
+		mdio-bus {
+			status = "okay";
+			phy0: ethernet-phy at 0 {
+				phy-mode = "mii";
+				reg = <0>;
+			};
+		};
+	};
+
+	wmac at 480000 {
+		status = "okay";
+		ralink,mtd-eeprom = <&factory 0x2000>;
+	};
+
+	cfi at bdc00000 {
+		compatible = "cfi-flash";
+		reg = <0xbc400000 0x800000>;
+
+		bank-width = <2>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		u-boot at 0 {
+			reg = <0x0 0x30000>;
+			label = "u-boot";
+			read-only;
+		};
+
+		factory: factory at 30000 {
+			reg = <0x30000 0x10000>;
+			label = "factory";
+			read-only;
+		};
+
+		firmware at 40000 {
+			reg = <0x40000 0x3c0000>;
+			label = "firmware";
+		};
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		status {
+			label = "ar670w:green:power";
+			gpios = <&gpio0 7 1>;
+		};
+
+		wpsblue {
+			label = "ar670w:blue:wps";
+			gpios = <&gpio0 13 1>;
+		};
+	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <100>;
+		wps {
+			label = "wps";
+			gpios = <&gpio0 0 1>;
+			linux,code = <0x211>;
+		};
+		reset {
+			label = "reset";
+			gpios = <&gpio0 9 1>;
+			linux,code = <0x198>;
+		};
+	};
+};
diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile
index 759de53..1f03386 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -295,10 +295,36 @@ define BuildFirmware/Gemtek/squashfs
 endef
 BuildFirmware/Gemtek/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
 
+# Airlink101 AR670W -- LZMA without uImage header
+define BuildFirmware/AR670W/squashfs
+	$(call PatchKernelLzmaDtb,$(2),$(3),$(5))
+
+	$(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-$(if $(4),$(4),sysupgrade).bin)
+	$(eval factory_name=$(IMG_PREFIX)-$(2)-$(1)-factory.bin)
+
+	( dd if=$(KDIR)/vmlinux-$(2).bin.lzma bs=65536 \
+		conv=sync; dd if=$(KDIR)/root.$(1) ) > $(KDIR)/$(output_name)
+
+	$(call prepare_generic_squashfs,$(KDIR)/$(output_name))
+
+	if [ `stat -c%s "$(KDIR)/$(output_name)"` \
+		-gt $(ralink_default_fw_size_4M) ]; then \
+		echo "Warning: $(KDIR)/$(output_name) is too big" >&2; \
+	else \
+		mkwrgimg -i $(KDIR)/$(output_name) \
+			-d "/dev/mtdblock/2" \
+			-s "wrgn16a_airlink_ar670w" \
+			-o $(BIN_DIR)/$(factory_name); \
+		$(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name); \
+	fi
+endef
+
 #
 # RT288X Profiles
 #
 
+Image/Build/Profile/AR670W=$(call BuildFirmware/AR670W/$(1),$(1),ar670w,AR670W)
+
 Image/Build/Profile/AR725W=$(call BuildFirmware/Gemtek/$(1),$(1),ar725w,AR725W)
 
 # 0x790000
@@ -313,6 +339,7 @@ Image/Build/Profile/WLITX4AG300N=$(call BuildFirmware/Default4M/$(1),$(1),wli-tx
 
 ifeq ($(SUBTARGET),rt288x)
 define Image/Build/Profile/Default
+	$(call Image/Build/Profile/AR670W,$(1))
 	$(call Image/Build/Profile/AR725W,$(1))
 	$(call Image/Build/Profile/F5D8235V1,$(1))
 	$(call Image/Build/Profile/RTN15,$(1))
diff --git a/target/linux/ramips/rt288x/config-3.14 b/target/linux/ramips/rt288x/config-3.14
index 44bb310..9a95186 100644
--- a/target/linux/ramips/rt288x/config-3.14
+++ b/target/linux/ramips/rt288x/config-3.14
@@ -107,6 +107,7 @@ CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_M25P80=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPLIT_FIRMWARE=y
+CONFIG_MTD_SPLIT_LZMA_FW=y
 CONFIG_MTD_UIMAGE_SPLIT=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NEED_PER_CPU_KM=y
-- 
2.1.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list