diff mbox

[OpenWrt-Devel,v4,ramips] mt7621: add support for netis WF-2881‏

Message ID BLU436-SMTP164FCC921A58B3C1C6601F1D0070@phx.gbl
State Accepted
Headers show

Commit Message

YounJaeRho Nov. 23, 2015, 1:01 p.m. UTC
netis WF-2881 is an MT7621AT based router with MT7602EN, MT7612EN.
It has 128MB DDR3, 128MB SLC NAND FLASH, 5-port Gbps switch and 1x USB 3.0.
The following patch adds support for this device.

this device only works on top of UBI.

Tested and working:
* ethernet
* both WiFi radios
* USB 3.0
* buttons (reset button)
* ethernet switch and USB diag LEDs
* UART
* GPIOs
* sysupgrade

Tested and not working
* failsafe


Signed-off-by: YounJae Rho <luxflow@live.com>
---
tested with git-am (trunk d1104b7ae3de77093756c0124e4946745c06c2f1)


 target/linux/ramips/Makefile                       |   2 +-
 target/linux/ramips/base-files/etc/board.d/01_leds |   3 +-
 .../linux/ramips/base-files/etc/board.d/02_network |   1 +
 target/linux/ramips/base-files/etc/diag.sh         |   1 +
 target/linux/ramips/base-files/lib/ramips.sh       |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh      |   1 +
 target/linux/ramips/dts/WF-2881.dts                | 133 +++++++++++++++++++++
 target/linux/ramips/image/Makefile                 |  11 +-
 target/linux/ramips/mt7621/config-3.18             |  24 +++-
 target/linux/ramips/mt7621/profiles/netis.mk       |  23 ++++
 10 files changed, 198 insertions(+), 4 deletions(-)
 create mode 100644 target/linux/ramips/dts/WF-2881.dts
 create mode 100644 target/linux/ramips/mt7621/profiles/netis.mk

Comments

Srdjan Rosic Nov. 24, 2015, 11:01 p.m. UTC | #1
not to be a spoil sport, I like seeing new devices supported, but this
one (commit id 5baf40d) causes a dependency of mtd/nand to be pulled
in, which has some bugs from before, which breaks the build at least
for ramips

I haven't tried other nand arches to see if they build at this same commit.

Maybe git revert 5baf40d would be a good thing to do until we figure
out how build is broken?

That is unless you already have an idea?

Do you have a commit where this patch worked, so we can perhaps bisect?

--------------

  LD      fs/built-in.o
  LD      crypto/built-in.o
  CC      drivers/mtd/nand/mtk_nand.o
drivers/mtd/nand/mtk_nand.c:113:25: error: 'NAND_MAX_OOBSIZE'
undeclared here (not in a function)
 static u8 local_oob_buf[NAND_MAX_OOBSIZE];
                         ^
drivers/mtd/nand/mtk_nand.c: In function 'mtk_nand_erase_hw':
drivers/mtd/nand/mtk_nand.c:1425:6: error: 'struct nand_chip' has no
member named 'erase_cmd'
  chip->erase_cmd(mtd, page);
      ^
drivers/mtd/nand/mtk_nand.c: At top level:
drivers/mtd/nand/mtk_nand.c:113:11: warning: 'local_oob_buf' defined
but not used [-Wunused-variable]
 static u8 local_oob_buf[NAND_MAX_OOBSIZE];
           ^
drivers/mtd/nand/mtk_nand.c:1392:1: warning: 'mtk_nand_read_page'
defined but not used [-Wunused-function]
 mtk_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, u8 *
buf, int page)
 ^
drivers/mtd/nand/mtk_nand.c:1431:1: warning: 'mtk_nand_erase' defined
but not used [-Wunused-function]
 mtk_nand_erase(struct mtd_info *mtd, int page)
 ^
drivers/mtd/nand/mtk_nand.c: In function 'mtk_nand_write_oob_hw':
drivers/mtd/nand/mtk_nand.c:1647:1: warning: control reaches end of
non-void function [-Wreturn-type]
 }
 ^
scripts/Makefile.build:257: recipe for target
'drivers/mtd/nand/mtk_nand.o' failed
make[8]: *** [drivers/mtd/nand/mtk_nand.o] Error 1
scripts/Makefile.build:402: recipe for target 'drivers/mtd/nand' failed
make[7]: *** [drivers/mtd/nand] Error 2

--------------


Thank you,
-risk
YounJaeRho Nov. 24, 2015, 11:28 p.m. UTC | #2
After git commit
a7ff0259c76b39c10898403f3c8e3590cae64e95
(in trunk)

Building works well

Could you check this again?

2015-11-25 오전 8:01에 Srdjan Rosic 이(가) 쓴 글:
> not to be a spoil sport, I like seeing new devices supported, but this
> one (commit id 5baf40d) causes a dependency of mtd/nand to be pulled
> in, which has some bugs from before, which breaks the build at least
> for ramips
> 
> I haven't tried other nand arches to see if they build at this same commit.
> 
> Maybe git revert 5baf40d would be a good thing to do until we figure
> out how build is broken?
> 
> That is unless you already have an idea?
> 
> Do you have a commit where this patch worked, so we can perhaps bisect?
> 
> --------------
> 
>   LD      fs/built-in.o
>   LD      crypto/built-in.o
>   CC      drivers/mtd/nand/mtk_nand.o
> drivers/mtd/nand/mtk_nand.c:113:25: error: 'NAND_MAX_OOBSIZE'
> undeclared here (not in a function)
>  static u8 local_oob_buf[NAND_MAX_OOBSIZE];
>                          ^
> drivers/mtd/nand/mtk_nand.c: In function 'mtk_nand_erase_hw':
> drivers/mtd/nand/mtk_nand.c:1425:6: error: 'struct nand_chip' has no
> member named 'erase_cmd'
>   chip->erase_cmd(mtd, page);
>       ^
> drivers/mtd/nand/mtk_nand.c: At top level:
> drivers/mtd/nand/mtk_nand.c:113:11: warning: 'local_oob_buf' defined
> but not used [-Wunused-variable]
>  static u8 local_oob_buf[NAND_MAX_OOBSIZE];
>            ^
> drivers/mtd/nand/mtk_nand.c:1392:1: warning: 'mtk_nand_read_page'
> defined but not used [-Wunused-function]
>  mtk_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, u8 *
> buf, int page)
>  ^
> drivers/mtd/nand/mtk_nand.c:1431:1: warning: 'mtk_nand_erase' defined
> but not used [-Wunused-function]
>  mtk_nand_erase(struct mtd_info *mtd, int page)
>  ^
> drivers/mtd/nand/mtk_nand.c: In function 'mtk_nand_write_oob_hw':
> drivers/mtd/nand/mtk_nand.c:1647:1: warning: control reaches end of
> non-void function [-Wreturn-type]
>  }
>  ^
> scripts/Makefile.build:257: recipe for target
> 'drivers/mtd/nand/mtk_nand.o' failed
> make[8]: *** [drivers/mtd/nand/mtk_nand.o] Error 1
> scripts/Makefile.build:402: recipe for target 'drivers/mtd/nand' failed
> make[7]: *** [drivers/mtd/nand] Error 2
> 
> --------------
> 
> 
> Thank you,
> -risk
>
Srdjan Rosic Nov. 25, 2015, 12:50 a.m. UTC | #3
It looks like the problem was on my end, I was trying to rebase my
patches onto trunk, and I suspect that as I rebased, make didn't pick
up that before and after rebase patches have changed in the src tree
as part of the a7ff025 commit, and the kernel in build_dir needed to
be re-patched. Running
  make target/linux/{clean,prepare} V=s QUILT=1
caused the patches to be reapplied, including a7ff025, which enables
the build to happen,

Sorry for the noise,
-risk
Srdjan Rosic


On Tue, Nov 24, 2015 at 11:28 PM, YounJae Rho <luxflow@live.com> wrote:
> After git commit
> a7ff0259c76b39c10898403f3c8e3590cae64e95
> (in trunk)
>
> Building works well
>
> Could you check this again?
>
> 2015-11-25 오전 8:01에 Srdjan Rosic 이(가) 쓴 글:
>> not to be a spoil sport, I like seeing new devices supported, but this
>> one (commit id 5baf40d) causes a dependency of mtd/nand to be pulled
>> in, which has some bugs from before, which breaks the build at least
>> for ramips
>>
>> I haven't tried other nand arches to see if they build at this same commit.
>>
>> Maybe git revert 5baf40d would be a good thing to do until we figure
>> out how build is broken?
>>
>> That is unless you already have an idea?
>>
>> Do you have a commit where this patch worked, so we can perhaps bisect?
>>
>> --------------
>>
>>   LD      fs/built-in.o
>>   LD      crypto/built-in.o
>>   CC      drivers/mtd/nand/mtk_nand.o
>> drivers/mtd/nand/mtk_nand.c:113:25: error: 'NAND_MAX_OOBSIZE'
>> undeclared here (not in a function)
>>  static u8 local_oob_buf[NAND_MAX_OOBSIZE];
>>                          ^
>> drivers/mtd/nand/mtk_nand.c: In function 'mtk_nand_erase_hw':
>> drivers/mtd/nand/mtk_nand.c:1425:6: error: 'struct nand_chip' has no
>> member named 'erase_cmd'
>>   chip->erase_cmd(mtd, page);
>>       ^
>> drivers/mtd/nand/mtk_nand.c: At top level:
>> drivers/mtd/nand/mtk_nand.c:113:11: warning: 'local_oob_buf' defined
>> but not used [-Wunused-variable]
>>  static u8 local_oob_buf[NAND_MAX_OOBSIZE];
>>            ^
>> drivers/mtd/nand/mtk_nand.c:1392:1: warning: 'mtk_nand_read_page'
>> defined but not used [-Wunused-function]
>>  mtk_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, u8 *
>> buf, int page)
>>  ^
>> drivers/mtd/nand/mtk_nand.c:1431:1: warning: 'mtk_nand_erase' defined
>> but not used [-Wunused-function]
>>  mtk_nand_erase(struct mtd_info *mtd, int page)
>>  ^
>> drivers/mtd/nand/mtk_nand.c: In function 'mtk_nand_write_oob_hw':
>> drivers/mtd/nand/mtk_nand.c:1647:1: warning: control reaches end of
>> non-void function [-Wreturn-type]
>>  }
>>  ^
>> scripts/Makefile.build:257: recipe for target
>> 'drivers/mtd/nand/mtk_nand.o' failed
>> make[8]: *** [drivers/mtd/nand/mtk_nand.o] Error 1
>> scripts/Makefile.build:402: recipe for target 'drivers/mtd/nand' failed
>> make[7]: *** [drivers/mtd/nand] Error 2
>>
>> --------------
>>
>>
>> Thank you,
>> -risk
>>
diff mbox

Patch

diff --git a/target/linux/ramips/Makefile b/target/linux/ramips/Makefile
index eafd274..a92b287 100644
--- a/target/linux/ramips/Makefile
+++ b/target/linux/ramips/Makefile
@@ -10,7 +10,7 @@  ARCH:=mipsel
 BOARD:=ramips
 BOARDNAME:=Ralink RT288x/RT3xxx
 SUBTARGETS:=rt305x mt7620 mt7621 mt7628 mt7688 rt3883 rt288x
-FEATURES:=squashfs gpio
+FEATURES:=squashfs gpio ubifs
 MAINTAINER:=John Crispin <blogic@openwrt.org>
 
 KERNEL_PATCHVER:=3.18
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 5627c8c..a365c61 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -44,7 +44,8 @@  air3gii)
 all0239-3g|\
 hw550-3g|\
 mofi3500-3gn|\
-sap-g3200u3)
+sap-g3200u3|\
+wf-2881)
 	set_usb_led "$board:green:usb"
 	;;
 all0256n)
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 3821742..45778f3 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -78,6 +78,7 @@  ramips_setup_interfaces()
 	oy-0001|\
 	pbr-m1|\
 	sap-g3200u3|\
+	wf-2881|\
 	whr-300hp2|\
 	whr-600d|\
 	wsr-1166|\
diff --git a/target/linux/ramips/base-files/etc/diag.sh b/target/linux/ramips/base-files/etc/diag.sh
index 3013d24..ff5fbf2 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -155,6 +155,7 @@  get_status_led() {
 	tew-692gr|\
 	ur-326n4g|\
 	ur-336un|\
+	wf-2881|\
 	wr512-3gn)
 		status_led="$board:green:wps"
 		;;
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index a1bcb72..eb2f194 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -376,6 +376,9 @@  ramips_board_detect() {
 	*"WCR-150GN")
 		name="wcr-150gn"
 		;;
+	*"WF-2881")
+		name="wf-2881"
+		;;
 	*"WHR-1166D")
 		name="whr-1166d"
 		;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 0e8d619..19ab5a2 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -108,6 +108,7 @@  platform_check_image() {
 	w150m|\
 	w306r-v20|\
 	w502u|\
+	wf-2881|\
 	whr-1166d|\
 	whr-300hp2|\
 	whr-600d|\
diff --git a/target/linux/ramips/dts/WF-2881.dts b/target/linux/ramips/dts/WF-2881.dts
new file mode 100644
index 0000000..7228dc5
--- /dev/null
+++ b/target/linux/ramips/dts/WF-2881.dts
@@ -0,0 +1,133 @@ 
+/dts-v1/;
+
+/include/ "mt7621.dtsi"
+
+/ {
+	compatible = "mediatek,mt7621-eval-board", "mediatek,mt7621-soc";
+	model = "NETIS WF-2881";
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x8000000>;
+	};
+
+	palmbus@1E000000 {
+		spi@b00 {
+			status="disabled";
+		};
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,57600";
+	};
+
+	nand@1e003000 {
+		compatible = "mtk,mt7621-nand";
+		bank-width = <2>;
+		reg = <0x1e003000 0x800
+				0x1e003800 0x800>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "u-boot";
+			reg = <0x0 0x30000>;
+			read-only;
+		};
+
+		partition@30000 {
+			label = "u-boot-env";
+			reg = <0x30000 0x1000>;
+			read-only;
+		};
+
+		partition@80000 {
+			label = "config";
+			reg = <0x80000 0x80000>;
+			read-only;
+		};
+
+		factory: partition@100000 {
+			label = "factory";
+			reg = <0x100000 0x40000>;
+			read-only;
+		};
+
+		firmware {
+			label = "firmware";
+			reg = <0x140000 0x6EC0000>;
+		};
+
+		partition@140000 {
+			label = "kernel";
+			reg = <0x140000 0x200000>;
+		};
+
+		partition@340000 {
+			label = "ubi";
+			reg = <0x340000 0x6CC0000>;
+		};
+	};
+
+	pcie@1e140000 {
+		status = "okay";
+
+		pcie0 {
+			mt76@0,0 {
+				reg = <0x0000 0 0 0 0>;
+				device_type = "pci";
+				mediatek,mtd-eeprom = <&factory 0x8000>;
+				mediatek,2ghz = <0>;
+			};
+		};
+
+		pcie1 {
+			mt76@1,0 {
+				reg = <0x0000 0 0 0 0>;
+				device_type = "pci";
+				mediatek,mtd-eeprom = <&factory 0x0000>;
+				mediatek,5ghz = <0>;
+			};
+		};
+	};
+
+	ethernet@1e100000 {
+		mtd-mac-address = <&factory 0xe006>;
+	};
+
+	gpio-leds {
+		compatible = "gpio-leds";
+
+		usb {
+			label = "wf-2881:green:usb";
+			gpios = <&gpio0 6 1>;
+		};
+
+		wps {
+			label = "wf-2881:green:wps";
+			gpios = <&gpio0 0 1>;
+		};
+	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <20>;
+
+		reset {
+			label = "reset";
+			gpios = <&gpio0 12 1>;
+			linux,code = <0x198>;
+		};
+	};
+
+	pinctrl {
+		state_default: pinctrl0 {
+			gpio {
+				ralink,group = "uart3", "jtag";
+				ralink,function = "gpio";
+			};
+		};
+	};
+};
diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile
index 5e19c3f..6e7b3a5 100644
--- a/target/linux/ramips/image/Makefile
+++ b/target/linux/ramips/image/Makefile
@@ -952,7 +952,7 @@  endif
 #
 
 ifeq ($(SUBTARGET),mt7621)
-  TARGET_DEVICES += mt7621 wsr-600 wsr-1166 dir-860l-b1 firewrt pbr-m1 re6500 sap-g3200u3 zbt-wg2626
+  TARGET_DEVICES += mt7621 wsr-600 wsr-1166 dir-860l-b1 firewrt pbr-m1 re6500 sap-g3200u3 zbt-wg2626 wf-2881
 endif
 
 define Device/mt7621
@@ -1007,6 +1007,15 @@  define Device/zbt-wg2626
   IMAGE_SIZE := $(ralink_default_fw_size_16M)
 endef
 
+define Device/wf-2881
+  DTS := WF-2881
+  BLOCKSIZE := 128KiB
+  PAGESIZE := 2048
+  KERNEL_SIZE := 2097152
+  FILESYSTEMS := squashfs
+  IMAGE/sysupgrade.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size $$$$(IMAGE_SIZE)
+endef
+
 #
 # MT7628 Profiles
 #
diff --git a/target/linux/ramips/mt7621/config-3.18 b/target/linux/ramips/mt7621/config-3.18
index fb05d1e..13ff9f8 100644
--- a/target/linux/ramips/mt7621/config-3.18
+++ b/target/linux/ramips/mt7621/config-3.18
@@ -36,6 +36,11 @@  CONFIG_CPU_RMAP=y
 CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
 CONFIG_CPU_SUPPORTS_HIGHMEM=y
 CONFIG_CPU_SUPPORTS_MSA=y
+CONFIG_CRC16=y
+CONFIG_CRYPTO_DEFLATE=y
+CONFIG_CRYPTO_LZO=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
 CONFIG_CSRC_R4K=y
 CONFIG_DEBUG_PINCTRL=y
 CONFIG_DMA_NONCOHERENT=y
@@ -102,6 +107,8 @@  CONFIG_IRQ_FORCED_THREADING=y
 CONFIG_IRQ_GIC=y
 CONFIG_IRQ_WORK=y
 CONFIG_LIBFDT=y
+CONFIG_LZO_COMPRESS=y
+CONFIG_LZO_DECOMPRESS=y
 CONFIG_MDIO_BOARDINFO=y
 CONFIG_MIPS=y
 CONFIG_MIPS_CM=y
@@ -117,18 +124,26 @@  CONFIG_MIPS_MT_FPAFF=y
 CONFIG_MIPS_MT_SMP=y
 CONFIG_MIPS_PERF_SHARED_TC_COUNTERS=y
 # CONFIG_MIPS_VPE_LOADER is not set
-# CONFIG_MTK_MTD_NAND is not set
 CONFIG_MODULES_USE_ELF_REL=y
 CONFIG_MT7621_WDT=y
 # CONFIG_MTD_CFI_INTELEXT is not set
 CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_ECC=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_SPI_NOR=y
 CONFIG_MTD_SPLIT_FIRMWARE=y
 CONFIG_MTD_SPLIT_SEAMA_FW=y
 CONFIG_MTD_SPLIT_TRX_FW=y
 CONFIG_MTD_SPLIT_UIMAGE_FW=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BEB_LIMIT=20
+CONFIG_MTD_UBI_BLOCK=y
+# CONFIG_MTD_UBI_FASTMAP is not set
+# CONFIG_MTD_UBI_GLUEBI is not set
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
+CONFIG_MTK_MTD_NAND=y
 CONFIG_NEED_DMA_MAP_STATE=y
 CONFIG_NET_FLOW_LIMIT=y
 CONFIG_NET_RALINK=y
@@ -209,9 +224,16 @@  CONFIG_SYS_SUPPORTS_SCHED_SMT=y
 CONFIG_SYS_SUPPORTS_SMP=y
 CONFIG_TICK_CPU_ACCOUNTING=y
 CONFIG_TREE_RCU=y
+CONFIG_UBIFS_FS=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+CONFIG_UBIFS_FS_LZO=y
+# CONFIG_UBIFS_FS_XZ is not set
+CONFIG_UBIFS_FS_ZLIB=y
 CONFIG_USB_SUPPORT=y
 CONFIG_USE_OF=y
 CONFIG_WATCHDOG_CORE=y
 CONFIG_WEAK_ORDERING=y
 CONFIG_XPS=y
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_ZLIB_INFLATE=y
 CONFIG_ZONE_DMA_FLAG=0
diff --git a/target/linux/ramips/mt7621/profiles/netis.mk b/target/linux/ramips/mt7621/profiles/netis.mk
new file mode 100644
index 0000000..39b524f
--- /dev/null
+++ b/target/linux/ramips/mt7621/profiles/netis.mk
@@ -0,0 +1,23 @@ 
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/WF-2881
+	NAME:=NETIS WF-2881
+	PACKAGES:=\
+		kmod-usb-core kmod-usb3 kmod-usb-hid \
+		kmod-ledtrig-usbdev
+endef
+
+define Profile/WF-2881/Description
+	Package set compatible with the NETIS WF-2881 board.
+endef
+
+#-m <min io size> -e <LEB size> -c <Eraseblocks count>
+WF-2881_UBIFS_OPTS:="-m 2048 -e 129024 -c 1024"
+WF-2881_UBI_OPTS:="-m 2048 -p 128KiB -s 512"
+
+$(eval $(call Profile,WF-2881))