From cf6f01c0e69a31afc6c5f384405ace51e03fe481 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Tue, 7 Jul 2020 10:32:09 +0200 Subject: [PATCH 01/55] build: conditionally enable testing-kernel feature Only enable the testing-kernel feature for the target when the testing kernel version does not match the stable kernel version. This way, the option for building the testing kernel in the build config menu is only exposed when there's a testing kernel available. Signed-off-by: David Bauer Acked-by: Adrian Schmutzler --- include/target.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/target.mk b/include/target.mk index a2ceb7f783..64292138b7 100644 --- a/include/target.mk +++ b/include/target.mk @@ -223,7 +223,9 @@ ifeq ($(DUMP),1) .PRECIOUS: $(TMP_CONFIG) ifdef KERNEL_TESTING_PATCHVER - FEATURES += testing-kernel + ifneq ($(KERNEL_TESTING_PATCHVER),$(KERNEL_PATCHVER)) + FEATURES += testing-kernel + endif endif ifneq ($(CONFIG_OF),) FEATURES += dt From d8ab3216e688e3f810bf2d3109ad85a805582076 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Thu, 2 Apr 2020 21:53:59 +0200 Subject: [PATCH 02/55] ath79: switch to kernel 5.4 As the reported major bugs are ironed out, switch to the new kernel to begin testing with a broader audience. Signed-off-by: David Bauer Acked-by: Hauke Mehrtens --- target/linux/ath79/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ath79/Makefile b/target/linux/ath79/Makefile index 9b203cf48e..a955602ba9 100644 --- a/target/linux/ath79/Makefile +++ b/target/linux/ath79/Makefile @@ -8,7 +8,7 @@ SUBTARGETS:=generic mikrotik nand tiny FEATURES:=ramdisk -KERNEL_PATCHVER:=4.19 +KERNEL_PATCHVER:=5.4 KERNEL_TESTING_PATCHVER:=5.4 include $(INCLUDE_DIR)/target.mk From 7cb721c03fdc163818f8114692229d0097d2f26b Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Tue, 7 Jul 2020 11:49:36 +0200 Subject: [PATCH 03/55] ramips: use WiFi LED DT triggers for TP-Link RE650 v1 This moves WiFi LED triggers from 01_leds to device tree. While at it, convert the labels there to lower case; this is more commonly used and the change will actually remove competition between DT trigger and leftover uci config on already installed systems. Suggested-by: Georgi Vlaev Signed-off-by: Adrian Schmutzler --- target/linux/ramips/dts/mt7621_tplink_re650-v1.dts | 6 ++++-- target/linux/ramips/mt7621/base-files/etc/board.d/01_leds | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/target/linux/ramips/dts/mt7621_tplink_re650-v1.dts b/target/linux/ramips/dts/mt7621_tplink_re650-v1.dts index ab8805f163..b7290635b9 100644 --- a/target/linux/ramips/dts/mt7621_tplink_re650-v1.dts +++ b/target/linux/ramips/dts/mt7621_tplink_re650-v1.dts @@ -23,13 +23,15 @@ }; wifi2g { - label = "re650-v1:blue:wifi2G"; + label = "re650-v1:blue:wifi2g"; gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; }; wifi5g { - label = "re650-v1:blue:wifi5G"; + label = "re650-v1:blue:wifi5g"; gpios = <&gpio 24 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; }; wps_red { diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 2e3dca7901..37ebd0fb64 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -68,14 +68,14 @@ netgear,r6800) ucidef_set_led_netdev "lan3" "LAN3" "$boardname:white:lan3" "lan3" ucidef_set_led_netdev "lan4" "LAN4" "$boardname:white:lan4" "lan4" ;; -tplink,re350-v1|\ -tplink,re650-v1) +tplink,re350-v1) ucidef_set_led_netdev "wifi2g" "Wifi 2.4G" "$boardname:blue:wifi2G" "wlan0" ucidef_set_led_netdev "wifi5g" "Wifi 5G" "$boardname:blue:wifi5G" "wlan1" ucidef_set_led_netdev "eth_act" "LAN act" "$boardname:green:eth_act" "lan" "tx rx" ucidef_set_led_netdev "eth_link" "LAN link" "$boardname:green:eth_link" "lan" "link" ;; -tplink,re500-v1) +tplink,re500-v1|\ +tplink,re650-v1) ucidef_set_led_netdev "eth_act" "LAN act" "$boardname:green:eth_act" "lan" "tx rx" ucidef_set_led_netdev "eth_link" "LAN link" "$boardname:green:eth_link" "lan" "link" ;; From 4e57fd5adaf0c937da1e947f32dfa9ae513637a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Wed, 1 Jul 2020 12:29:44 +0200 Subject: [PATCH 04/55] dropbear: make rsa-sha2-256 pubkeys usable again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream in commit 972d723484d8 ("split signkey_type and signature_type for RSA sha1 vs sha256") has added strict checking of pubkey algorithms which made keys with SHA-256 hashing algorithm unusable as they still reuse the `ssh-rsa` public key format. So fix this by disabling the check for `rsa-sha2-256` pubkeys. Ref: https://tools.ietf.org/html/rfc8332#section-3 Fixes: d4c80f5b172e ("dropbear: bump to 2020.80") Tested-by: Russell Senior Signed-off-by: Petr Štetiar --- ...nkey-fix-use-of-rsa-sha2-256-pubkeys.patch | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 package/network/services/dropbear/patches/910-signkey-fix-use-of-rsa-sha2-256-pubkeys.patch diff --git a/package/network/services/dropbear/patches/910-signkey-fix-use-of-rsa-sha2-256-pubkeys.patch b/package/network/services/dropbear/patches/910-signkey-fix-use-of-rsa-sha2-256-pubkeys.patch new file mode 100644 index 0000000000..afa0ebb310 --- /dev/null +++ b/package/network/services/dropbear/patches/910-signkey-fix-use-of-rsa-sha2-256-pubkeys.patch @@ -0,0 +1,40 @@ +From 667d9b75df86ec9ee1205f9101beb8dbbe4a00ae Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20=C5=A0tetiar?= +Date: Wed, 1 Jul 2020 11:38:33 +0200 +Subject: [PATCH] signkey: fix use of rsa-sha2-256 pubkeys +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit 972d723484d8 ("split signkey_type and signature_type for RSA sha1 +vs sha256") has added strict checking of pubkey algorithms which made +keys with SHA-256 hashing algorithm unusable as they still reuse the +`ssh-rsa` public key format. So fix this by disabling the check for +rsa-sha2-256 pubkeys. + +Ref: https://tools.ietf.org/html/rfc8332#section-3 +Fixes: 972d723484d8 ("split signkey_type and signature_type for RSA sha1 vs sha256") +Signed-off-by: Petr Štetiar +--- + signkey.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/signkey.c b/signkey.c +index 92fe6a242cd0..d16ab174d83a 100644 +--- a/signkey.c ++++ b/signkey.c +@@ -657,8 +657,12 @@ int buf_verify(buffer * buf, sign_key *key, enum signature_type expect_sigtype, + sigtype = signature_type_from_name(type_name, type_name_len); + m_free(type_name); + +- if (expect_sigtype != sigtype) { +- dropbear_exit("Non-matching signing type"); ++ if (sigtype == DROPBEAR_SIGNATURE_NONE) { ++ dropbear_exit("No signature type"); ++ } ++ ++ if ((expect_sigtype != DROPBEAR_SIGNATURE_RSA_SHA256) && (expect_sigtype != sigtype)) { ++ dropbear_exit("Non-matching signing type"); + } + + keytype = signkey_type_from_signature(sigtype); From 326e488c7b02fb291e0b01970db3482284307c8d Mon Sep 17 00:00:00 2001 From: Andrey Bondar Date: Fri, 26 Jun 2020 11:16:00 +0300 Subject: [PATCH 05/55] ath79: add support for 8devices Rambutan board MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rambutan is a Wifi module based on QCA9550/9557 http://www.8devices.com/products/rambutan Specification: - 720/600/200 MHz (CPU/DDR/AHB) - 128 MB of DDR2 RAM - 128 MB of NAND Flash - 1x 100Mbps Ethernet - 1x 1000Mbps Ethernet (PHY on dev-kit) - 1x Wifi radio 2x2 MIMO, dualband 2.4 and 5 GHz - 2x U.FL connectors on module, chip antennas on dev-kit - 1x miniPCIe slot - 2x USB2.0 host - 2x UART - SPI, I2C, GPIO Flash instructions: Upgrade from ar71xx target: sysupgrade -F /tmp/openwrt-ath79-nand-8dev_rambutan-squashfs-sysupgrade.tar or upgrade from GUI (don't save config) Use factory image to flash from U-Boot: tftpboot 80060000 openwrt-ath79-nand-8dev_rambutan-squashfs-factory.ubi nand erase.part ubi nand write 80060000 ubi ${filesize} Signed-off-by: Petr Štetiar [copy&pasted missing commit description] Signed-off-by: Andrey Bondar --- target/linux/ath79/config-4.19 | 1 + target/linux/ath79/config-5.4 | 1 + .../linux/ath79/dts/qca9557_8dev_rambutan.dts | 131 ++++++++++++++++++ target/linux/ath79/image/nand.mk | 15 ++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 3 + 5 files changed, 151 insertions(+) create mode 100644 target/linux/ath79/dts/qca9557_8dev_rambutan.dts diff --git a/target/linux/ath79/config-4.19 b/target/linux/ath79/config-4.19 index 92af6ba970..c1b15301ef 100644 --- a/target/linux/ath79/config-4.19 +++ b/target/linux/ath79/config-4.19 @@ -18,6 +18,7 @@ CONFIG_ARCH_USE_BUILTIN_BSWAP=y CONFIG_ARCH_USE_QUEUED_RWLOCKS=y CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_AT803X_PHY=y CONFIG_ATH79=y CONFIG_ATH79_WDT=y CONFIG_BLK_MQ_PCI=y diff --git a/target/linux/ath79/config-5.4 b/target/linux/ath79/config-5.4 index 449f42bba7..f0679933ae 100644 --- a/target/linux/ath79/config-5.4 +++ b/target/linux/ath79/config-5.4 @@ -23,6 +23,7 @@ CONFIG_ARCH_USE_QUEUED_RWLOCKS=y CONFIG_ARCH_USE_QUEUED_SPINLOCKS=y CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y +CONFIG_AT803X_PHY=y CONFIG_ATH79=y CONFIG_ATH79_WDT=y CONFIG_BLK_MQ_PCI=y diff --git a/target/linux/ath79/dts/qca9557_8dev_rambutan.dts b/target/linux/ath79/dts/qca9557_8dev_rambutan.dts new file mode 100644 index 0000000000..cf1c00c642 --- /dev/null +++ b/target/linux/ath79/dts/qca9557_8dev_rambutan.dts @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca955x.dtsi" + +/ { + compatible = "8dev,rambutan", "qca,qca9557"; + model = "8devices Rambutan"; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x300000>; + read-only; + }; + + partition@300000 { + label = "u-boot-env"; + reg = <0x300000 0x200000>; + }; + + art: partition@500000 { + label = "art"; + reg = <0x500000 0x100000>; + read-only; + }; + + partition@600000 { + label = "ubi"; + reg = <0x600000 0x7a00000>; + }; + }; +}; + +&mdio0 { + status = "okay"; + + phy0: ethernet-phy@0 { + reg = <0>; + reset-gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; +}; + +&mdio1 { + status = "okay"; + + phy1: ethernet-phy@0 { + reg = <0>; + reset-gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + phy-mode = "sgmii"; + at803x-override-sgmii-link-check; + }; +}; + +ð0 { + status = "okay"; + + mtd-mac-address = <&art 0x0>; + phy-mode = "mii"; + phy-handle = <&phy0>; +}; + +ð1 { + status = "okay"; + + pll-data = <0x17000000 0x101 0x1313>; + phy-handle = <&phy1>; + phy-mode = "sgmii"; + qca955x-sgmii-fixup; + mtd-mac-address = <&art 0x6>; +}; + +&wmac { + status = "okay"; + + gpio-controller; + mtd-cal-data = <&art 0x1000>; +}; + +&pcie0 { + status = "okay"; +}; + +&usb_phy0 { + status = "okay"; +}; + +&usb0 { + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; +}; + +&usb_phy1 { + status = "okay"; +}; + +&usb1 { + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; +}; + +&uart { + status = "okay"; +}; diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index dc06b65371..240d96729b 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -30,6 +30,21 @@ define Build/zyxel-factory fi endef +define Device/8dev_rambutan + SOC := qca9557 + DEVICE_VENDOR := 8devices + DEVICE_MODEL := Rambutan + DEVICE_PACKAGES := kmod-usb2 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + KERNEL_IN_UBI := 1 + IMAGES := factory.bin sysupgrade.tar + IMAGE/sysupgrade.tar := sysupgrade-tar | append-metadata + IMAGE/factory.bin := append-ubi +endef +TARGET_DEVICES += 8dev_rambutan + define Device/aerohive_hiveap-121 SOC := ar9344 DEVICE_VENDOR := Aerohive diff --git a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 355be93ead..60defa5f8b 100644 --- a/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -9,6 +9,9 @@ board=$(board_name) case "$FIRMWARE" in "ath9k-eeprom-ahb-18100000.wmac.bin") case $board in + 8dev,rambutan) + caldata_extract "caldata" 0x1000 0x800 + ;; netgear,wndr3700-v4|\ netgear,wndr4300|\ netgear,wndr4300sw|\ From ae2d249056bdd7b87169e7c14f54c0c464b1acc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Wed, 20 May 2020 12:11:12 +0200 Subject: [PATCH 06/55] ath79: nand: disable images for glinet_gl-ar750s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes following build failures: WARNING: Image file glinet_gl-ar750s-nor-kernel.bin is too big WARNING: Image file glinet_gl-ar750s-nor-nand-kernel.bin is too big Signed-off-by: Petr Štetiar --- target/linux/ath79/image/nand.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/ath79/image/nand.mk b/target/linux/ath79/image/nand.mk index 240d96729b..f7fc71d65e 100644 --- a/target/linux/ath79/image/nand.mk +++ b/target/linux/ath79/image/nand.mk @@ -134,6 +134,7 @@ define Device/glinet_gl-ar750s-nor-nand append-ubi | check-kernel-size $$$$(GL_UBOOT_UBI_OFFSET) IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata SUPPORTED_DEVICES += glinet,gl-ar750s-nor + DEFAULT := n endef TARGET_DEVICES += glinet_gl-ar750s-nor-nand @@ -142,6 +143,7 @@ define Device/glinet_gl-ar750s-nor DEVICE_VARIANT := NOR BLOCKSIZE := 64k SUPPORTED_DEVICES += gl-ar750s glinet,gl-ar750s glinet,gl-ar750s-nor-nand + DEFAULT := n endef TARGET_DEVICES += glinet_gl-ar750s-nor From 8fb0b15efde92de43f6bc52f60a5a5680b782d8e Mon Sep 17 00:00:00 2001 From: "Sergio E. Nemirowski" Date: Wed, 10 Jun 2020 04:33:21 +0300 Subject: [PATCH 07/55] build: add nconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for make target nconfig (ncurses) Reviewed-by: Eneas U de Queiroz Signed-off-by: Sergio E. Nemirowski Signed-off-by: Petr Štetiar --- include/toplevel.mk | 7 + scripts/config/Makefile | 15 +- scripts/config/README | 2 +- scripts/config/nconf-cfg.sh | 50 ++ scripts/config/nconf.c | 1569 +++++++++++++++++++++++++++++++++++ scripts/config/nconf.gui.c | 664 +++++++++++++++ scripts/config/nconf.h | 92 ++ 7 files changed, 2397 insertions(+), 2 deletions(-) create mode 100755 scripts/config/nconf-cfg.sh create mode 100644 scripts/config/nconf.c create mode 100644 scripts/config/nconf.gui.c create mode 100644 scripts/config/nconf.h diff --git a/include/toplevel.mk b/include/toplevel.mk index 5cf93ce7ef..ba59595764 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -141,6 +141,13 @@ menuconfig: scripts/config/mconf prepare-tmpinfo FORCE [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \ $< Config.in +nconfig: scripts/config/nconf prepare-tmpinfo FORCE + if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \ + cp $(HOME)/.openwrt/defconfig .config; \ + fi + [ -L .config ] && export KCONFIG_OVERWRITECONFIG=1; \ + $< Config.in + xconfig: scripts/config/qconf prepare-tmpinfo FORCE if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \ cp $(HOME)/.openwrt/defconfig .config; \ diff --git a/scripts/config/Makefile b/scripts/config/Makefile index d98f15c393..3082a65ceb 100644 --- a/scripts/config/Makefile +++ b/scripts/config/Makefile @@ -5,7 +5,7 @@ .PHONY: clean all all: conf mconf clean: - rm -f *.o lxdialog/*.o *.moc $(clean-files) conf mconf qconf + rm -f *.o lxdialog/*.o *.moc $(clean-files) conf mconf qconf nconf # This clean-files definition is here to ensure that temporary files from the # previous version are removed by make config-clean. @@ -52,6 +52,16 @@ HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) hostprogs-y += conf conf-objs := conf.o $(common-objs) +# nconf: Used for the nconfig target based on ncurses +hostprogs-y += nconf +nconf-objs := nconf.o nconf.gui.o $(common-objs) + +HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) +HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) +HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) + +$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg + # mconf: Used for the menuconfig target based on lxdialog hostprogs-y += mconf lxdialog := $(addprefix lxdialog/, \ @@ -123,5 +133,8 @@ conf: $(conf-objs) mconf: mconf-cfg $(mconf-objs) $(CC) -o $@ $(filter-out mconf-cfg,$^) $(HOSTLDLIBS_mconf) +nconf: nconf-cfg $(nconf-objs) + $(CC) -o $@ $(filter-out nconf-cfg,$^) $(HOSTLDLIBS_nconf) + qconf: qconf-cfg $(qconf-cxxobjs) $(qconf-objs) $(CXX) -o $@ $(filter-out qconf-cfg,$^) $(HOSTLDLIBS_qconf) diff --git a/scripts/config/README b/scripts/config/README index 1e94ee46f1..f402cdc746 100644 --- a/scripts/config/README +++ b/scripts/config/README @@ -1,7 +1,7 @@ These files were taken from the Linux Kernel Configuration System at commit 089b7d890f972f6b649fedc9259f6b93a18fb970 (Feb 4, 2020) and modified for the OpenWrt Buildroot: - - Removed nconf, gconf, tests and kernel configuration targets. + - Removed gconf, tests and kernel configuration targets. - Adjusted the Makefile to compile outside the kernel. - Always use default file when running make all{no,mod,yes}config. - Added a 'reset' command to reset config when the target changes. diff --git a/scripts/config/nconf-cfg.sh b/scripts/config/nconf-cfg.sh new file mode 100755 index 0000000000..c212255070 --- /dev/null +++ b/scripts/config/nconf-cfg.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +PKG="ncursesw menuw panelw" +PKG2="ncurses menu panel" + +if [ -n "$(command -v pkg-config)" ]; then + if pkg-config --exists $PKG; then + echo cflags=\"$(pkg-config --cflags $PKG)\" + echo libs=\"$(pkg-config --libs $PKG)\" + exit 0 + fi + + if pkg-config --exists $PKG2; then + echo cflags=\"$(pkg-config --cflags $PKG2)\" + echo libs=\"$(pkg-config --libs $PKG2)\" + exit 0 + fi +fi + +# Check the default paths in case pkg-config is not installed. +# (Even if it is installed, some distributions such as openSUSE cannot +# find ncurses by pkg-config.) +if [ -f /usr/include/ncursesw/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" + echo libs=\"-lncursesw -lmenuw -lpanelw\" + exit 0 +fi + +if [ -f /usr/include/ncurses/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" + echo libs=\"-lncurses -lmenu -lpanel\" + exit 0 +fi + +if [ -f /usr/include/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE\" + echo libs=\"-lncurses -lmenu -lpanel\" + exit 0 +fi + +echo >&2 "*" +echo >&2 "* Unable to find the ncurses package." +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev" +echo >&2 "* depending on your distribution)." +echo >&2 "*" +echo >&2 "* You may also need to install pkg-config to find the" +echo >&2 "* ncurses installed in a non-default location." +echo >&2 "*" +exit 1 diff --git a/scripts/config/nconf.c b/scripts/config/nconf.c new file mode 100644 index 0000000000..82ab7e3004 --- /dev/null +++ b/scripts/config/nconf.c @@ -0,0 +1,1569 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2008 Nir Tzachar + * + * Derived from menuconfig. + */ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include + +#include "lkc.h" +#include "nconf.h" +#include + +static const char nconf_global_help[] = +"Help windows\n" +"------------\n" +"o Global help: Unless in a data entry window, pressing will give \n" +" you the global help window, which you are just reading.\n" +"\n" +"o A short version of the global help is available by pressing .\n" +"\n" +"o Local help: To get help related to the current menu entry, use any\n" +" of , or if in a data entry window then press .\n" +"\n" +"\n" +"OpenWrt config is based on Kernel kconfig\n" +"so ipkg packages are referred here as modules.\n" +"\n" +"Menu entries\n" +"------------\n" +"This interface lets you select features and parameters for the build.\n" +"Features can either be built-in, modularized, or removed.\n" +"Parameters must be entered as text or decimal or hexadecimal numbers.\n" +"\n" +"Menu entries beginning with following braces represent features that\n" +" [ ] can be built in or removed\n" +" < > can be built in, modularized or removed\n" +" { } can be built in or modularized, are selected by another feature\n" +" - - are selected by another feature\n" +" XXX cannot be selected. Symbol Info tells you why.\n" +"*, M or whitespace inside braces means to build in, build as a module\n" +"or to exclude the feature respectively.\n" +"\n" +"To change any of these features, highlight it with the movement keys\n" +"listed below and press to build it in, to make it a module or\n" +" to remove it. You may press the key to cycle through the\n" +"available options.\n" +"\n" +"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n" +"empty submenu.\n" +"\n" +"Menu navigation keys\n" +"----------------------------------------------------------------------\n" +"Linewise up \n" +"Linewise down \n" +"Pagewise up \n" +"Pagewise down \n" +"First entry \n" +"Last entry \n" +"Enter a submenu \n" +"Go back to parent menu \n" +"Close a help window \n" +"Close entry window, apply \n" +"Close entry window, forget \n" +"Start incremental, case-insensitive search for STRING in menu entries,\n" +" no regex support, STRING is displayed in upper left corner\n" +" STRING\n" +" Remove last character \n" +" Jump to next hit \n" +" Jump to previous hit \n" +"Exit menu search mode \n" +"Search for configuration variables with or without leading CONFIG_\n" +" RegExpr\n" +"Verbose search help \n" +"----------------------------------------------------------------------\n" +"\n" +"Unless in a data entry window, key <1> may be used instead of ,\n" +"<2> instead of , etc.\n" +"\n" +"\n" +"Radiolist (Choice list)\n" +"-----------------------\n" +"Use the movement keys listed above to select the option you wish to set\n" +"and press .\n" +"\n" +"\n" +"Data entry\n" +"----------\n" +"Enter the requested information and press . Hexadecimal values\n" +"may be entered without the \"0x\" prefix.\n" +"\n" +"\n" +"Text Box (Help Window)\n" +"----------------------\n" +"Use movement keys as listed in table above.\n" +"\n" +"Press any of to exit.\n" +"\n" +"\n" +"Alternate configuration files\n" +"-----------------------------\n" +"nconfig supports switching between different configurations.\n" +"Press to save your current configuration. Press and enter\n" +"a file name to load a previously saved configuration.\n" +"\n" +"\n" +"Terminal configuration\n" +"----------------------\n" +"If you use nconfig in a xterm window, make sure your TERM environment\n" +"variable specifies a terminal configuration which supports at least\n" +"16 colors. Otherwise nconfig will look rather bad.\n" +"\n" +"If the \"stty size\" command reports the current terminalsize correctly,\n" +"nconfig will adapt to sizes larger than the traditional 80x25 \"standard\"\n" +"and display longer menus properly.\n" +"\n" +"\n" +"Single menu mode\n" +"----------------\n" +"If you prefer to have all of the menu entries listed in a single menu,\n" +"rather than the default multimenu hierarchy, run nconfig with\n" +"NCONFIG_MODE environment variable set to single_menu. Example:\n" +"\n" +"make NCONFIG_MODE=single_menu nconfig\n" +"\n" +" will then unfold the appropriate category, or fold it if it\n" +"is already unfolded. Folded menu entries will be designated by a\n" +"leading \"++>\" and unfolded entries by a leading \"-->\".\n" +"\n" +"Note that this mode can eventually be a little more CPU expensive than\n" +"the default mode, especially with a larger number of unfolded submenus.\n" +"\n", +menu_no_f_instructions[] = +"Legend: [*] built-in [ ] excluded module < > module capable.\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" +"\n" +"Use the following keys to navigate the menus:\n" +"Move up or down with and .\n" +"Enter a submenu with or .\n" +"Exit a submenu to its parent menu with or .\n" +"Pressing includes, excludes, modularizes features.\n" +"Pressing cycles through the available options.\n" +"To search for menu entries press .\n" +" always leaves the current window.\n" +"\n" +"You do not have function keys support.\n" +"Press <1> instead of , <2> instead of , etc.\n" +"For verbose global help use key <1>.\n" +"For help related to the current menu entry press or .\n", +menu_instructions[] = +"Legend: [*] built-in [ ] excluded module < > module capable.\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" +"\n" +"Use the following keys to navigate the menus:\n" +"Move up or down with or .\n" +"Enter a submenu with or .\n" +"Exit a submenu to its parent menu with or .\n" +"Pressing includes, excludes, modularizes features.\n" +"Pressing cycles through the available options.\n" +"To search for menu entries press .\n" +" always leaves the current window.\n" +"\n" +"Pressing <1> may be used instead of , <2> instead of , etc.\n" +"For verbose global help press .\n" +"For help related to the current menu entry press or .\n", +radiolist_instructions[] = +"Press , , or to navigate a radiolist, select\n" +"with .\n" +"For help related to the current entry press or .\n" +"For global help press .\n", +inputbox_instructions_int[] = +"Please enter a decimal value.\n" +"Fractions will not be accepted.\n" +"Press to apply, to cancel.", +inputbox_instructions_hex[] = +"Please enter a hexadecimal value.\n" +"Press to apply, to cancel.", +inputbox_instructions_string[] = +"Please enter a string value.\n" +"Press to apply, to cancel.", +setmod_text[] = +"This feature depends on another feature which has been configured as a\n" +"module. As a result, the current feature will be built as a module too.", +load_config_text[] = +"Enter the name of the configuration file you wish to load.\n" +"Accept the name shown to restore the configuration you last\n" +"retrieved. Leave empty to abort.", +load_config_help[] = +"For various reasons, one may wish to keep several different\n" +"configurations available on a single machine.\n" +"\n" +"If you have saved a previous configuration in a file other than the\n" +"default one, entering its name here will allow you to load and modify\n" +"that configuration.\n" +"\n" +"Leave empty to abort.\n", +save_config_text[] = +"Enter a filename to which this configuration should be saved\n" +"as an alternate. Leave empty to abort.", +save_config_help[] = +"For various reasons, one may wish to keep several different\n" +"configurations available on a single machine.\n" +"\n" +"Entering a file name here will allow you to later retrieve, modify\n" +"and use the current configuration as an alternate to whatever\n" +"configuration options you have selected at that time.\n" +"\n" +"Leave empty to abort.\n", +search_help[] = +"Search for symbols (configuration variable names CONFIG_*) and display\n" +"their relations. Regular expressions are supported.\n" +"Example: Search for \"^FOO\".\n" +"Result:\n" +"-----------------------------------------------------------------\n" +"Symbol: FOO [ = m]\n" +"Prompt: Foo bus is used to drive the bar HW\n" +"Defined at drivers/pci/Kconfig:47\n" +"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n" +"Location:\n" +" -> Bus options (PCI, PCMCIA, EISA, ISA)\n" +" -> PCI support (PCI [ = y])\n" +" -> PCI access mode ( [ = y])\n" +"Selects: LIBCRC32\n" +"Selected by: BAR\n" +"-----------------------------------------------------------------\n" +"o The line 'Prompt:' shows the text displayed for this symbol in\n" +" the menu hierarchy.\n" +"o The 'Defined at' line tells at what file / line number the symbol is\n" +" defined.\n" +"o The 'Depends on:' line lists symbols that need to be defined for\n" +" this symbol to be visible and selectable in the menu.\n" +"o The 'Location:' lines tell, where in the menu structure this symbol\n" +" is located. A location followed by a [ = y] indicates that this is\n" +" a selectable menu item, and the current value is displayed inside\n" +" brackets.\n" +"o The 'Selects:' line tells, what symbol will be automatically selected\n" +" if this symbol is selected (y or m).\n" +"o The 'Selected by' line tells what symbol has selected this symbol.\n" +"\n" +"Only relevant lines are shown.\n" +"\n\n" +"Search examples:\n" +"USB => find all symbols containing USB\n" +"^USB => find all symbols starting with USB\n" +"USB$ => find all symbols ending with USB\n" +"\n"; + +struct mitem { + char str[256]; + char tag; + void *usrptr; + int is_visible; +}; + +#define MAX_MENU_ITEMS 4096 +static int show_all_items; +static int indent; +static struct menu *current_menu; +static int child_count; +static int single_menu_mode; +/* the window in which all information appears */ +static WINDOW *main_window; +/* the largest size of the menu window */ +static int mwin_max_lines; +static int mwin_max_cols; +/* the window in which we show option buttons */ +static MENU *curses_menu; +static ITEM *curses_menu_items[MAX_MENU_ITEMS]; +static struct mitem k_menu_items[MAX_MENU_ITEMS]; +static int items_num; +static int global_exit; +/* the currently selected button */ +static const char *current_instructions = menu_instructions; + +static char *dialog_input_result; +static int dialog_input_result_len; + +static void conf(struct menu *menu); +static void conf_choice(struct menu *menu); +static void conf_string(struct menu *menu); +static void conf_load(void); +static void conf_save(void); +static void show_help(struct menu *menu); +static int do_exit(void); +static void setup_windows(void); +static void search_conf(void); + +typedef void (*function_key_handler_t)(int *key, struct menu *menu); +static void handle_f1(int *key, struct menu *current_item); +static void handle_f2(int *key, struct menu *current_item); +static void handle_f3(int *key, struct menu *current_item); +static void handle_f4(int *key, struct menu *current_item); +static void handle_f5(int *key, struct menu *current_item); +static void handle_f6(int *key, struct menu *current_item); +static void handle_f7(int *key, struct menu *current_item); +static void handle_f8(int *key, struct menu *current_item); +static void handle_f9(int *key, struct menu *current_item); + +struct function_keys { + const char *key_str; + const char *func; + function_key key; + function_key_handler_t handler; +}; + +static const int function_keys_num = 9; +static struct function_keys function_keys[] = { + { + .key_str = "F1", + .func = "Help", + .key = F_HELP, + .handler = handle_f1, + }, + { + .key_str = "F2", + .func = "SymInfo", + .key = F_SYMBOL, + .handler = handle_f2, + }, + { + .key_str = "F3", + .func = "Help 2", + .key = F_INSTS, + .handler = handle_f3, + }, + { + .key_str = "F4", + .func = "ShowAll", + .key = F_CONF, + .handler = handle_f4, + }, + { + .key_str = "F5", + .func = "Back", + .key = F_BACK, + .handler = handle_f5, + }, + { + .key_str = "F6", + .func = "Save", + .key = F_SAVE, + .handler = handle_f6, + }, + { + .key_str = "F7", + .func = "Load", + .key = F_LOAD, + .handler = handle_f7, + }, + { + .key_str = "F8", + .func = "SymSearch", + .key = F_SEARCH, + .handler = handle_f8, + }, + { + .key_str = "F9", + .func = "Exit", + .key = F_EXIT, + .handler = handle_f9, + }, +}; + +static void print_function_line(void) +{ + int i; + int offset = 1; + const int skip = 1; + int lines = getmaxy(stdscr); + + for (i = 0; i < function_keys_num; i++) { + (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); + mvwprintw(main_window, lines-3, offset, + "%s", + function_keys[i].key_str); + (void) wattrset(main_window, attributes[FUNCTION_TEXT]); + offset += strlen(function_keys[i].key_str); + mvwprintw(main_window, lines-3, + offset, "%s", + function_keys[i].func); + offset += strlen(function_keys[i].func) + skip; + } + (void) wattrset(main_window, attributes[NORMAL]); +} + +/* help */ +static void handle_f1(int *key, struct menu *current_item) +{ + show_scroll_win(main_window, + "Global help", nconf_global_help); + return; +} + +/* symbole help */ +static void handle_f2(int *key, struct menu *current_item) +{ + show_help(current_item); + return; +} + +/* instructions */ +static void handle_f3(int *key, struct menu *current_item) +{ + show_scroll_win(main_window, + "Short help", + current_instructions); + return; +} + +/* config */ +static void handle_f4(int *key, struct menu *current_item) +{ + int res = btn_dialog(main_window, + "Show all symbols?", + 2, + " ", + ""); + if (res == 0) + show_all_items = 1; + else if (res == 1) + show_all_items = 0; + + return; +} + +/* back */ +static void handle_f5(int *key, struct menu *current_item) +{ + *key = KEY_LEFT; + return; +} + +/* save */ +static void handle_f6(int *key, struct menu *current_item) +{ + conf_save(); + return; +} + +/* load */ +static void handle_f7(int *key, struct menu *current_item) +{ + conf_load(); + return; +} + +/* search */ +static void handle_f8(int *key, struct menu *current_item) +{ + search_conf(); + return; +} + +/* exit */ +static void handle_f9(int *key, struct menu *current_item) +{ + do_exit(); + return; +} + +/* return != 0 to indicate the key was handles */ +static int process_special_keys(int *key, struct menu *menu) +{ + int i; + + if (*key == KEY_RESIZE) { + setup_windows(); + return 1; + } + + for (i = 0; i < function_keys_num; i++) { + if (*key == KEY_F(function_keys[i].key) || + *key == '0' + function_keys[i].key){ + function_keys[i].handler(key, menu); + return 1; + } + } + + return 0; +} + +static void clean_items(void) +{ + int i; + for (i = 0; curses_menu_items[i]; i++) + free_item(curses_menu_items[i]); + bzero(curses_menu_items, sizeof(curses_menu_items)); + bzero(k_menu_items, sizeof(k_menu_items)); + items_num = 0; +} + +typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN, + FIND_NEXT_MATCH_DOWN, FIND_NEXT_MATCH_UP} match_f; + +/* return the index of the matched item, or -1 if no such item exists */ +static int get_mext_match(const char *match_str, match_f flag) +{ + int match_start = item_index(current_item(curses_menu)); + int index; + + if (flag == FIND_NEXT_MATCH_DOWN) + ++match_start; + else if (flag == FIND_NEXT_MATCH_UP) + --match_start; + + index = match_start; + index = (index + items_num) % items_num; + while (true) { + char *str = k_menu_items[index].str; + if (strcasestr(str, match_str) != NULL) + return index; + if (flag == FIND_NEXT_MATCH_UP || + flag == MATCH_TINKER_PATTERN_UP) + --index; + else + ++index; + index = (index + items_num) % items_num; + if (index == match_start) + return -1; + } +} + +/* Make a new item. */ +static void item_make(struct menu *menu, char tag, const char *fmt, ...) +{ + va_list ap; + + if (items_num > MAX_MENU_ITEMS-1) + return; + + bzero(&k_menu_items[items_num], sizeof(k_menu_items[0])); + k_menu_items[items_num].tag = tag; + k_menu_items[items_num].usrptr = menu; + if (menu != NULL) + k_menu_items[items_num].is_visible = + menu_is_visible(menu); + else + k_menu_items[items_num].is_visible = 1; + + va_start(ap, fmt); + vsnprintf(k_menu_items[items_num].str, + sizeof(k_menu_items[items_num].str), + fmt, ap); + va_end(ap); + + if (!k_menu_items[items_num].is_visible) + memcpy(k_menu_items[items_num].str, "XXX", 3); + + curses_menu_items[items_num] = new_item( + k_menu_items[items_num].str, + k_menu_items[items_num].str); + set_item_userptr(curses_menu_items[items_num], + &k_menu_items[items_num]); + /* + if (!k_menu_items[items_num].is_visible) + item_opts_off(curses_menu_items[items_num], O_SELECTABLE); + */ + + items_num++; + curses_menu_items[items_num] = NULL; +} + +/* very hackish. adds a string to the last item added */ +static void item_add_str(const char *fmt, ...) +{ + va_list ap; + int index = items_num-1; + char new_str[256]; + char tmp_str[256]; + + if (index < 0) + return; + + va_start(ap, fmt); + vsnprintf(new_str, sizeof(new_str), fmt, ap); + va_end(ap); + snprintf(tmp_str, sizeof(tmp_str), "%s%s", + k_menu_items[index].str, new_str); + strncpy(k_menu_items[index].str, + tmp_str, + sizeof(k_menu_items[index].str)); + + free_item(curses_menu_items[index]); + curses_menu_items[index] = new_item( + k_menu_items[index].str, + k_menu_items[index].str); + set_item_userptr(curses_menu_items[index], + &k_menu_items[index]); +} + +/* get the tag of the currently selected item */ +static char item_tag(void) +{ + ITEM *cur; + struct mitem *mcur; + + cur = current_item(curses_menu); + if (cur == NULL) + return 0; + mcur = (struct mitem *) item_userptr(cur); + return mcur->tag; +} + +static int curses_item_index(void) +{ + return item_index(current_item(curses_menu)); +} + +static void *item_data(void) +{ + ITEM *cur; + struct mitem *mcur; + + cur = current_item(curses_menu); + if (!cur) + return NULL; + mcur = (struct mitem *) item_userptr(cur); + return mcur->usrptr; + +} + +static int item_is_tag(char tag) +{ + return item_tag() == tag; +} + +static char filename[PATH_MAX+1]; +static char menu_backtitle[PATH_MAX+128]; +static const char *set_config_filename(const char *config_filename) +{ + int size; + + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + "%s - %s", config_filename, rootmenu.prompt->text); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; + return menu_backtitle; +} + +/* return = 0 means we are successful. + * -1 means go on doing what you were doing + */ +static int do_exit(void) +{ + int res; + if (!conf_get_changed()) { + global_exit = 1; + return 0; + } + res = btn_dialog(main_window, + "Do you wish to save your new configuration?\n" + " to cancel and resume nconfig.", + 2, + " ", + ""); + if (res == KEY_EXIT) { + global_exit = 0; + return -1; + } + + /* if we got here, the user really wants to exit */ + switch (res) { + case 0: + res = conf_write(filename); + if (res) + btn_dialog( + main_window, + "Error during writing of configuration.\n" + "Your configuration changes were NOT saved.", + 1, + ""); + conf_write_autoconf(0); + break; + default: + btn_dialog( + main_window, + "Your configuration changes were NOT saved.", + 1, + ""); + break; + } + global_exit = 1; + return 0; +} + + +static void search_conf(void) +{ + struct symbol **sym_arr; + struct gstr res; + struct gstr title; + char *dialog_input; + int dres; + + title = str_new(); + str_printf( &title, "Enter (sub)string or regexp to search for " + "(with or without \"%s\")", CONFIG_); + +again: + dres = dialog_inputbox(main_window, + "Search Configuration Parameter", + str_get(&title), + "", &dialog_input_result, &dialog_input_result_len); + switch (dres) { + case 0: + break; + case 1: + show_scroll_win(main_window, + "Search Configuration", search_help); + goto again; + default: + str_free(&title); + return; + } + + /* strip the prefix if necessary */ + dialog_input = dialog_input_result; + if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0) + dialog_input += strlen(CONFIG_); + + sym_arr = sym_re_search(dialog_input); + res = get_relations_str(sym_arr, NULL); + free(sym_arr); + show_scroll_win(main_window, + "Search Results", str_get(&res)); + str_free(&res); + str_free(&title); +} + + +static void build_conf(struct menu *menu) +{ + struct symbol *sym; + struct property *prop; + struct menu *child; + int type, tmp, doint = 2; + tristate val; + char ch; + + if (!menu || (!show_all_items && !menu_is_visible(menu))) + return; + + sym = menu->sym; + prop = menu->prompt; + if (!sym) { + if (prop && menu != current_menu) { + const char *prompt = menu_get_prompt(menu); + enum prop_type ptype; + ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN; + switch (ptype) { + case P_MENU: + child_count++; + prompt = prompt; + if (single_menu_mode) { + item_make(menu, 'm', + "%s%*c%s", + menu->data ? "-->" : "++>", + indent + 1, ' ', prompt); + } else + item_make(menu, 'm', + " %*c%s %s", + indent + 1, ' ', prompt, + menu_is_empty(menu) ? "----" : "--->"); + + if (single_menu_mode && menu->data) + goto conf_childs; + return; + case P_COMMENT: + if (prompt) { + child_count++; + item_make(menu, ':', + " %*c*** %s ***", + indent + 1, ' ', + prompt); + } + break; + default: + if (prompt) { + child_count++; + item_make(menu, ':', "---%*c%s", + indent + 1, ' ', + prompt); + } + } + } else + doint = 0; + goto conf_childs; + } + + type = sym_get_type(sym); + if (sym_is_choice(sym)) { + struct symbol *def_sym = sym_get_choice_value(sym); + struct menu *def_menu = NULL; + + child_count++; + for (child = menu->list; child; child = child->next) { + if (menu_is_visible(child) && child->sym == def_sym) + def_menu = child; + } + + val = sym_get_tristate_value(sym); + if (sym_is_changeable(sym)) { + switch (type) { + case S_BOOLEAN: + item_make(menu, 't', "[%c]", + val == no ? ' ' : '*'); + break; + case S_TRISTATE: + switch (val) { + case yes: + ch = '*'; + break; + case mod: + ch = 'M'; + break; + default: + ch = ' '; + break; + } + item_make(menu, 't', "<%c>", ch); + break; + } + } else { + item_make(menu, def_menu ? 't' : ':', " "); + } + + item_add_str("%*c%s", indent + 1, + ' ', menu_get_prompt(menu)); + if (val == yes) { + if (def_menu) { + item_add_str(" (%s)", + menu_get_prompt(def_menu)); + item_add_str(" --->"); + if (def_menu->list) { + indent += 2; + build_conf(def_menu); + indent -= 2; + } + } + return; + } + } else { + if (menu == current_menu) { + item_make(menu, ':', + "---%*c%s", indent + 1, + ' ', menu_get_prompt(menu)); + goto conf_childs; + } + child_count++; + val = sym_get_tristate_value(sym); + if (sym_is_choice_value(sym) && val == yes) { + item_make(menu, ':', " "); + } else { + switch (type) { + case S_BOOLEAN: + if (sym_is_changeable(sym)) + item_make(menu, 't', "[%c]", + val == no ? ' ' : '*'); + else + item_make(menu, 't', "-%c-", + val == no ? ' ' : '*'); + break; + case S_TRISTATE: + switch (val) { + case yes: + ch = '*'; + break; + case mod: + ch = 'M'; + break; + default: + ch = ' '; + break; + } + if (sym_is_changeable(sym)) { + if (sym->rev_dep.tri == mod) + item_make(menu, + 't', "{%c}", ch); + else + item_make(menu, + 't', "<%c>", ch); + } else + item_make(menu, 't', "-%c-", ch); + break; + default: + tmp = 2 + strlen(sym_get_string_value(sym)); + item_make(menu, 's', " (%s)", + sym_get_string_value(sym)); + tmp = indent - tmp + 4; + if (tmp < 0) + tmp = 0; + item_add_str("%*c%s%s", tmp, ' ', + menu_get_prompt(menu), + (sym_has_value(sym) || + !sym_is_changeable(sym)) ? "" : + " (NEW)"); + goto conf_childs; + } + } + item_add_str("%*c%s%s", indent + 1, ' ', + menu_get_prompt(menu), + (sym_has_value(sym) || !sym_is_changeable(sym)) ? + "" : " (NEW)"); + if (menu->prompt && menu->prompt->type == P_MENU) { + item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); + return; + } + } + +conf_childs: + indent += doint; + for (child = menu->list; child; child = child->next) + build_conf(child); + indent -= doint; +} + +static void reset_menu(void) +{ + unpost_menu(curses_menu); + clean_items(); +} + +/* adjust the menu to show this item. + * prefer not to scroll the menu if possible*/ +static void center_item(int selected_index, int *last_top_row) +{ + int toprow; + + set_top_row(curses_menu, *last_top_row); + toprow = top_row(curses_menu); + if (selected_index < toprow || + selected_index >= toprow+mwin_max_lines) { + toprow = max(selected_index-mwin_max_lines/2, 0); + if (toprow >= item_count(curses_menu)-mwin_max_lines) + toprow = item_count(curses_menu)-mwin_max_lines; + set_top_row(curses_menu, toprow); + } + set_current_item(curses_menu, + curses_menu_items[selected_index]); + *last_top_row = toprow; + post_menu(curses_menu); + refresh_all_windows(main_window); +} + +/* this function assumes reset_menu has been called before */ +static void show_menu(const char *prompt, const char *instructions, + int selected_index, int *last_top_row) +{ + int maxx, maxy; + WINDOW *menu_window; + + current_instructions = instructions; + + clear(); + (void) wattrset(main_window, attributes[NORMAL]); + print_in_middle(stdscr, 1, 0, getmaxx(stdscr), + menu_backtitle, + attributes[MAIN_HEADING]); + + (void) wattrset(main_window, attributes[MAIN_MENU_BOX]); + box(main_window, 0, 0); + (void) wattrset(main_window, attributes[MAIN_MENU_HEADING]); + mvwprintw(main_window, 0, 3, " %s ", prompt); + (void) wattrset(main_window, attributes[NORMAL]); + + set_menu_items(curses_menu, curses_menu_items); + + /* position the menu at the middle of the screen */ + scale_menu(curses_menu, &maxy, &maxx); + maxx = min(maxx, mwin_max_cols-2); + maxy = mwin_max_lines; + menu_window = derwin(main_window, + maxy, + maxx, + 2, + (mwin_max_cols-maxx)/2); + keypad(menu_window, TRUE); + set_menu_win(curses_menu, menu_window); + set_menu_sub(curses_menu, menu_window); + + /* must reassert this after changing items, otherwise returns to a + * default of 16 + */ + set_menu_format(curses_menu, maxy, 1); + center_item(selected_index, last_top_row); + set_menu_format(curses_menu, maxy, 1); + + print_function_line(); + + /* Post the menu */ + post_menu(curses_menu); + refresh_all_windows(main_window); +} + +static void adj_match_dir(match_f *match_direction) +{ + if (*match_direction == FIND_NEXT_MATCH_DOWN) + *match_direction = + MATCH_TINKER_PATTERN_DOWN; + else if (*match_direction == FIND_NEXT_MATCH_UP) + *match_direction = + MATCH_TINKER_PATTERN_UP; + /* else, do no change.. */ +} + +struct match_state +{ + int in_search; + match_f match_direction; + char pattern[256]; +}; + +/* Return 0 means I have handled the key. In such a case, ans should hold the + * item to center, or -1 otherwise. + * Else return -1 . + */ +static int do_match(int key, struct match_state *state, int *ans) +{ + char c = (char) key; + int terminate_search = 0; + *ans = -1; + if (key == '/' || (state->in_search && key == 27)) { + move(0, 0); + refresh(); + clrtoeol(); + state->in_search = 1-state->in_search; + bzero(state->pattern, sizeof(state->pattern)); + state->match_direction = MATCH_TINKER_PATTERN_DOWN; + return 0; + } else if (!state->in_search) + return 1; + + if (isalnum(c) || isgraph(c) || c == ' ') { + state->pattern[strlen(state->pattern)] = c; + state->pattern[strlen(state->pattern)] = '\0'; + adj_match_dir(&state->match_direction); + *ans = get_mext_match(state->pattern, + state->match_direction); + } else if (key == KEY_DOWN) { + state->match_direction = FIND_NEXT_MATCH_DOWN; + *ans = get_mext_match(state->pattern, + state->match_direction); + } else if (key == KEY_UP) { + state->match_direction = FIND_NEXT_MATCH_UP; + *ans = get_mext_match(state->pattern, + state->match_direction); + } else if (key == KEY_BACKSPACE || key == 8 || key == 127) { + state->pattern[strlen(state->pattern)-1] = '\0'; + adj_match_dir(&state->match_direction); + } else + terminate_search = 1; + + if (terminate_search) { + state->in_search = 0; + bzero(state->pattern, sizeof(state->pattern)); + move(0, 0); + refresh(); + clrtoeol(); + return -1; + } + return 0; +} + +static void conf(struct menu *menu) +{ + struct menu *submenu = NULL; + const char *prompt = menu_get_prompt(menu); + struct symbol *sym; + int res; + int current_index = 0; + int last_top_row = 0; + struct match_state match_state = { + .in_search = 0, + .match_direction = MATCH_TINKER_PATTERN_DOWN, + .pattern = "", + }; + + while (!global_exit) { + reset_menu(); + current_menu = menu; + build_conf(menu); + if (!child_count) + break; + + show_menu(prompt ? prompt : "Main Menu", + menu_instructions, + current_index, &last_top_row); + keypad((menu_win(curses_menu)), TRUE); + while (!global_exit) { + if (match_state.in_search) { + mvprintw(0, 0, + "searching: %s", match_state.pattern); + clrtoeol(); + } + refresh_all_windows(main_window); + res = wgetch(menu_win(curses_menu)); + if (!res) + break; + if (do_match(res, &match_state, ¤t_index) == 0) { + if (current_index != -1) + center_item(current_index, + &last_top_row); + continue; + } + if (process_special_keys(&res, + (struct menu *) item_data())) + break; + switch (res) { + case KEY_DOWN: + menu_driver(curses_menu, REQ_DOWN_ITEM); + break; + case KEY_UP: + menu_driver(curses_menu, REQ_UP_ITEM); + break; + case KEY_NPAGE: + menu_driver(curses_menu, REQ_SCR_DPAGE); + break; + case KEY_PPAGE: + menu_driver(curses_menu, REQ_SCR_UPAGE); + break; + case KEY_HOME: + menu_driver(curses_menu, REQ_FIRST_ITEM); + break; + case KEY_END: + menu_driver(curses_menu, REQ_LAST_ITEM); + break; + case 'h': + case '?': + show_help((struct menu *) item_data()); + break; + } + if (res == 10 || res == 27 || + res == 32 || res == 'n' || res == 'y' || + res == KEY_LEFT || res == KEY_RIGHT || + res == 'm') + break; + refresh_all_windows(main_window); + } + + refresh_all_windows(main_window); + /* if ESC or left*/ + if (res == 27 || (menu != &rootmenu && res == KEY_LEFT)) + break; + + /* remember location in the menu */ + last_top_row = top_row(curses_menu); + current_index = curses_item_index(); + + if (!item_tag()) + continue; + + submenu = (struct menu *) item_data(); + if (!submenu || !menu_is_visible(submenu)) + continue; + sym = submenu->sym; + + switch (res) { + case ' ': + if (item_is_tag('t')) + sym_toggle_tristate_value(sym); + else if (item_is_tag('m')) + conf(submenu); + break; + case KEY_RIGHT: + case 10: /* ENTER WAS PRESSED */ + switch (item_tag()) { + case 'm': + if (single_menu_mode) + submenu->data = + (void *) (long) !submenu->data; + else + conf(submenu); + break; + case 't': + if (sym_is_choice(sym) && + sym_get_tristate_value(sym) == yes) + conf_choice(submenu); + else if (submenu->prompt && + submenu->prompt->type == P_MENU) + conf(submenu); + else if (res == 10) + sym_toggle_tristate_value(sym); + break; + case 's': + conf_string(submenu); + break; + } + break; + case 'y': + if (item_is_tag('t')) { + if (sym_set_tristate_value(sym, yes)) + break; + if (sym_set_tristate_value(sym, mod)) + btn_dialog(main_window, setmod_text, 0); + } + break; + case 'n': + if (item_is_tag('t')) + sym_set_tristate_value(sym, no); + break; + case 'm': + if (item_is_tag('t')) + sym_set_tristate_value(sym, mod); + break; + } + } +} + +static void conf_message_callback(const char *s) +{ + btn_dialog(main_window, s, 1, ""); +} + +static void show_help(struct menu *menu) +{ + struct gstr help; + + if (!menu) + return; + + help = str_new(); + menu_get_ext_help(menu, &help); + show_scroll_win(main_window, menu_get_prompt(menu), str_get(&help)); + str_free(&help); +} + +static void conf_choice(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + struct menu *child = NULL; + struct symbol *active; + struct property *prop; + int selected_index = 0; + int last_top_row = 0; + int res, i = 0; + struct match_state match_state = { + .in_search = 0, + .match_direction = MATCH_TINKER_PATTERN_DOWN, + .pattern = "", + }; + + active = sym_get_choice_value(menu->sym); + /* this is mostly duplicated from the conf() function. */ + while (!global_exit) { + reset_menu(); + + for (i = 0, child = menu->list; child; child = child->next) { + if (!show_all_items && !menu_is_visible(child)) + continue; + + if (child->sym == sym_get_choice_value(menu->sym)) + item_make(child, ':', " %s", + menu_get_prompt(child)); + else if (child->sym) + item_make(child, ':', " %s", + menu_get_prompt(child)); + else + item_make(child, ':', "*** %s ***", + menu_get_prompt(child)); + + if (child->sym == active){ + last_top_row = top_row(curses_menu); + selected_index = i; + } + i++; + } + show_menu(prompt ? prompt : "Choice Menu", + radiolist_instructions, + selected_index, + &last_top_row); + while (!global_exit) { + if (match_state.in_search) { + mvprintw(0, 0, "searching: %s", + match_state.pattern); + clrtoeol(); + } + refresh_all_windows(main_window); + res = wgetch(menu_win(curses_menu)); + if (!res) + break; + if (do_match(res, &match_state, &selected_index) == 0) { + if (selected_index != -1) + center_item(selected_index, + &last_top_row); + continue; + } + if (process_special_keys( + &res, + (struct menu *) item_data())) + break; + switch (res) { + case KEY_DOWN: + menu_driver(curses_menu, REQ_DOWN_ITEM); + break; + case KEY_UP: + menu_driver(curses_menu, REQ_UP_ITEM); + break; + case KEY_NPAGE: + menu_driver(curses_menu, REQ_SCR_DPAGE); + break; + case KEY_PPAGE: + menu_driver(curses_menu, REQ_SCR_UPAGE); + break; + case KEY_HOME: + menu_driver(curses_menu, REQ_FIRST_ITEM); + break; + case KEY_END: + menu_driver(curses_menu, REQ_LAST_ITEM); + break; + case 'h': + case '?': + show_help((struct menu *) item_data()); + break; + } + if (res == 10 || res == 27 || res == ' ' || + res == KEY_LEFT){ + break; + } + refresh_all_windows(main_window); + } + /* if ESC or left */ + if (res == 27 || res == KEY_LEFT) + break; + + child = item_data(); + if (!child || !menu_is_visible(child) || !child->sym) + continue; + switch (res) { + case ' ': + case 10: + case KEY_RIGHT: + if (sym_get_tristate_value(child->sym) != yes) { + for_all_properties(menu->sym, prop, P_RESET) { + if (expr_calc_value(prop->visible.expr) == no) + continue; + + conf_reset(S_DEF_USER); + break; + } + } + sym_set_tristate_value(child->sym, yes); + return; + case 'h': + case '?': + show_help(child); + active = child->sym; + break; + case KEY_EXIT: + return; + } + } +} + +static void conf_string(struct menu *menu) +{ + const char *prompt = menu_get_prompt(menu); + + while (1) { + int res; + const char *heading; + + switch (sym_get_type(menu->sym)) { + case S_INT: + heading = inputbox_instructions_int; + break; + case S_HEX: + heading = inputbox_instructions_hex; + break; + case S_STRING: + heading = inputbox_instructions_string; + break; + default: + heading = "Internal nconf error!"; + } + res = dialog_inputbox(main_window, + prompt ? prompt : "Main Menu", + heading, + sym_get_string_value(menu->sym), + &dialog_input_result, + &dialog_input_result_len); + switch (res) { + case 0: + if (sym_set_string_value(menu->sym, + dialog_input_result)) + return; + btn_dialog(main_window, + "You have made an invalid entry.", 0); + break; + case 1: + show_help(menu); + break; + case KEY_EXIT: + return; + } + } +} + +static void conf_load(void) +{ + while (1) { + int res; + res = dialog_inputbox(main_window, + NULL, load_config_text, + filename, + &dialog_input_result, + &dialog_input_result_len); + switch (res) { + case 0: + if (!dialog_input_result[0]) + return; + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); + sym_set_change_count(1); + return; + } + btn_dialog(main_window, "File does not exist!", 0); + break; + case 1: + show_scroll_win(main_window, + "Load Alternate Configuration", + load_config_help); + break; + case KEY_EXIT: + return; + } + } +} + +static void conf_save(void) +{ + while (1) { + int res; + res = dialog_inputbox(main_window, + NULL, save_config_text, + filename, + &dialog_input_result, + &dialog_input_result_len); + switch (res) { + case 0: + if (!dialog_input_result[0]) + return; + res = conf_write(dialog_input_result); + if (!res) { + set_config_filename(dialog_input_result); + return; + } + btn_dialog(main_window, "Can't create file!", + 1, ""); + break; + case 1: + show_scroll_win(main_window, + "Save Alternate Configuration", + save_config_help); + break; + case KEY_EXIT: + return; + } + } +} + +static void setup_windows(void) +{ + int lines, columns; + + getmaxyx(stdscr, lines, columns); + + if (main_window != NULL) + delwin(main_window); + + /* set up the menu and menu window */ + main_window = newwin(lines-2, columns-2, 2, 1); + keypad(main_window, TRUE); + mwin_max_lines = lines-7; + mwin_max_cols = columns-6; + + /* panels order is from bottom to top */ + new_panel(main_window); +} + +int main(int ac, char **av) +{ + int lines, columns; + char *mode; + + if (ac > 1 && strcmp(av[1], "-s") == 0) { + /* Silence conf_read() until the real callback is set up */ + conf_set_message_callback(NULL); + av++; + } + conf_parse(av[1]); + conf_read(NULL); + + mode = getenv("NCONFIG_MODE"); + if (mode) { + if (!strcasecmp(mode, "single_menu")) + single_menu_mode = 1; + } + + /* Initialize curses */ + initscr(); + /* set color theme */ + set_colors(); + + cbreak(); + noecho(); + keypad(stdscr, TRUE); + curs_set(0); + + getmaxyx(stdscr, lines, columns); + if (columns < 75 || lines < 20) { + endwin(); + printf("Your terminal should have at " + "least 20 lines and 75 columns\n"); + return 1; + } + + notimeout(stdscr, FALSE); +#if NCURSES_REENTRANT + set_escdelay(1); +#else + ESCDELAY = 1; +#endif + + /* set btns menu */ + curses_menu = new_menu(curses_menu_items); + menu_opts_off(curses_menu, O_SHOWDESC); + menu_opts_on(curses_menu, O_SHOWMATCH); + menu_opts_on(curses_menu, O_ONEVALUE); + menu_opts_on(curses_menu, O_NONCYCLIC); + menu_opts_on(curses_menu, O_IGNORECASE); + set_menu_mark(curses_menu, " "); + set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]); + set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]); + set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]); + + set_config_filename(conf_get_configname()); + setup_windows(); + + /* check for KEY_FUNC(1) */ + if (has_key(KEY_F(1)) == FALSE) { + show_scroll_win(main_window, + "Instructions", + menu_no_f_instructions); + } + + conf_set_message_callback(conf_message_callback); + /* do the work */ + while (!global_exit) { + conf(&rootmenu); + if (!global_exit && do_exit() == 0) + break; + } + /* ok, we are done */ + unpost_menu(curses_menu); + free_menu(curses_menu); + delwin(main_window); + clear(); + refresh(); + endwin(); + return 0; +} diff --git a/scripts/config/nconf.gui.c b/scripts/config/nconf.gui.c new file mode 100644 index 0000000000..77f525a861 --- /dev/null +++ b/scripts/config/nconf.gui.c @@ -0,0 +1,664 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2008 Nir Tzachar + * + * Derived from menuconfig. + */ +#include "nconf.h" +#include "lkc.h" + +/* a list of all the different widgets we use */ +attributes_t attributes[ATTR_MAX+1] = {0}; + +/* available colors: + COLOR_BLACK 0 + COLOR_RED 1 + COLOR_GREEN 2 + COLOR_YELLOW 3 + COLOR_BLUE 4 + COLOR_MAGENTA 5 + COLOR_CYAN 6 + COLOR_WHITE 7 + */ +static void set_normal_colors(void) +{ + init_pair(NORMAL, -1, -1); + init_pair(MAIN_HEADING, COLOR_MAGENTA, -1); + + /* FORE is for the selected item */ + init_pair(MAIN_MENU_FORE, -1, -1); + /* BACK for all the rest */ + init_pair(MAIN_MENU_BACK, -1, -1); + init_pair(MAIN_MENU_GREY, -1, -1); + init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1); + init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1); + + init_pair(SCROLLWIN_TEXT, -1, -1); + init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1); + init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1); + + init_pair(DIALOG_TEXT, -1, -1); + init_pair(DIALOG_BOX, COLOR_YELLOW, -1); + init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1); + init_pair(DIALOG_MENU_FORE, COLOR_RED, -1); + + init_pair(INPUT_BOX, COLOR_YELLOW, -1); + init_pair(INPUT_HEADING, COLOR_GREEN, -1); + init_pair(INPUT_TEXT, -1, -1); + init_pair(INPUT_FIELD, -1, -1); + + init_pair(FUNCTION_HIGHLIGHT, -1, -1); + init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1); +} + +/* available attributes: + A_NORMAL Normal display (no highlight) + A_STANDOUT Best highlighting mode of the terminal. + A_UNDERLINE Underlining + A_REVERSE Reverse video + A_BLINK Blinking + A_DIM Half bright + A_BOLD Extra bright or bold + A_PROTECT Protected mode + A_INVIS Invisible or blank mode + A_ALTCHARSET Alternate character set + A_CHARTEXT Bit-mask to extract a character + COLOR_PAIR(n) Color-pair number n + */ +static void normal_color_theme(void) +{ + /* automatically add color... */ +#define mkattr(name, attr) do { \ +attributes[name] = attr | COLOR_PAIR(name); } while (0) + mkattr(NORMAL, NORMAL); + mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE); + + mkattr(MAIN_MENU_FORE, A_REVERSE); + mkattr(MAIN_MENU_BACK, A_NORMAL); + mkattr(MAIN_MENU_GREY, A_NORMAL); + mkattr(MAIN_MENU_HEADING, A_BOLD); + mkattr(MAIN_MENU_BOX, A_NORMAL); + + mkattr(SCROLLWIN_TEXT, A_NORMAL); + mkattr(SCROLLWIN_HEADING, A_BOLD); + mkattr(SCROLLWIN_BOX, A_BOLD); + + mkattr(DIALOG_TEXT, A_BOLD); + mkattr(DIALOG_BOX, A_BOLD); + mkattr(DIALOG_MENU_FORE, A_STANDOUT); + mkattr(DIALOG_MENU_BACK, A_NORMAL); + + mkattr(INPUT_BOX, A_NORMAL); + mkattr(INPUT_HEADING, A_BOLD); + mkattr(INPUT_TEXT, A_NORMAL); + mkattr(INPUT_FIELD, A_UNDERLINE); + + mkattr(FUNCTION_HIGHLIGHT, A_BOLD); + mkattr(FUNCTION_TEXT, A_REVERSE); +} + +static void no_colors_theme(void) +{ + /* automatically add highlight, no color */ +#define mkattrn(name, attr) { attributes[name] = attr; } + + mkattrn(NORMAL, NORMAL); + mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE); + + mkattrn(MAIN_MENU_FORE, A_STANDOUT); + mkattrn(MAIN_MENU_BACK, A_NORMAL); + mkattrn(MAIN_MENU_GREY, A_NORMAL); + mkattrn(MAIN_MENU_HEADING, A_BOLD); + mkattrn(MAIN_MENU_BOX, A_NORMAL); + + mkattrn(SCROLLWIN_TEXT, A_NORMAL); + mkattrn(SCROLLWIN_HEADING, A_BOLD); + mkattrn(SCROLLWIN_BOX, A_BOLD); + + mkattrn(DIALOG_TEXT, A_NORMAL); + mkattrn(DIALOG_BOX, A_BOLD); + mkattrn(DIALOG_MENU_FORE, A_STANDOUT); + mkattrn(DIALOG_MENU_BACK, A_NORMAL); + + mkattrn(INPUT_BOX, A_BOLD); + mkattrn(INPUT_HEADING, A_BOLD); + mkattrn(INPUT_TEXT, A_NORMAL); + mkattrn(INPUT_FIELD, A_UNDERLINE); + + mkattrn(FUNCTION_HIGHLIGHT, A_BOLD); + mkattrn(FUNCTION_TEXT, A_REVERSE); +} + +void set_colors(void) +{ + start_color(); + use_default_colors(); + set_normal_colors(); + if (has_colors()) { + normal_color_theme(); + } else { + /* give defaults */ + no_colors_theme(); + } +} + + +/* this changes the windows attributes !!! */ +void print_in_middle(WINDOW *win, + int starty, + int startx, + int width, + const char *string, + chtype color) +{ int length, x, y; + float temp; + + + if (win == NULL) + win = stdscr; + getyx(win, y, x); + if (startx != 0) + x = startx; + if (starty != 0) + y = starty; + if (width == 0) + width = 80; + + length = strlen(string); + temp = (width - length) / 2; + x = startx + (int)temp; + (void) wattrset(win, color); + mvwprintw(win, y, x, "%s", string); + refresh(); +} + +int get_line_no(const char *text) +{ + int i; + int total = 1; + + if (!text) + return 0; + + for (i = 0; text[i] != '\0'; i++) + if (text[i] == '\n') + total++; + return total; +} + +const char *get_line(const char *text, int line_no) +{ + int i; + int lines = 0; + + if (!text) + return NULL; + + for (i = 0; text[i] != '\0' && lines < line_no; i++) + if (text[i] == '\n') + lines++; + return text+i; +} + +int get_line_length(const char *line) +{ + int res = 0; + while (*line != '\0' && *line != '\n') { + line++; + res++; + } + return res; +} + +/* print all lines to the window. */ +void fill_window(WINDOW *win, const char *text) +{ + int x, y; + int total_lines = get_line_no(text); + int i; + + getmaxyx(win, y, x); + /* do not go over end of line */ + total_lines = min(total_lines, y); + for (i = 0; i < total_lines; i++) { + char tmp[x+10]; + const char *line = get_line(text, i); + int len = get_line_length(line); + strncpy(tmp, line, min(len, x)); + tmp[len] = '\0'; + mvwprintw(win, i, 0, "%s", tmp); + } +} + +/* get the message, and buttons. + * each button must be a char* + * return the selected button + * + * this dialog is used for 2 different things: + * 1) show a text box, no buttons. + * 2) show a dialog, with horizontal buttons + */ +int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...) +{ + va_list ap; + char *btn; + int btns_width = 0; + int msg_lines = 0; + int msg_width = 0; + int total_width; + int win_rows = 0; + WINDOW *win; + WINDOW *msg_win; + WINDOW *menu_win; + MENU *menu; + ITEM *btns[btn_num+1]; + int i, x, y; + int res = -1; + + + va_start(ap, btn_num); + for (i = 0; i < btn_num; i++) { + btn = va_arg(ap, char *); + btns[i] = new_item(btn, ""); + btns_width += strlen(btn)+1; + } + va_end(ap); + btns[btn_num] = NULL; + + /* find the widest line of msg: */ + msg_lines = get_line_no(msg); + for (i = 0; i < msg_lines; i++) { + const char *line = get_line(msg, i); + int len = get_line_length(line); + if (msg_width < len) + msg_width = len; + } + + total_width = max(msg_width, btns_width); + /* place dialog in middle of screen */ + y = (getmaxy(stdscr)-(msg_lines+4))/2; + x = (getmaxx(stdscr)-(total_width+4))/2; + + + /* create the windows */ + if (btn_num > 0) + win_rows = msg_lines+4; + else + win_rows = msg_lines+2; + + win = newwin(win_rows, total_width+4, y, x); + keypad(win, TRUE); + menu_win = derwin(win, 1, btns_width, win_rows-2, + 1+(total_width+2-btns_width)/2); + menu = new_menu(btns); + msg_win = derwin(win, win_rows-2, msg_width, 1, + 1+(total_width+2-msg_width)/2); + + set_menu_fore(menu, attributes[DIALOG_MENU_FORE]); + set_menu_back(menu, attributes[DIALOG_MENU_BACK]); + + (void) wattrset(win, attributes[DIALOG_BOX]); + box(win, 0, 0); + + /* print message */ + (void) wattrset(msg_win, attributes[DIALOG_TEXT]); + fill_window(msg_win, msg); + + set_menu_win(menu, win); + set_menu_sub(menu, menu_win); + set_menu_format(menu, 1, btn_num); + menu_opts_off(menu, O_SHOWDESC); + menu_opts_off(menu, O_SHOWMATCH); + menu_opts_on(menu, O_ONEVALUE); + menu_opts_on(menu, O_NONCYCLIC); + set_menu_mark(menu, ""); + post_menu(menu); + + + touchwin(win); + refresh_all_windows(main_window); + while ((res = wgetch(win))) { + switch (res) { + case KEY_LEFT: + menu_driver(menu, REQ_LEFT_ITEM); + break; + case KEY_RIGHT: + menu_driver(menu, REQ_RIGHT_ITEM); + break; + case 10: /* ENTER */ + case 27: /* ESCAPE */ + case ' ': + case KEY_F(F_BACK): + case KEY_F(F_EXIT): + break; + } + touchwin(win); + refresh_all_windows(main_window); + + if (res == 10 || res == ' ') { + res = item_index(current_item(menu)); + break; + } else if (res == 27 || res == KEY_F(F_BACK) || + res == KEY_F(F_EXIT)) { + res = KEY_EXIT; + break; + } + } + + unpost_menu(menu); + free_menu(menu); + for (i = 0; i < btn_num; i++) + free_item(btns[i]); + + delwin(win); + return res; +} + +int dialog_inputbox(WINDOW *main_window, + const char *title, const char *prompt, + const char *init, char **resultp, int *result_len) +{ + int prompt_lines = 0; + int prompt_width = 0; + WINDOW *win; + WINDOW *prompt_win; + WINDOW *form_win; + PANEL *panel; + int i, x, y, lines, columns, win_lines, win_cols; + int res = -1; + int cursor_position = strlen(init); + int cursor_form_win; + char *result = *resultp; + + getmaxyx(stdscr, lines, columns); + + if (strlen(init)+1 > *result_len) { + *result_len = strlen(init)+1; + *resultp = result = xrealloc(result, *result_len); + } + + /* find the widest line of msg: */ + prompt_lines = get_line_no(prompt); + for (i = 0; i < prompt_lines; i++) { + const char *line = get_line(prompt, i); + int len = get_line_length(line); + prompt_width = max(prompt_width, len); + } + + if (title) + prompt_width = max(prompt_width, strlen(title)); + + win_lines = min(prompt_lines+6, lines-2); + win_cols = min(prompt_width+7, columns-2); + prompt_lines = max(win_lines-6, 0); + prompt_width = max(win_cols-7, 0); + + /* place dialog in middle of screen */ + y = (lines-win_lines)/2; + x = (columns-win_cols)/2; + + strncpy(result, init, *result_len); + + /* create the windows */ + win = newwin(win_lines, win_cols, y, x); + prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2); + form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); + keypad(form_win, TRUE); + + (void) wattrset(form_win, attributes[INPUT_FIELD]); + + (void) wattrset(win, attributes[INPUT_BOX]); + box(win, 0, 0); + (void) wattrset(win, attributes[INPUT_HEADING]); + if (title) + mvwprintw(win, 0, 3, "%s", title); + + /* print message */ + (void) wattrset(prompt_win, attributes[INPUT_TEXT]); + fill_window(prompt_win, prompt); + + mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); + cursor_form_win = min(cursor_position, prompt_width-1); + mvwprintw(form_win, 0, 0, "%s", + result + cursor_position-cursor_form_win); + + /* create panels */ + panel = new_panel(win); + + /* show the cursor */ + curs_set(1); + + touchwin(win); + refresh_all_windows(main_window); + while ((res = wgetch(form_win))) { + int len = strlen(result); + switch (res) { + case 10: /* ENTER */ + case 27: /* ESCAPE */ + case KEY_F(F_HELP): + case KEY_F(F_EXIT): + case KEY_F(F_BACK): + break; + case 8: /* ^H */ + case 127: /* ^? */ + case KEY_BACKSPACE: + if (cursor_position > 0) { + memmove(&result[cursor_position-1], + &result[cursor_position], + len-cursor_position+1); + cursor_position--; + cursor_form_win--; + len--; + } + break; + case KEY_DC: + if (cursor_position >= 0 && cursor_position < len) { + memmove(&result[cursor_position], + &result[cursor_position+1], + len-cursor_position+1); + len--; + } + break; + case KEY_UP: + case KEY_RIGHT: + if (cursor_position < len) { + cursor_position++; + cursor_form_win++; + } + break; + case KEY_DOWN: + case KEY_LEFT: + if (cursor_position > 0) { + cursor_position--; + cursor_form_win--; + } + break; + case KEY_HOME: + cursor_position = 0; + cursor_form_win = 0; + break; + case KEY_END: + cursor_position = len; + cursor_form_win = min(cursor_position, prompt_width-1); + break; + default: + if ((isgraph(res) || isspace(res))) { + /* one for new char, one for '\0' */ + if (len+2 > *result_len) { + *result_len = len+2; + *resultp = result = realloc(result, + *result_len); + } + /* insert the char at the proper position */ + memmove(&result[cursor_position+1], + &result[cursor_position], + len-cursor_position+1); + result[cursor_position] = res; + cursor_position++; + cursor_form_win++; + len++; + } else { + mvprintw(0, 0, "unknown key: %d\n", res); + } + break; + } + if (cursor_form_win < 0) + cursor_form_win = 0; + else if (cursor_form_win > prompt_width-1) + cursor_form_win = prompt_width-1; + + wmove(form_win, 0, 0); + wclrtoeol(form_win); + mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); + mvwprintw(form_win, 0, 0, "%s", + result + cursor_position-cursor_form_win); + wmove(form_win, 0, cursor_form_win); + touchwin(win); + refresh_all_windows(main_window); + + if (res == 10) { + res = 0; + break; + } else if (res == 27 || res == KEY_F(F_BACK) || + res == KEY_F(F_EXIT)) { + res = KEY_EXIT; + break; + } else if (res == KEY_F(F_HELP)) { + res = 1; + break; + } + } + + /* hide the cursor */ + curs_set(0); + del_panel(panel); + delwin(prompt_win); + delwin(form_win); + delwin(win); + return res; +} + +/* refresh all windows in the correct order */ +void refresh_all_windows(WINDOW *main_window) +{ + update_panels(); + touchwin(main_window); + refresh(); +} + +/* layman's scrollable window... */ +void show_scroll_win(WINDOW *main_window, + const char *title, + const char *text) +{ + int res; + int total_lines = get_line_no(text); + int x, y, lines, columns; + int start_x = 0, start_y = 0; + int text_lines = 0, text_cols = 0; + int total_cols = 0; + int win_cols = 0; + int win_lines = 0; + int i = 0; + WINDOW *win; + WINDOW *pad; + PANEL *panel; + + getmaxyx(stdscr, lines, columns); + + /* find the widest line of msg: */ + total_lines = get_line_no(text); + for (i = 0; i < total_lines; i++) { + const char *line = get_line(text, i); + int len = get_line_length(line); + total_cols = max(total_cols, len+2); + } + + /* create the pad */ + pad = newpad(total_lines+10, total_cols+10); + (void) wattrset(pad, attributes[SCROLLWIN_TEXT]); + fill_window(pad, text); + + win_lines = min(total_lines+4, lines-2); + win_cols = min(total_cols+2, columns-2); + text_lines = max(win_lines-4, 0); + text_cols = max(win_cols-2, 0); + + /* place window in middle of screen */ + y = (lines-win_lines)/2; + x = (columns-win_cols)/2; + + win = newwin(win_lines, win_cols, y, x); + keypad(win, TRUE); + /* show the help in the help window, and show the help panel */ + (void) wattrset(win, attributes[SCROLLWIN_BOX]); + box(win, 0, 0); + (void) wattrset(win, attributes[SCROLLWIN_HEADING]); + mvwprintw(win, 0, 3, " %s ", title); + panel = new_panel(win); + + /* handle scrolling */ + do { + + copywin(pad, win, start_y, start_x, 2, 2, text_lines, + text_cols, 0); + print_in_middle(win, + text_lines+2, + 0, + text_cols, + "", + attributes[DIALOG_MENU_FORE]); + wrefresh(win); + + res = wgetch(win); + switch (res) { + case KEY_NPAGE: + case ' ': + case 'd': + start_y += text_lines-2; + break; + case KEY_PPAGE: + case 'u': + start_y -= text_lines+2; + break; + case KEY_HOME: + start_y = 0; + break; + case KEY_END: + start_y = total_lines-text_lines; + break; + case KEY_DOWN: + case 'j': + start_y++; + break; + case KEY_UP: + case 'k': + start_y--; + break; + case KEY_LEFT: + case 'h': + start_x--; + break; + case KEY_RIGHT: + case 'l': + start_x++; + break; + } + if (res == 10 || res == 27 || res == 'q' || + res == KEY_F(F_HELP) || res == KEY_F(F_BACK) || + res == KEY_F(F_EXIT)) + break; + if (start_y < 0) + start_y = 0; + if (start_y >= total_lines-text_lines) + start_y = total_lines-text_lines; + if (start_x < 0) + start_x = 0; + if (start_x >= total_cols-text_cols) + start_x = total_cols-text_cols; + } while (res); + + del_panel(panel); + delwin(win); + refresh_all_windows(main_window); +} diff --git a/scripts/config/nconf.h b/scripts/config/nconf.h new file mode 100644 index 0000000000..fa5245eb93 --- /dev/null +++ b/scripts/config/nconf.h @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2008 Nir Tzachar + * + * Derived from menuconfig. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define max(a, b) ({\ + typeof(a) _a = a;\ + typeof(b) _b = b;\ + _a > _b ? _a : _b; }) + +#define min(a, b) ({\ + typeof(a) _a = a;\ + typeof(b) _b = b;\ + _a < _b ? _a : _b; }) + +typedef enum { + NORMAL = 1, + MAIN_HEADING, + MAIN_MENU_BOX, + MAIN_MENU_FORE, + MAIN_MENU_BACK, + MAIN_MENU_GREY, + MAIN_MENU_HEADING, + SCROLLWIN_TEXT, + SCROLLWIN_HEADING, + SCROLLWIN_BOX, + DIALOG_TEXT, + DIALOG_MENU_FORE, + DIALOG_MENU_BACK, + DIALOG_BOX, + INPUT_BOX, + INPUT_HEADING, + INPUT_TEXT, + INPUT_FIELD, + FUNCTION_TEXT, + FUNCTION_HIGHLIGHT, + ATTR_MAX +} attributes_t; +extern attributes_t attributes[]; + +typedef enum { + F_HELP = 1, + F_SYMBOL = 2, + F_INSTS = 3, + F_CONF = 4, + F_BACK = 5, + F_SAVE = 6, + F_LOAD = 7, + F_SEARCH = 8, + F_EXIT = 9, +} function_key; + +void set_colors(void); + +/* this changes the windows attributes !!! */ +void print_in_middle(WINDOW *win, + int starty, + int startx, + int width, + const char *string, + chtype color); +int get_line_length(const char *line); +int get_line_no(const char *text); +const char *get_line(const char *text, int line_no); +void fill_window(WINDOW *win, const char *text); +int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); +int dialog_inputbox(WINDOW *main_window, + const char *title, const char *prompt, + const char *init, char **resultp, int *result_len); +void refresh_all_windows(WINDOW *main_window); +void show_scroll_win(WINDOW *main_window, + const char *title, + const char *text); From ab26022cc104a2dd82b7bb7e6468f693b68e75ed Mon Sep 17 00:00:00 2001 From: "Sergio E. Nemirowski" Date: Mon, 15 Jun 2020 20:58:15 +0300 Subject: [PATCH 08/55] build: mconf readme update This updates mconf.c readme message to maintain less changes with upstream and consistency with nconf.c Signed-off-by: Sergio E. Nemirowski --- scripts/config/mconf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/config/mconf.c b/scripts/config/mconf.c index a35408d2df..9ea7945675 100644 --- a/scripts/config/mconf.c +++ b/scripts/config/mconf.c @@ -23,11 +23,14 @@ #include "lxdialog/dialog.h" static const char mconf_readme[] = +"OpenWrt config is based on Kernel kconfig\n" +"so ipkg packages are referred here as modules.\n" +"\n" "Overview\n" "--------\n" -"Some OpenWrt features may be built directly into the image.\n" -"Some may be made into installable ipkg packages (referred here as\n" -"modules). Some features may be completely removed altogether.\n" +"This interface lets you select features and parameters for the build.\n" +"Features can either be built-in, modularized, or ignored. Parameters\n" +"must be entered in as decimal or hexadecimal numbers or text.\n" "\n" "Menu items beginning with following braces represent features that\n" " [ ] can be built in or removed\n" From 3caad5150c2011a7dac462acaa06d0e69f8ed005 Mon Sep 17 00:00:00 2001 From: Huangbin Zhan Date: Tue, 7 Jul 2020 07:14:42 +0800 Subject: [PATCH 09/55] build: fix compatibility with python 3.6 On a system python3 is linked to python3.6, fail to perform json_overview_image_info and got `TypeError: __init__() got an unexpected keyword argument 'capture_output'`. This patch emulate the behaviour on python 3.7+. Signed-off-by: Huangbin Zhan --- scripts/json_overview_image_info.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/json_overview_image_info.py b/scripts/json_overview_image_info.py index 8f3525f890..c76a442840 100755 --- a/scripts/json_overview_image_info.py +++ b/scripts/json_overview_image_info.py @@ -2,7 +2,7 @@ from os import getenv, environ from pathlib import Path -from subprocess import run +from subprocess import run, PIPE from sys import argv import json @@ -42,10 +42,11 @@ if output: "val.DEFAULT_PACKAGES", "val.ARCH_PACKAGES", ], - capture_output=True, + stdout=PIPE, + stderr=PIPE, check=True, env=environ.copy().update({"TOPDIR": Path().cwd()}), - text=True, + universal_newlines=True, ).stdout.splitlines() output["default_packages"] = default_packages.split() From ebddd0b327e17bcec63b2f3bc7febd45de2d5c59 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Tue, 7 Jul 2020 21:39:36 +0200 Subject: [PATCH 10/55] nat46: fix translation of ICMP protocol unreachable Refresh patch 1182f30 nat46-core: Fix translation of ICMP protocol unreachable Signed-off-by: Hans Dedecker --- package/kernel/nat46/Makefile | 6 +++--- package/kernel/nat46/patches/100-kernel-5.4-compat.patch | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package/kernel/nat46/Makefile b/package/kernel/nat46/Makefile index dfe7539c53..c7ba9a17d7 100644 --- a/package/kernel/nat46/Makefile +++ b/package/kernel/nat46/Makefile @@ -3,11 +3,11 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=nat46 -PKG_MIRROR_HASH:=3f5ef0a56e9b02c3ec10ec95f3f81c0ed04b983b2d857c16304c379106d6beb6 +PKG_MIRROR_HASH:=0627c7122ff7432aadb443e92e11a9ad7710add0ff512eebe17d7e3c041e0d2a PKG_SOURCE_URL:=https://github.com/ayourtch/nat46.git -PKG_SOURCE_DATE:=2017-05-12 +PKG_SOURCE_DATE:=2020-06-26 PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=683fbd2b765506332a1af141545652bf58f03166 +PKG_SOURCE_VERSION:=1182f30785e4274913f01a8c3d7e1b5437ae3819 PKG_MAINTAINER:=Hans Dedecker PKG_LICENSE:=GPL-2.0 diff --git a/package/kernel/nat46/patches/100-kernel-5.4-compat.patch b/package/kernel/nat46/patches/100-kernel-5.4-compat.patch index 076bf2a61d..6a638e96b5 100644 --- a/package/kernel/nat46/patches/100-kernel-5.4-compat.patch +++ b/package/kernel/nat46/patches/100-kernel-5.4-compat.patch @@ -8,7 +8,7 @@ #include "nat46-glue.h" #include "nat46-core.h" -@@ -1598,7 +1599,11 @@ void nat46_ipv6_input(struct sk_buff *ol +@@ -1601,7 +1602,11 @@ void nat46_ipv6_input(struct sk_buff *ol /* Remove any debris in the socket control block */ memset(IPCB(new_skb), 0, sizeof(struct inet_skb_parm)); /* Remove netfilter references to IPv6 packet, new netfilter references will be created based on IPv4 packet */ @@ -20,7 +20,7 @@ /* modify packet: actual IPv6->IPv4 transformation */ truncSize = v6packet_l3size - sizeof(struct iphdr); /* chop first 20 bytes */ -@@ -1803,7 +1808,11 @@ void nat46_ipv4_input(struct sk_buff *ol +@@ -1806,7 +1811,11 @@ void nat46_ipv4_input(struct sk_buff *ol /* Remove any debris in the socket control block */ memset(IPCB(new_skb), 0, sizeof(struct inet_skb_parm)); /* Remove netfilter references to IPv4 packet, new netfilter references will be created based on IPv6 packet */ From 2b479512bc27c7ba9dcfc0a74deaf9031ccf240d Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Tue, 7 Jul 2020 21:51:36 +0200 Subject: [PATCH 11/55] curl: bump to 7.71.1 For changes in 7.71.1; see https://curl.haxx.se/changes.html#7_71_1 Signed-off-by: Hans Dedecker --- package/network/utils/curl/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/network/utils/curl/Makefile b/package/network/utils/curl/Makefile index 54ca5d8b6b..7879a986b4 100644 --- a/package/network/utils/curl/Makefile +++ b/package/network/utils/curl/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=curl -PKG_VERSION:=7.71.0 +PKG_VERSION:=7.71.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz @@ -16,7 +16,7 @@ PKG_SOURCE_URL:=https://dl.uxnr.de/mirror/curl/ \ https://curl.mirror.anstey.ca/ \ https://curl.askapache.com/download/ \ https://curl.haxx.se/download/ -PKG_HASH:=cdf18794393d8bead915312708a9e5d819c6e9919de14b20d5c8e7987abd9772 +PKG_HASH:=40f83eda27cdbeb25cd4da48cefb639af1b9395d6026d2da1825bf059239658c PKG_LICENSE:=MIT PKG_LICENSE_FILES:=COPYING From 66e04abbb6d0dec8642be5deb2fca4bba470f8ac Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 7 Jul 2020 23:38:10 +0200 Subject: [PATCH 12/55] ar71xx: Fix mikrotik NAND compile problem This Fixes the folowing compile error: drivers/mtd/nand/rb91x_nand.c: In function 'rb91x_nand_remove': drivers/mtd/nand/rb91x_nand.c:445:16: error: 'rbni' undeclared (first use in this function) nand_release(&rbni->chip); Fixes: ce958dd88a7e ("kernel: Update kernel 4.14 to version 4.14.187") Signed-off-by: Hauke Mehrtens --- target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c b/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c index f5a31bf58f..94e709b7e4 100644 --- a/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c +++ b/target/linux/ar71xx/files/drivers/mtd/nand/rb91x_nand.c @@ -442,7 +442,7 @@ static int rb91x_nand_remove(struct platform_device *pdev) { struct rb91x_nand_info *info = platform_get_drvdata(pdev); - nand_release(&rbni->chip); + nand_release(&info->chip); return 0; } From 8c13ebd3ad7532fce916d1160e1218a6a40f50b1 Mon Sep 17 00:00:00 2001 From: Davide Fioravanti Date: Wed, 20 May 2020 01:27:56 +0200 Subject: [PATCH 13/55] ramips: add support for Edimax Gemini RE23S Hardware -------- SoC: Mediatek MT7621AT (880 MHz, 2 cores 4 threads) RAM: 128MB FLASH: 16MB NOR (Macronix MX25L12805D) ETH: 1x 10/100/1000 Mbps Ethernet (MT7530) WIFI: - 2.4GHz: 1x MT7615 (4x4:4) - 5GHz: 1x MT7615 (4x4:4) - 4 antennas: 2 external detachable and 2 internal BTN: - 1x Reset button - 1x WPS button LEDS: - 1x Green led (Power) - 1x Green-Amber-Red led (Wifi) UART: - 57600-8-N-1 Everything works correctly. Installation ------------ Flash the factory image directly from OEM web interface. (You can login using these credentials: admin/1234) Restore OEM Firmware -------------------- Flash the OEM "bin" firmware directly from LUCI. The firmware is downloadable from the OEM web page. Warning: Remember to not keep settings! Warning2: Remember to force the flash. Restoring procedure tested with RE23_1.08.bin MAC addresses ------------- factory 0x4 *:24 factory 0x8004 *:25 Cimage 0x07 *:24 Cimage 0x0D *:24 Cimage 0x13 *:24 Cimage 0x19 *:25 No other addresses were found in factory partition. Since the label contains both the 2.4GHz and 5GHz mac address I decided to set the 5GHz one as label-mac-device. Moreover it also corresponds to the lan mac address. Notes ----- The wifi led in the OEM firmware changes colour depending on the signal strength. This can be done in OpenWrt but just for one interface. So for now will not be any default action for this led. If you want to open the case, pay attention to the antenna placed on the bottom part of the front cover. The wire is a bit short and it breaks easily. (I broke it) Signed-off-by: Davide Fioravanti [fix two typos and add extended MAC address section to commit message] Signed-off-by: Adrian Schmutzler --- .../linux/ramips/dts/mt7621_edimax_re23s.dts | 163 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 18 ++ .../mt7621/base-files/etc/board.d/02_network | 19 +- 3 files changed, 191 insertions(+), 9 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_edimax_re23s.dts diff --git a/target/linux/ramips/dts/mt7621_edimax_re23s.dts b/target/linux/ramips/dts/mt7621_edimax_re23s.dts new file mode 100644 index 0000000000..79733152f0 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_edimax_re23s.dts @@ -0,0 +1,163 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "edimax,re23s", "mediatek,mt7621-soc"; + model = "Edimax RE23S"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_wifi_red; + led-running = &led_power; + led-upgrade = &led_power; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,57600"; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "re23s:green:power"; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + }; + + wifi_green { + label = "re23s:green:wifi"; + gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + }; + + wifi_amber { + label = "re23s:amber:wifi"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + led_wifi_red: wifi_red { + label = "re23s:red:wifi"; + gpios = <&gpio 6 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + m25p,fast-read; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootloader"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "config"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "cimage"; + reg = <0x50000 0x20000>; + read-only; + }; + + partition@70000 { + compatible = "edimax,uimage"; + label = "firmware"; + reg = <0x70000 0xf50000>; + }; + + partition@fc0000 { + label = "freespace"; + reg = <0xfc0000 0x40000>; + read-only; + }; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0x8004>; +}; + +&switch0 { + ports { + port@4 { + status = "okay"; + label = "lan"; + }; + }; +}; + +&state_default { + gpio { + groups = "uart3", "uart2", "jtag", "wdt"; + function = "gpio"; + }; +}; + +&xhci { + status = "disabled"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index d7a4b9fa7c..728b2efb24 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -261,6 +261,24 @@ define Device/edimax_ra21s endef TARGET_DEVICES += edimax_ra21s +define Device/edimax_re23s + $(Device/uimage-lzma-loader) + IMAGE_SIZE := 15680k + DEVICE_VENDOR := Edimax + DEVICE_MODEL := RE23S + DEVICE_ALT0_VENDOR := Edimax + DEVICE_ALT0_MODEL := Gemini RE23S + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \ + edimax-header -s CSYS -m RN76 -f 0x70000 -S 0x01100000 | pad-rootfs | \ + append-metadata | check-size + IMAGES += factory.bin + IMAGE/factory.bin := append-kernel | append-rootfs | \ + edimax-header -s CSYS -m RN76 -f 0x70000 -S 0x01100000 | pad-rootfs | \ + check-size + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic +endef +TARGET_DEVICES += edimax_re23s + define Device/edimax_rg21s IMAGE_SIZE := 16064k DEVICE_VENDOR := Edimax diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index a276d082e9..9665993297 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -19,6 +19,16 @@ ramips_setup_interfaces() xiaomi,mir3g-v2) ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" ;; + edimax,re23s|\ + mikrotik,routerboard-m11g|\ + netgear,ex6150|\ + thunder,timecloud|\ + tplink,re350-v1|\ + tplink,re500-v1|\ + tplink,re650-v1|\ + ubnt,unifi-nanohd) + ucidef_set_interface_lan "lan" + ;; gehua,ghl-r-001|\ hiwifi,hc5962|\ xiaomi,mir3p|\ @@ -33,15 +43,6 @@ ramips_setup_interfaces() netgear,wac104) ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ;; - mikrotik,routerboard-m11g|\ - netgear,ex6150|\ - thunder,timecloud|\ - tplink,re350-v1|\ - tplink,re500-v1|\ - tplink,re650-v1|\ - ubnt,unifi-nanohd) - ucidef_set_interface_lan "lan" - ;; mikrotik,routerboard-750gr3) ucidef_set_interfaces_lan_wan "lan2 lan3 lan4 lan5" "wan" ;; From 5c4b431a3cd00bd0e7d0d66abe5ff02d669a9266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Fri, 5 Jun 2020 13:59:41 +0200 Subject: [PATCH 14/55] generic: platform/mikrotik: fix routerboot_tag_show_u32s() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The routine would only accurately print out the first word. Signed-off-by: Thibaut VARÈNE Fixes: 5ecf7d96 ("generic: routerboot sysfs platform driver") --- .../files/drivers/platform/mikrotik/routerboot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c index 47e4471f8e..4c8c0bfac5 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c @@ -194,18 +194,18 @@ ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf) ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf) { char *out = buf; - u32 data; // cpu-endian + u32 *data; // cpu-endian /* Caller ensures pld_len > 0 */ - if (pld_len % sizeof(data)) + if (pld_len % sizeof(*data)) return -EINVAL; - data = *(u32 *)pld; + data = (u32 *)pld; do { - out += sprintf(out, "0x%08x\n", data); + out += sprintf(out, "0x%08x\n", *data); data++; - } while ((pld_len -= sizeof(data))); + } while ((pld_len -= sizeof(*data))); return out - buf; } From 2714a4faab4149d6ba9da3c7ded047caa9ea7fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Fri, 5 Jun 2020 14:06:02 +0200 Subject: [PATCH 15/55] generic: platform/mikrotik: match RouterBOOT nomenclature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RouterBOOT cpu frequency settings are letter-indexed. Follow the same logic for the sysfs interface. Signed-off-by: Thibaut VARÈNE --- .../drivers/platform/mikrotik/rb_softconfig.c | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c index 7bef497c9b..be526e9a6d 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c @@ -56,7 +56,7 @@ #include "routerboot.h" -#define RB_SOFTCONFIG_VER "0.02" +#define RB_SOFTCONFIG_VER "0.03" #define RB_SC_PR_PFX "[rb_softconfig] " /* @@ -123,20 +123,20 @@ /* * ATH79 CPU frequency indices. * It is unknown if they apply to all ATH79 RBs, and some do not seem to feature - * the up levels (QCA955x), while U3 is presumably AR9344-only. + * the upper levels (QCA955x), while F is presumably AR9344-only. */ -#define RB_CPU_FREQ_IDX_ATH79_D2 (0 << 3) -#define RB_CPU_FREQ_IDX_ATH79_D1 (1 << 3) // 0x8 -#define RB_CPU_FREQ_IDX_ATH79_N0 (2 << 3) // 0x10 - factory freq for many devices -#define RB_CPU_FREQ_IDX_ATH79_U1 (3 << 3) // 0x18 -#define RB_CPU_FREQ_IDX_ATH79_U2 (4 << 3) // 0x20 -#define RB_CPU_FREQ_IDX_ATH79_U3 (5 << 3) // 0x28 +#define RB_CPU_FREQ_IDX_ATH79_A (0 << 3) +#define RB_CPU_FREQ_IDX_ATH79_B (1 << 3) // 0x8 +#define RB_CPU_FREQ_IDX_ATH79_C (2 << 3) // 0x10 - factory freq for many devices +#define RB_CPU_FREQ_IDX_ATH79_D (3 << 3) // 0x18 +#define RB_CPU_FREQ_IDX_ATH79_E (4 << 3) // 0x20 +#define RB_CPU_FREQ_IDX_ATH79_F (5 << 3) // 0x28 #define RB_CPU_FREQ_IDX_ATH79_MIN 0 // all devices support lowest setting -#define RB_CPU_FREQ_IDX_ATH79_AR9334_MAX 5 // stops at U3 -#define RB_CPU_FREQ_IDX_ATH79_QCA953X_MAX 4 // stops at U2 -#define RB_CPU_FREQ_IDX_ATH79_QCA9556_MAX 2 // stops at N0 -#define RB_CPU_FREQ_IDX_ATH79_QCA9558_MAX 3 // stops at U1 +#define RB_CPU_FREQ_IDX_ATH79_AR9334_MAX 5 // stops at F +#define RB_CPU_FREQ_IDX_ATH79_QCA953X_MAX 4 // stops at E +#define RB_CPU_FREQ_IDX_ATH79_QCA9556_MAX 2 // stops at C +#define RB_CPU_FREQ_IDX_ATH79_QCA9558_MAX 3 // stops at D #define RB_SC_CRC32_OFFSET 4 // located right after magic @@ -387,13 +387,14 @@ static ssize_t sc_tag_store_bootdelays(const u8 *pld, u16 pld_len, const char *b /* Support CPU frequency accessors only when the tag format has been asserted */ #if defined(CONFIG_ATH79) +/* Use the same letter-based nomenclature as RouterBOOT */ static struct sc_u32tvs const sc_cpufreq_indexes_ath79[] = { - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_D2, "-2"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_D1, "-1"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_N0, "0"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_U1, "+1"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_U2, "+2"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_U3, "+3"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_A, "a"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_B, "b"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_C, "c"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_D, "d"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_E, "e"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_F, "f"), }; static int sc_tag_cpufreq_ath79_idxmax(void) From 0217a9be0d84438251401bd4a8d21d3e857c5e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Fri, 5 Jun 2020 15:56:15 +0200 Subject: [PATCH 16/55] generic: platform/mikrotik: graceful fallback for cpufreq_index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code would return an error on ath79 when the SoC isn't known to the driver. Return the raw hex value instead, as happens with non supported targets. Also return the correctly incremented value from sc_tag_cpufreq_ath79_arraysize() Signed-off-by: Thibaut VARÈNE --- .../drivers/platform/mikrotik/rb_softconfig.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c index be526e9a6d..5cfb08f8ac 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c @@ -168,8 +168,9 @@ static ssize_t sc_tag_show_u32tvs(const u8 *pld, u16 pld_len, char *buf, u32 data; // cpu-endian int i; + // fallback to raw hex output if we can't handle the input if (tvselmts < 0) - return tvselmts; + return routerboot_tag_show_u32s(pld, pld_len, buf); if (sizeof(data) != pld_len) return -EINVAL; @@ -397,30 +398,32 @@ static struct sc_u32tvs const sc_cpufreq_indexes_ath79[] = { RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_F, "f"), }; -static int sc_tag_cpufreq_ath79_idxmax(void) +static int sc_tag_cpufreq_ath79_arraysize(void) { - int idx_max = -EOPNOTSUPP; + int idx_max; if (soc_is_ar9344()) - idx_max = RB_CPU_FREQ_IDX_ATH79_AR9334_MAX; + idx_max = RB_CPU_FREQ_IDX_ATH79_AR9334_MAX+1; else if (soc_is_qca953x()) - idx_max = RB_CPU_FREQ_IDX_ATH79_QCA953X_MAX; + idx_max = RB_CPU_FREQ_IDX_ATH79_QCA953X_MAX+1; else if (soc_is_qca9556()) - idx_max = RB_CPU_FREQ_IDX_ATH79_QCA9556_MAX; + idx_max = RB_CPU_FREQ_IDX_ATH79_QCA9556_MAX+1; else if (soc_is_qca9558()) - idx_max = RB_CPU_FREQ_IDX_ATH79_QCA9558_MAX; + idx_max = RB_CPU_FREQ_IDX_ATH79_QCA9558_MAX+1; + else + idx_max = -EOPNOTSUPP; return idx_max; } static ssize_t sc_tag_show_cpufreq_indexes(const u8 *pld, u16 pld_len, char * buf) { - return sc_tag_show_u32tvs(pld, pld_len, buf, sc_cpufreq_indexes_ath79, sc_tag_cpufreq_ath79_idxmax()+1); + return sc_tag_show_u32tvs(pld, pld_len, buf, sc_cpufreq_indexes_ath79, sc_tag_cpufreq_ath79_arraysize()); } static ssize_t sc_tag_store_cpufreq_indexes(const u8 *pld, u16 pld_len, const char *buf, size_t count) { - return sc_tag_store_u32tvs(pld, pld_len, buf, count, sc_cpufreq_indexes_ath79, sc_tag_cpufreq_ath79_idxmax()+1); + return sc_tag_store_u32tvs(pld, pld_len, buf, count, sc_cpufreq_indexes_ath79, sc_tag_cpufreq_ath79_arraysize()); } #else /* By default we only show the raw value to help with reverse-engineering */ From a874c87f4c43438ac700dc68a1a7f750c7ad878f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Sat, 6 Jun 2020 15:46:08 +0200 Subject: [PATCH 17/55] generic: platform/mikrotik: add board_revision tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tag was discovered exploring the hard_config of a "r2" board. Signed-off-by: Thibaut VARÈNE --- .../files/drivers/platform/mikrotik/rb_hardconfig.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c b/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c index 992689605d..4559418de7 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_hardconfig.c @@ -39,7 +39,7 @@ #include "routerboot.h" -#define RB_HARDCONFIG_VER "0.04" +#define RB_HARDCONFIG_VER "0.05" #define RB_HC_PR_PFX "[rb_hardconfig] " /* ID values for hardware settings */ @@ -58,6 +58,7 @@ #define RB_ID_BOARD_IDENTIFIER 0x17 #define RB_ID_PRODUCT_NAME 0x21 #define RB_ID_DEFCONF 0x26 +#define RB_ID_BOARD_REVISION 0x27 /* Bit definitions for hardware options */ #define RB_HW_OPT_NO_UART BIT(0) @@ -415,6 +416,10 @@ static struct hc_attr { .tag_id = RB_ID_DEFCONF, .tshow = routerboot_tag_show_string, .kattr = __ATTR(defconf, S_IRUSR, hc_attr_show, NULL), + }, { + .tag_id = RB_ID_BOARD_REVISION, + .tshow = routerboot_tag_show_string, + .kattr = __ATTR(board_revision, S_IRUSR, hc_attr_show, NULL), } }; From 78fffc2dfdb8736d82103e17bb936bdd48fb902b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Date: Sun, 21 Jun 2020 12:59:56 +0200 Subject: [PATCH 18/55] generic: platform/mikrotik: add partial AR71xx cpufreq support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds cpu frequency setting for AR724x and AR7161. It is unknown if all the AR71xx devices support the same value range, so support is only enabled for AR7161 at this stage. Signed-off-by: Thibaut VARÈNE --- .../drivers/platform/mikrotik/rb_softconfig.c | 97 +++++++++++++------ 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c index 5cfb08f8ac..51a178ec7c 100644 --- a/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c +++ b/target/linux/generic/files/drivers/platform/mikrotik/rb_softconfig.c @@ -121,22 +121,36 @@ #define RB_BOOT_DEVICE_FLSHONCE 8 // "boot in flash configuration mode once, then NAND" /* - * ATH79 CPU frequency indices. + * ATH79 9xxx CPU frequency indices. * It is unknown if they apply to all ATH79 RBs, and some do not seem to feature * the upper levels (QCA955x), while F is presumably AR9344-only. */ -#define RB_CPU_FREQ_IDX_ATH79_A (0 << 3) -#define RB_CPU_FREQ_IDX_ATH79_B (1 << 3) // 0x8 -#define RB_CPU_FREQ_IDX_ATH79_C (2 << 3) // 0x10 - factory freq for many devices -#define RB_CPU_FREQ_IDX_ATH79_D (3 << 3) // 0x18 -#define RB_CPU_FREQ_IDX_ATH79_E (4 << 3) // 0x20 -#define RB_CPU_FREQ_IDX_ATH79_F (5 << 3) // 0x28 +#define RB_CPU_FREQ_IDX_ATH79_9X_A (0 << 3) +#define RB_CPU_FREQ_IDX_ATH79_9X_B (1 << 3) // 0x8 +#define RB_CPU_FREQ_IDX_ATH79_9X_C (2 << 3) // 0x10 - factory freq for many devices +#define RB_CPU_FREQ_IDX_ATH79_9X_D (3 << 3) // 0x18 +#define RB_CPU_FREQ_IDX_ATH79_9X_E (4 << 3) // 0x20 +#define RB_CPU_FREQ_IDX_ATH79_9X_F (5 << 3) // 0x28 -#define RB_CPU_FREQ_IDX_ATH79_MIN 0 // all devices support lowest setting -#define RB_CPU_FREQ_IDX_ATH79_AR9334_MAX 5 // stops at F -#define RB_CPU_FREQ_IDX_ATH79_QCA953X_MAX 4 // stops at E -#define RB_CPU_FREQ_IDX_ATH79_QCA9556_MAX 2 // stops at C -#define RB_CPU_FREQ_IDX_ATH79_QCA9558_MAX 3 // stops at D +#define RB_CPU_FREQ_IDX_ATH79_9X_MIN 0 // all devices support lowest setting +#define RB_CPU_FREQ_IDX_ATH79_9X_AR9334_MAX 5 // stops at F +#define RB_CPU_FREQ_IDX_ATH79_9X_QCA953X_MAX 4 // stops at E +#define RB_CPU_FREQ_IDX_ATH79_9X_QCA9556_MAX 2 // stops at C +#define RB_CPU_FREQ_IDX_ATH79_9X_QCA9558_MAX 3 // stops at D + +/* ATH79 7xxx CPU frequency indices. */ +#define RB_CPU_FREQ_IDX_ATH79_7X_A ((0 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_B ((1 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_C ((2 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_D ((3 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_E ((4 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_F ((5 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_G ((6 * 9) << 4) +#define RB_CPU_FREQ_IDX_ATH79_7X_H ((7 * 9) << 4) + +#define RB_CPU_FREQ_IDX_ATH79_7X_MIN 0 // all devices support lowest setting +#define RB_CPU_FREQ_IDX_ATH79_7X_AR724X_MAX 3 // stops at D +#define RB_CPU_FREQ_IDX_ATH79_7X_AR7161_MAX 7 // stops at H - check if applies to all AR71xx devices #define RB_SC_CRC32_OFFSET 4 // located right after magic @@ -389,41 +403,70 @@ static ssize_t sc_tag_store_bootdelays(const u8 *pld, u16 pld_len, const char *b /* Support CPU frequency accessors only when the tag format has been asserted */ #if defined(CONFIG_ATH79) /* Use the same letter-based nomenclature as RouterBOOT */ -static struct sc_u32tvs const sc_cpufreq_indexes_ath79[] = { - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_A, "a"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_B, "b"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_C, "c"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_D, "d"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_E, "e"), - RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_F, "f"), +static struct sc_u32tvs const sc_cpufreq_indexes_ath79_9x[] = { + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_9X_A, "a"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_9X_B, "b"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_9X_C, "c"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_9X_D, "d"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_9X_E, "e"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_9X_F, "f"), +}; + +static struct sc_u32tvs const sc_cpufreq_indexes_ath79_7x[] = { + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_A, "a"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_B, "b"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_C, "c"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_D, "d"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_E, "e"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_F, "f"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_G, "g"), + RB_SC_TVS(RB_CPU_FREQ_IDX_ATH79_7X_H, "h"), }; static int sc_tag_cpufreq_ath79_arraysize(void) { int idx_max; - if (soc_is_ar9344()) - idx_max = RB_CPU_FREQ_IDX_ATH79_AR9334_MAX+1; + if (ATH79_SOC_AR7161 == ath79_soc) + idx_max = RB_CPU_FREQ_IDX_ATH79_7X_AR7161_MAX+1; + else if (soc_is_ar724x()) + idx_max = RB_CPU_FREQ_IDX_ATH79_7X_AR724X_MAX+1; + else if (soc_is_ar9344()) + idx_max = RB_CPU_FREQ_IDX_ATH79_9X_AR9334_MAX+1; else if (soc_is_qca953x()) - idx_max = RB_CPU_FREQ_IDX_ATH79_QCA953X_MAX+1; + idx_max = RB_CPU_FREQ_IDX_ATH79_9X_QCA953X_MAX+1; else if (soc_is_qca9556()) - idx_max = RB_CPU_FREQ_IDX_ATH79_QCA9556_MAX+1; + idx_max = RB_CPU_FREQ_IDX_ATH79_9X_QCA9556_MAX+1; else if (soc_is_qca9558()) - idx_max = RB_CPU_FREQ_IDX_ATH79_QCA9558_MAX+1; + idx_max = RB_CPU_FREQ_IDX_ATH79_9X_QCA9558_MAX+1; else idx_max = -EOPNOTSUPP; return idx_max; } -static ssize_t sc_tag_show_cpufreq_indexes(const u8 *pld, u16 pld_len, char * buf) +static ssize_t sc_tag_show_cpufreq_indexes(const u8 *pld, u16 pld_len, char *buf) { - return sc_tag_show_u32tvs(pld, pld_len, buf, sc_cpufreq_indexes_ath79, sc_tag_cpufreq_ath79_arraysize()); + const struct sc_u32tvs *tvs; + + if (soc_is_ar71xx() || soc_is_ar724x()) + tvs = sc_cpufreq_indexes_ath79_7x; + else + tvs = sc_cpufreq_indexes_ath79_9x; + + return sc_tag_show_u32tvs(pld, pld_len, buf, tvs, sc_tag_cpufreq_ath79_arraysize()); } static ssize_t sc_tag_store_cpufreq_indexes(const u8 *pld, u16 pld_len, const char *buf, size_t count) { - return sc_tag_store_u32tvs(pld, pld_len, buf, count, sc_cpufreq_indexes_ath79, sc_tag_cpufreq_ath79_arraysize()); + const struct sc_u32tvs *tvs; + + if (soc_is_ar71xx() || soc_is_ar724x()) + tvs = sc_cpufreq_indexes_ath79_7x; + else + tvs = sc_cpufreq_indexes_ath79_9x; + + return sc_tag_store_u32tvs(pld, pld_len, buf, count, tvs, sc_tag_cpufreq_ath79_arraysize()); } #else /* By default we only show the raw value to help with reverse-engineering */ From 53a1fede1f9856b61092ce4693e7610a515d562b Mon Sep 17 00:00:00 2001 From: Emir Efe Kucuk Date: Sat, 30 May 2020 12:18:50 +0300 Subject: [PATCH 19/55] ramips: Add support for Xiaomi Mi Router(Black,R2100) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Xiaomi Mi Router AC2100 is a *black* cylindrical router that shares many characteristics (apart from its looks and the GPIO ports) with the 6-antenna *white* "Xiaomi Redmi Router AC2100" See the visual comparison of the two routers here: https://github.com/emirefek/openwrt-R2100/raw/imgcdn/rm2100-r2100.jpg Specification of R2100: - CPU: MediaTek MT7621A - RAM: 128 MB DDR3 - FLASH: 128 MB ESMT NAND - WIFI: 2x2 802.11bgn (MT7603) - WIFI: 4x4 802.11ac (MT7615) - ETH: 3xLAN+1xWAN 1000base-T - LED: Power, WAN in Yellow and Blue - UART: On board (Don't know where is should be confirmed by anybody else) - Modified u-boot Hacking of official firmware process is same at both RM2100 and R2100. Thanks to @namidairo Here is the detailed guide Hack: https://github.com/impulse/ac2100-openwrt-guide Guide is written for MacOS but it will work at linux. needed packages: python3(with scapy), netcat, http server, telnet client 1. Run PPPoE&exploit to get nc and wget busybox, get telnet and wget firmware 2. mtd write openwrt-ramips-mt7621-xiaomi_mi-router-ac2100-kernel1.bin kernel1 3. nvram set uart_en=1 4. nvram set bootdelay=5 5. nvram set flag_try_sys1_failed=1 6. nvram commit 7. mtd -r write openwrt-ramips-mt7621-xiaomi_mi-router-ac2100-rootfs0.bin rootfs0 other than these I specified in here. Everything is same with: https://github.com/openwrt/openwrt/commit/f3792690c4f0567a8965d82898295b9d50c3bb7e Thanks for all community and especially for this device: @Ilyas @scp07 @namidairo @Percy @thorsten97 @impulse (names@forum.openwrt.com) MAC Locations: WAN *:b5 = factory 0xe006 LAN *:b6 = factory 0xe000 WIFI 5ghz *:b8 = factory 0x8004 WIFI 2.4ghz *:b7 = factory 0x0004 Signed-off-by: Emir Efe Kucuk [refactored common image bits into Device/xiaomi-ac2100, fixed From:] Signed-off-by: Petr Štetiar --- package/boot/uboot-envtools/files/ramips | 1 + .../dts/mt7621_xiaomi_mi-router-ac2100.dts | 41 +++++ .../dts/mt7621_xiaomi_redmi-router-ac2100.dts | 144 +---------------- .../dts/mt7621_xiaomi_router-ac2100.dtsi | 146 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 34 ++-- .../mt7621/base-files/etc/board.d/01_leds | 3 + .../mt7621/base-files/etc/board.d/02_network | 1 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 8 files changed, 216 insertions(+), 155 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts create mode 100644 target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index d48be8d27c..701f051f77 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -34,6 +34,7 @@ zbtlink,zbt-wg2626) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000" ;; linksys,ea7500-v2|\ +xiaomi,mi-router-ac2100|\ xiaomi,mir3p|\ xiaomi,mir3g|\ xiaomi,redmi-router-ac2100) diff --git a/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts new file mode 100644 index 0000000000..885ea05c62 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_mi-router-ac2100.dts @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7621_xiaomi_router-ac2100.dtsi" + +/ { + compatible = "xiaomi,mi-router-ac2100", "mediatek,mt7621-soc"; + model = "Xiaomi Mi Router AC2100"; + + aliases { + led-boot = &led_status_yellow; + led-failsafe = &led_status_yellow; + led-running = &led_status_blue; + led-upgrade = &led_status_blue; + label-mac-device = &gmac0; + }; + + leds { + compatible = "gpio-leds"; + + wan_yellow { + label = "mi-router-ac2100:yellow:wan"; + gpios = <&gpio 6 GPIO_ACTIVE_LOW>; + }; + + wan_blue { + label = "mi-router-ac2100:blue:wan"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + }; + + led_status_yellow: status_yellow { + label = "mi-router-ac2100:yellow:status"; + gpios = <&gpio 10 GPIO_ACTIVE_LOW>; + }; + + led_status_blue: status_blue { + label = "mi-router-ac2100:blue:status"; + gpios = <&gpio 12 GPIO_ACTIVE_LOW>; + }; + }; +}; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts b/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts index f0bc1aeb96..ceaeec750c 100644 --- a/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts +++ b/target/linux/ramips/dts/mt7621_xiaomi_redmi-router-ac2100.dts @@ -1,10 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later OR MIT /dts-v1/; -#include "mt7621.dtsi" - -#include -#include +#include "mt7621_xiaomi_router-ac2100.dtsi" / { compatible = "xiaomi,redmi-router-ac2100", "mediatek,mt7621-soc"; @@ -18,10 +15,6 @@ label-mac-device = &gmac0; }; - chosen { - bootargs = "console=ttyS0,115200n8"; - }; - leds { compatible = "gpio-leds"; @@ -45,139 +38,4 @@ gpios = <&gpio 12 GPIO_ACTIVE_LOW>; }; }; - - keys { - compatible = "gpio-keys"; - - reset { - label = "reset"; - gpios = <&gpio 18 GPIO_ACTIVE_LOW>; - linux,code = ; - }; - }; - -}; - - -&nand { - status = "okay"; - - partitions { - compatible = "fixed-partitions"; - #address-cells = <1>; - #size-cells = <1>; - - partition@0 { - label = "Bootloader"; - reg = <0x0 0x80000>; - read-only; - }; - - partition@80000 { - label = "Config"; - reg = <0x80000 0x40000>; - }; - - partition@c0000 { - label = "Bdata"; - reg = <0xc0000 0x40000>; - read-only; - }; - - factory: partition@100000 { - label = "factory"; - reg = <0x100000 0x40000>; - read-only; - }; - - partition@140000 { - label = "crash"; - reg = <0x140000 0x40000>; - }; - - partition@180000 { - label = "crash_syslog"; - reg = <0x180000 0x40000>; - }; - - partition@1c0000 { - label = "reserved0"; - reg = <0x1c0000 0x40000>; - read-only; - }; - - /* We keep stock xiaomi firmware (kernel0) here */ - partition@200000 { - label = "kernel_stock"; - reg = <0x200000 0x400000>; - }; - - partition@600000 { - label = "kernel"; - reg = <0x600000 0x400000>; - }; - - partition@a00000 { - label = "ubi"; - reg = <0xa00000 0x7580000>; - }; - }; -}; - -&pcie { - status = "okay"; -}; - -&pcie0 { - wifi@0,0 { - compatible = "mediatek,mt76"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x8000>; - ieee80211-freq-limit = <5000000 6000000>; - }; -}; - -&pcie1 { - wifi@0,0 { - compatible = "mediatek,mt76"; - reg = <0x0000 0 0 0 0>; - mediatek,mtd-eeprom = <&factory 0x0000>; - ieee80211-freq-limit = <2400000 2500000>; - }; -}; - -&gmac0 { - mtd-mac-address = <&factory 0xe000>; -}; - -&switch0 { - ports { - port@0 { - status = "okay"; - label = "wan"; - mtd-mac-address = <&factory 0xe006>; - }; - - port@2 { - status = "okay"; - label = "lan1"; - }; - - port@3 { - status = "okay"; - label = "lan2"; - }; - - port@4 { - status = "okay"; - label = "lan3"; - }; - }; -}; - -&state_default { - gpio { - groups = "uart2", "uart3", "wdt"; - function = "gpio"; - }; }; diff --git a/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi b/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi new file mode 100644 index 0000000000..d19a3440b5 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_xiaomi_router-ac2100.dtsi @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include + +/ { + + chosen { + bootargs = "console=ttyS0,115200n8"; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x80000>; + read-only; + }; + + partition@80000 { + label = "Config"; + reg = <0x80000 0x40000>; + }; + + partition@c0000 { + label = "Bdata"; + reg = <0xc0000 0x40000>; + read-only; + }; + + factory: partition@100000 { + label = "factory"; + reg = <0x100000 0x40000>; + read-only; + }; + + partition@140000 { + label = "crash"; + reg = <0x140000 0x40000>; + }; + + partition@180000 { + label = "crash_syslog"; + reg = <0x180000 0x40000>; + }; + + partition@1c0000 { + label = "reserved0"; + reg = <0x1c0000 0x40000>; + read-only; + }; + + /* We keep stock xiaomi firmware (kernel0) here */ + partition@200000 { + label = "kernel_stock"; + reg = <0x200000 0x400000>; + }; + + partition@600000 { + label = "kernel"; + reg = <0x600000 0x400000>; + }; + + partition@a00000 { + label = "ubi"; + reg = <0xa00000 0x7580000>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x8000>; + ieee80211-freq-limit = <5000000 6000000>; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0000>; + ieee80211-freq-limit = <2400000 2500000>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe000>; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "wan"; + mtd-mac-address = <&factory 0xe006>; + }; + + port@2 { + status = "okay"; + label = "lan1"; + }; + + port@3 { + status = "okay"; + label = "lan2"; + }; + + port@4 { + status = "okay"; + label = "lan3"; + }; + }; +}; + +&state_default { + gpio { + groups = "uart2", "uart3", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 728b2efb24..9103fd6762 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -957,6 +957,27 @@ define Device/wevo_w2914ns-v2 endef TARGET_DEVICES += wevo_w2914ns-v2 +define Device/xiaomi-ac2100 + $(Device/uimage-lzma-loader) + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 120320k + UBINIZE_OPTS := -E 5 + IMAGES += kernel1.bin rootfs0.bin + IMAGE/kernel1.bin := append-kernel + IMAGE/rootfs0.bin := append-ubi | check-size + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_VENDOR := Xiaomi + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware wpad-basic uboot-envtools +endef + +define Device/xiaomi_mi-router-ac2100 + $(Device/xiaomi-ac2100) + DEVICE_MODEL := Mi Router AC2100 +endef +TARGET_DEVICES += xiaomi_mi-router-ac2100 + define Device/xiaomi_mir3g $(Device/uimage-lzma-loader) BLOCKSIZE := 128k @@ -1009,19 +1030,8 @@ endef TARGET_DEVICES += xiaomi_mir3p define Device/xiaomi_redmi-router-ac2100 - $(Device/uimage-lzma-loader) - BLOCKSIZE := 128k - PAGESIZE := 2048 - KERNEL_SIZE := 4096k - IMAGE_SIZE := 124416k - UBINIZE_OPTS := -E 5 - IMAGES += kernel1.bin rootfs0.bin - IMAGE/kernel1.bin := append-kernel - IMAGE/rootfs0.bin := append-ubi | check-size - IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - DEVICE_VENDOR := Xiaomi + $(Device/xiaomi-ac2100) DEVICE_MODEL := Redmi Router AC2100 - DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware wpad-basic uboot-envtools endef TARGET_DEVICES += xiaomi_redmi-router-ac2100 diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds index 37ebd0fb64..a0f9b2b10d 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/01_leds @@ -82,6 +82,9 @@ tplink,re650-v1) xzwifi,creativebox-v1) ucidef_set_led_netdev "internet" "internet" "$boardname:blue:internet" "wan" ;; +xiaomi,mi-router-ac2100) + ucidef_set_led_netdev "wan-blue" "WAN (blue)" "$boardname:blue:wan" "wan" + ;; xiaomi,redmi-router-ac2100) ucidef_set_led_netdev "wan" "wan" "$boardname:white:wan" "wan" ;; diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 9665993297..4b65dd2364 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -31,6 +31,7 @@ ramips_setup_interfaces() ;; gehua,ghl-r-001|\ hiwifi,hc5962|\ + xiaomi,mi-router-ac2100|\ xiaomi,mir3p|\ xiaomi,redmi-router-ac2100) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 233ed80b4e..00b2ffa89e 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -55,6 +55,7 @@ platform_do_upgrade() { netgear,wac104|\ netgear,wac124|\ netis,wf2881|\ + xiaomi,mi-router-ac2100|\ xiaomi,mir3g|\ xiaomi,mir3p|\ xiaomi,redmi-router-ac2100) From 9f020269332d50dba61f5bce5f1d055b683b059e Mon Sep 17 00:00:00 2001 From: Wren Turkal Date: Mon, 25 May 2020 14:05:51 -0700 Subject: [PATCH 20/55] uclibc++: make verbosity affect uClibc++ build Before this change, setting the verbosity to anything with V=blah would cause uclibc++ build to print errors to the screen. Now, it the clibc++ build verbosity will be altered in the following manners: * V=s will set V=1 in the uclibc++ build * V=sc will set V=2 in the uclibc++ build Signed-off-by: Wren Turkal --- package/libs/uclibc++/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package/libs/uclibc++/Makefile b/package/libs/uclibc++/Makefile index 7a0d9094ff..0e3210a5b9 100644 --- a/package/libs/uclibc++/Makefile +++ b/package/libs/uclibc++/Makefile @@ -55,6 +55,14 @@ ifeq ($(CONFIG_USE_MUSL),y) SSP_LIB=-lssp_nonshared endif +ifeq (${V}, s) +MAKE_VARS+= \ + V=1 +else ifeq (${V}, sc) +MAKE_VARS+= \ + V=2 +endif + MAKE_FLAGS:= \ $(TARGET_CONFIGURE_OPTS) \ CPU_CFLAGS="$(TARGET_CFLAGS)" \ From b88f8202c4ced971de26268597d2e798ecdc0ba2 Mon Sep 17 00:00:00 2001 From: Lucian Cristian Date: Sun, 12 Apr 2020 17:45:41 +0300 Subject: [PATCH 21/55] kernel: add iscsi-initator support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Module is needed for using iscsi-initiator userspace applications Signed-off-by: Lucian Cristian [added missing newline between kernel modules] Signed-off-by: Petr Štetiar --- package/kernel/linux/modules/block.mk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/package/kernel/linux/modules/block.mk b/package/kernel/linux/modules/block.mk index b870304ad4..a86c60da2a 100644 --- a/package/kernel/linux/modules/block.mk +++ b/package/kernel/linux/modules/block.mk @@ -270,6 +270,32 @@ endef $(eval $(call KernelPackage,dm-raid)) +define KernelPackage/iscsi-initiator + SUBMENU:=$(BLOCK_MENU) + TITLE:=iSCSI Initiator over TCP/IP + DEPENDS:=+kmod-scsi-core + KCONFIG:= \ + CONFIG_INET \ + CONFIG_SCSI_LOWLEVEL \ + CONFIG_ISCSI_TCP \ + CONFIG_SCSI_ISCSI_ATTRS + FILES:= \ + $(LINUX_DIR)/drivers/scsi/iscsi_tcp.ko \ + $(LINUX_DIR)/drivers/scsi/libiscsi.ko \ + $(LINUX_DIR)/drivers/scsi/libiscsi_tcp.ko \ + $(LINUX_DIR)/drivers/scsi/scsi_transport_iscsi.ko + AUTOLOAD:=$(call AutoProbe,libiscsi libiscsi_tcp scsi_transport_iscsi iscsi_tcp) +endef + +define KernelPackage/iscsi-initiator/description +The iSCSI Driver provides a host with the ability to access storage through an +IP network. The driver uses the iSCSI protocol to transport SCSI requests and +responses over a TCP/IP network between the host (the "initiator") and "targets". +endef + +$(eval $(call KernelPackage,iscsi-initiator)) + + define KernelPackage/md-mod SUBMENU:=$(BLOCK_MENU) TITLE:=MD RAID From f103321349182d5fef5a1b846f017db32005da87 Mon Sep 17 00:00:00 2001 From: Dongming Han Date: Wed, 8 Apr 2020 16:43:51 +0800 Subject: [PATCH 22/55] ipq40xx: add support for GL.iNet GL-S1300 Specifications: SOC: Qualcomm IPQ4029 (DAKOTA) ARM Quad-Core RAM: 512 MiB FLASH1: 16 MiB NOR - SPI0 FLASH2: 8 GiB eMMC ETH: Qualcomm QCA8075 WLAN1: Qualcomm Atheros QCA4029 2.4GHz 802.11b/g/n 2x2 WLAN2: Qualcomm Atheros QCA4029 5GHz 802.11n/ac W2 2x2 INPUT: Reset, WPS LED: Power, Mesh, WLAN UART1: On board pin header near to LED (3.3V, TX, RX, GND), 3.3V without pin - 115200 8N1 UART2: On board with BLE module SPI1: On board socket for Zigbee module Install via tftp - NB: need to flash transition image firstly Firstly install transition image: (IPQ40xx) # tftpboot 0x84000000 s1300-factory-to-openwrt.img (IPQ40xx) # sf probe && imgaddr=0x84000000 && source :script Secondly install openwrt sysupgrade bin: (IPQ40xx) # run lf Revert to factory image: (IPQ40xx) # tftpboot 0x84000000 s1300-openwrt-to-factory.img (IPQ40xx) # sf probe && imgaddr=0x84000000 && source :script The kernel and rootfs of factory firmware are on eMMC, and openwrt firmware is on NOR flash. The transition image includes U-boot and partition table, which decides where to load kernel and rootfs. After you firstly install openwrt image, you can switch between factory and openwrt firmware by flashing transition image. Signed-off-by: Dongming Han --- package/firmware/ipq-wifi/Makefile | 2 + .../ipq-wifi/board-glinet_gl-s1300.qca4019 | Bin 0 -> 24276 bytes .../ipq40xx/base-files/etc/board.d/02_network | 3 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 2 + .../arm/boot/dts/qcom-ipq4029-gl-s1300.dts | 356 ++++++++++++++++++ target/linux/ipq40xx/image/Makefile | 13 + .../901-arm-boot-add-dts-files.patch | 3 +- .../901-arm-boot-add-dts-files.patch | 3 +- 8 files changed, 379 insertions(+), 3 deletions(-) create mode 100644 package/firmware/ipq-wifi/board-glinet_gl-s1300.qca4019 create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4029-gl-s1300.dts diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index c86645e253..4868b75d16 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -34,6 +34,7 @@ ALLWIFIBOARDS:= \ engenius_emd1 \ engenius_emr3500 \ ezviz_cs-w3-wd1200g-eup \ + glinet_gl-s1300 \ linksys_ea8300 \ mobipromo_cm520-79f \ qxwlan_e2600ac @@ -106,6 +107,7 @@ $(eval $(call generate-ipq-wifi-package,engenius_eap2200,EnGenius EAP2200)) $(eval $(call generate-ipq-wifi-package,engenius_emd1,EnGenius EMD1)) $(eval $(call generate-ipq-wifi-package,engenius_emr3500,EnGenius EMR3500)) $(eval $(call generate-ipq-wifi-package,ezviz_cs-w3-wd1200g-eup,EZVIZ CS-W3-WD1200G EUP)) +$(eval $(call generate-ipq-wifi-package,glinet_gl-s1300,GL.iNet GL-S1300)) $(eval $(call generate-ipq-wifi-package,linksys_ea8300,Linksys EA8300)) $(eval $(call generate-ipq-wifi-package,mobipromo_cm520-79f,MobiPromo CM520-79F)) $(eval $(call generate-ipq-wifi-package,qxwlan_e2600ac,Qxwlan E2600AC)) diff --git a/package/firmware/ipq-wifi/board-glinet_gl-s1300.qca4019 b/package/firmware/ipq-wifi/board-glinet_gl-s1300.qca4019 new file mode 100644 index 0000000000000000000000000000000000000000..b84e62f825e714ba579484c702c6d18d9fd33f01 GIT binary patch literal 24276 zcmeHPdr%We8t;T)Tt#6*Km;5@2qAGHKwvdOTmmA?BZA8c669FG7l|S-c^URZOOeHh zh%AB-h%6#6bBL5Du81q@xmQYgRadq57rS+jx+=Znw)F1Ss;k56Niv3zAc@2iVZNlN zzy7+v?yr9{naoW8l212<`-N|d4h)F%i%1Ahj08D3IRHwEKeh$H8>XzH!i|~PS-x30 zQoo(q(mX%uu8jejQdVwe!7i*AxDNV}U|Rxq8CmXscui0%3K)OG@Rjqa;@Dj@O zx|z%Nuc{p2Y_JzDSd6%?&%;bce9eLpwS6tqWTOx507LiEkD=A*w5b-;;|^OeE;h5N z$q|;Z9FSn=8w*Q^hgDTisZ* z)R-6nbU0aE0&SsM2cNZIqT_OTSxRb1j4yOOR<<)W5;p5>u7<900?w_=&2?pYsfmIB zor8~Ie6y6wpv=<5u$pi%#KUxHA)sV>X788vu4>;Gv9f^e&S8D6g;nc!c_+EX4fo_X zMV;UjxMVc-?r7R@f>G$0In*L8kK5<9#aT4eo?983&6T)`?{}A-OE|$RT(k2=Z%NaZ zlYS-cd+xU8l}GJn#yEzIcH|z5&1EM!M_%fbHbz%}SmKsFbh)_A|FB1%W5)Z15)mzq zfGzcdK;Bs|eKA78h^ZCXNz-<;#~W(GDfxdV4XM z9;r3W6d?I2w)wqJc*f^_tPT$tFs=^znRHjv<=~~|))JuakrDZm8L>(s_5jWJ0=O*5S zZkpJH#G!G#IB^gfG!cY^qM^J{F?MV;wrlqarYqYUE?&F{!+h=59FXAdn^mx5H}6Yj z-_+ziN6~+?nAS{vUf$HU5UxpyIheEe36uzwWAG-d$Cz`Q6?GC+VR5C{+m5C{+m z5C{+mEMf#!@mC=pv`_e-APKbf{Pjo}Z7D7wF{`e9V07wM|Mb8T&3KFtaIxALi+C3j zQ(q_un7cw?ZoBsk7jas)V(<|FFfUc81|Ln&;X`oj={K9r#5L9{ZQj_hXXx6f=A#Ay zWV2ab*m449E63I;$yLrBh0YIS+NF6S&ofDi~NB7lJ3j&dsi2n1dT zAbJmRGlhgOqG_-cA zuZ{d>CY|BSV=#1|`MK!UIsmM-d+3vN#2t0#xr^x_axxMTqhg*|90`IagApMr*{6;OdW04p(m{Y=7@Ftspg`Sm1g@$2Du zSEr9TjbCr(?y(0)7~vp1lA__(o8s4_@cLLUVRR~$YD-;WV@t8Y1%PWWP15f5ZbsU& zSL4peuQ%{9&966TGFyR8rvohE0`Ct1mT9+= z&)^BV$b}3p{hp*rl`yaTkpxOvWYE(`2E9L#!K3RoU_wX%_QMnqw$Tx4k` zLLfjOu;>s-NlA>?a_N8m`Po0Fa_KRC{ePbP`NtoA_yg4R{Q8%F|LY&0KK%={*~1@1 z=>4BRpLnYE7Yc&|w0%xa{_7{L&6>ax{Cb>+Zp@rEqSv<){CZ=QUSpYZV{1)%eZy?@ z`WADZl`K4dy*LGXs6G71@D4*?n(e$XJ}^?RES4ur{Ktnznw919bctZ(nzBKjFNqR( zj|`|g6mpqF;Ew$!?B;DB4uB44l|}L-32&@leMXThOOy!IgG!Z5CW#mLj{I6#C(n^Y z2pE{d@Eso?plK$PC(Dz^Zm3%nMY7K%>(w_D4YGphNC6)@oR#m#9d6z6;exT7>Q+TD z?DwOQe)ZRia+yRTRF5c{We1}-b6hkd?33-#hBR^qhBP*$ZdM*q=b zpns1t_RNRBbjv-hO0Ee!#E{v?-|yaEC#vwyS)H!vPihmK z@hGRss=Cu#_?2i8E$ez$euL;Jw}6&3+9N$1R^heZCB3{isnxH_wRmM_Pk+hRq8d*5 zs%%Ab{PDnpPTN;(9_r4j3pvc#=d|PQkh~|M+2@FJj`~VbduTPYnD%*fQ$l5Mv5Ukm z`fBgzUkQ$S)=eskT!cTe@($ecY zrRRl}UWJZnr)su;5iDcwpos>03R~h&aY|fvFWLi#m^gvJ0zkmv-!}9&Wv?{s^8a-L z*8=ro0+0Tx41vRgFShbgZ*LZS!++XfczJp8UyyWO-f7F&_v*S~dc{=DJR;|%|)T>trhyaxg{WJ0kai>3qqH7CmsCdh&jK|cJl z4sHdOV(;klj3o#llPSy6VD8`mNRg0tzjgyFfBw&th;TXr82_CD`R^%>UH9Gw|9$#+ z)-KP)tH +#include +#include + +/ { + model = "GL.iNet GL-S1300"; + compatible = "glinet,gl-s1300"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + memory { + device_type = "memory"; + reg = <0x80000000 0x10000000>; + }; + + soc { + rng@22000 { + status = "okay"; + }; + + mdio@90000 { + status = "okay"; + }; + + ess-psgmii@98000 { + status = "okay"; + }; + + tcsr@1949000 { + compatible = "qcom,tcsr"; + reg = <0x1949000 0x100>; + qcom,wifi_glb_cfg = ; + }; + + tcsr@194b000 { + /* select hostmode */ + compatible = "qcom,tcsr"; + reg = <0x194b000 0x100>; + qcom,usb-hsphy-mode-select = ; + status = "okay"; + }; + + ess_tcsr@1953000 { + compatible = "qcom,tcsr"; + reg = <0x1953000 0x1000>; + qcom,ess-interface-select = ; + }; + + tcsr@1957000 { + compatible = "qcom,tcsr"; + reg = <0x1957000 0x100>; + qcom,wifi_noc_memtype_m0_m2 = ; + }; + + usb2@60f8800 { + status = "okay"; + }; + + usb3@8af8800 { + status = "okay"; + }; + + crypto@8e3a000 { + status = "okay"; + }; + + watchdog@b017000 { + status = "okay"; + }; + + ess-switch@c000000 { + status = "okay"; + switch_lan_bmp = <0x18>; + switch_wan_bmp = <0x20>; + }; + + edma@c080000 { + status = "okay"; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&tlmm 53 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "gl-s1300:green:power"; + gpios = <&tlmm 57 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + mesh { + label = "gl-s1300:green:mesh"; + gpios = <&tlmm 59 GPIO_ACTIVE_HIGH>; + }; + + wlan { + label = "gl-s1300:green:wlan"; + gpios = <&tlmm 60 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0tpt"; + }; + }; +}; + +&vqmmc { + status = "okay"; +}; + +&sdhci { + status = "okay"; + pinctrl-0 = <&sd_pins>; + pinctrl-names = "default"; + cd-gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + vqmmc-supply = <&vqmmc>; +}; + +&blsp_dma { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&blsp1_spi1 { + pinctrl-0 = <&spi_0_pins>; + pinctrl-names = "default"; + status = "okay"; + cs-gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <24000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + SBL1@0 { + label = "SBL1"; + reg = <0x0 0x40000>; + read-only; + }; + + MIBIB@40000 { + label = "MIBIB"; + reg = <0x40000 0x20000>; + read-only; + }; + + QSEE@60000 { + label = "QSEE"; + reg = <0x60000 0x60000>; + read-only; + }; + + CDT@c0000 { + label = "CDT"; + reg = <0xc0000 0x10000>; + read-only; + }; + + DDRPARAMS@d0000 { + label = "DDRPARAMS"; + reg = <0xd0000 0x10000>; + read-only; + }; + + APPSBLENV@e0000 { + label = "APPSBLENV"; + reg = <0xe0000 0x10000>; + read-only; + }; + + APPSBL@f0000 { + label = "APPSBL"; + reg = <0xf0000 0x80000>; + read-only; + }; + + ART@170000 { + label = "ART"; + reg = <0x170000 0x10000>; + read-only; + }; + + firmware@180000 { + compatible = "denx,fit"; + label = "firmware"; + reg = <0x180000 0xe80000>; + }; + }; + }; +}; + +&blsp1_spi2 { + pinctrl-0 = <&spi_1_pins>; + pinctrl-names = "default"; + status = "okay"; + + spidev1: spi@1 { + compatible = "siliconlabs,si3210"; + reg = <0>; + spi-max-frequency = <24000000>; + }; +}; + +&blsp1_uart1 { + pinctrl-0 = <&serial_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&blsp1_uart2 { + pinctrl-0 = <&serial_1_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&tlmm { + serial_pins: serial_pinmux { + mux { + pins = "gpio16", "gpio17"; + function = "blsp_uart0"; + bias-disable; + }; + }; + + serial_1_pins: serial1_pinmux { + mux { + pins = "gpio8", "gpio9", + "gpio10", "gpio11"; + function = "blsp_uart1"; + bias-disable; + }; + }; + + spi_0_pins: spi_0_pinmux { + pinmux { + function = "blsp_spi0"; + pins = "gpio13", "gpio14", "gpio15"; + }; + pinmux_cs { + function = "gpio"; + pins = "gpio12"; + }; + pinconf { + pins = "gpio13", "gpio14", "gpio15"; + drive-strength = <12>; + bias-disable; + }; + pinconf_cs { + pins = "gpio12"; + drive-strength = <2>; + bias-disable; + output-high; + }; + }; + + spi_1_pins: spi_1_pinmux { + mux { + pins = "gpio44", "gpio46", "gpio47"; + function = "blsp_spi1"; + bias-disable; + }; + host_int { + pins = "gpio42"; + function = "gpio"; + input; + }; + cs { + pins = "gpio45"; + function = "gpio"; + bias-pull-up; + }; + wake { + pins = "gpio40"; + function = "gpio"; + output-high; + }; + reset { + pins = "gpio49"; + function = "gpio"; + output-high; + }; + }; + + sd_pins: sd_pins { + pinmux { + function = "sdio"; + pins = "gpio23", "gpio24", "gpio25", "gpio26", + "gpio28", "gpio29", "gpio30", "gpio31"; + drive-strength = <10>; + }; + + pinmux_sd_clk { + function = "sdio"; + pins = "gpio27"; + drive-strength = <16>; + }; + + pinmux_sd7 { + function = "sdio"; + pins = "gpio32"; + drive-strength = <10>; + bias-disable; + }; + }; +}; + +&usb2_hs_phy { + status = "okay"; +}; + +&usb3_hs_phy { + status = "okay"; +}; + +&usb3_ss_phy { + status = "okay"; +}; + +&wifi0 { + status = "okay"; + qcom,ath10k-calibration-variant = "GL-S1300"; +}; + +&wifi1 { + status = "okay"; + qcom,ath10k-calibration-variant = "GL-S1300"; +}; diff --git a/target/linux/ipq40xx/image/Makefile b/target/linux/ipq40xx/image/Makefile index a374c7da47..5336649c3d 100644 --- a/target/linux/ipq40xx/image/Makefile +++ b/target/linux/ipq40xx/image/Makefile @@ -437,6 +437,19 @@ define Device/glinet_gl-b1300 endef TARGET_DEVICES += glinet_gl-b1300 +define Device/glinet_gl-s1300 + $(call Device/FitImage) + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-S1300 + SOC := qcom-ipq4029 + KERNEL_SIZE := 4096k + IMAGE_SIZE := 26624k + IMAGES := sysupgrade.bin + IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata + DEVICE_PACKAGES := ipq-wifi-glinet_gl-s1300 kmod-fs-ext4 kmod-mmc kmod-spi-dev +endef +TARGET_DEVICES += glinet_gl-s1300 + define Device/linksys_ea6350v3 # The Linksys EA6350v3 has a uboot bootloader that does not # support either booting lzma kernel images nor booting UBI diff --git a/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch index 2ec1007191..fb358ed184 100644 --- a/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -785,11 +785,47 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -785,11 +785,48 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ @@ -54,6 +54,7 @@ Signed-off-by: John Crispin + qcom-ipq4029-ap-303h.dtb \ + qcom-ipq4029-ap-365.dtb \ + qcom-ipq4029-gl-b1300.dtb \ ++ qcom-ipq4029-gl-s1300.dtb \ + qcom-ipq4029-mr33.dtb \ qcom-ipq8064-ap148.dtb \ qcom-msm8660-surf.dtb \ diff --git a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch index 371faa3a09..2db36aa597 100644 --- a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -837,11 +837,48 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -837,11 +837,49 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ @@ -55,6 +55,7 @@ Signed-off-by: John Crispin + qcom-ipq4029-ap-303h.dtb \ + qcom-ipq4029-ap-365.dtb \ + qcom-ipq4029-gl-b1300.dtb \ ++ qcom-ipq4029-gl-s1300.dtb \ + qcom-ipq4029-mr33.dtb \ qcom-ipq8064-ap148.dtb \ qcom-msm8660-surf.dtb \ From 645b1ec3e2857769d7e4adb3bc4c2261af795115 Mon Sep 17 00:00:00 2001 From: "Sergio E. Nemirowski" Date: Thu, 2 Apr 2020 02:21:37 +0300 Subject: [PATCH 23/55] build: add 'make kernel_xconfig' command This adds the kernel_xconfig make target. Signed-off-by: Sergio E. Nemirowski --- include/kernel-build.mk | 2 +- include/toplevel.mk | 4 ++++ target/linux/Makefile | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/kernel-build.mk b/include/kernel-build.mk index 32c91a5b83..9dfb19ccc7 100644 --- a/include/kernel-build.mk +++ b/include/kernel-build.mk @@ -157,7 +157,7 @@ define BuildKernel compile: $(LINUX_DIR)/.modules $(MAKE) -C image compile TARGET_BUILD= - oldconfig menuconfig nconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE + oldconfig menuconfig nconfig xconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE rm -f $(LINUX_DIR)/.config.prev rm -f $(STAMP_CONFIGURED) $(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config diff --git a/include/toplevel.mk b/include/toplevel.mk index ba59595764..8564a4de73 100644 --- a/include/toplevel.mk +++ b/include/toplevel.mk @@ -169,6 +169,7 @@ kernel_oldconfig: prepare_kernel_conf ifneq ($(DISTRO_PKG_CONFIG),) kernel_menuconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH) kernel_nconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH) +kernel_xconfig: export PATH:=$(dir $(DISTRO_PKG_CONFIG)):$(PATH) endif kernel_menuconfig: prepare_kernel_conf $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig @@ -176,6 +177,9 @@ kernel_menuconfig: prepare_kernel_conf kernel_nconfig: prepare_kernel_conf $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig +kernel_xconfig: prepare_kernel_conf + $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux xconfig + staging_dir/host/.prereq-build: include/prereq-build.mk mkdir -p tmp @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \ diff --git a/target/linux/Makefile b/target/linux/Makefile index f7bbdffbf8..3a70b80bb3 100644 --- a/target/linux/Makefile +++ b/target/linux/Makefile @@ -9,5 +9,5 @@ include $(INCLUDE_DIR)/target.mk export TARGET_BUILD=1 -prereq clean download prepare compile install menuconfig nconfig oldconfig update refresh: FORCE +prereq clean download prepare compile install oldconfig menuconfig nconfig xconfig update refresh: FORCE @+$(NO_TRACE_MAKE) -C $(BOARD) $@ From 667fbb8151c7348283985f28c43aeb848f948350 Mon Sep 17 00:00:00 2001 From: Kirill Lukonin Date: Fri, 20 Mar 2020 14:08:52 +0500 Subject: [PATCH 24/55] comgt: add new script to send ussd request and get the answer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New script for comgt. Should help to fetch balance or any additional information with USSD. This script uses the standard AT command which should be supported by all modems. Run-tested on: Mikrotik wAP LTE KIT Signed-off-by: Kirill Lukonin [fixed from/sob] Signed-off-by: Petr Štetiar --- package/network/utils/comgt/files/ussd.gcom | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 package/network/utils/comgt/files/ussd.gcom diff --git a/package/network/utils/comgt/files/ussd.gcom b/package/network/utils/comgt/files/ussd.gcom new file mode 100644 index 0000000000..c5be80b2d7 --- /dev/null +++ b/package/network/utils/comgt/files/ussd.gcom @@ -0,0 +1,21 @@ +opengt + set com 115200n81 + set comecho off + set senddelay 0.02 + waitquiet 0.2 0.2 + flash 0.1 + +:start + send "AT+CUSD=1," + send $env("ussd") + send ",15" + send "^m" + waitfor 120 "+CUSD:" + if % = -1 goto timeout + get 1 "^m" $s + print $s + exit 0 + +:timeout + print "ERROR: no USSD response, timeout.\n" + exit 1 From ba59021d64d52a5ec3e75b9701d65f940c33a670 Mon Sep 17 00:00:00 2001 From: Andrey Bondar Date: Wed, 8 Jul 2020 13:51:34 +0300 Subject: [PATCH 25/55] ath79: add support for 8devices Lima board MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specification: • 650/600/216 MHz (CPU/DDR/AHB) • 64 MB of RAM (DDR2) • 32 MB of FLASH • 2T2R 2.4 GHz • 2x 10/100 Mbps Ethernet • 1x USB 2.0 Host socket • 1x miniPCIe slot • UART for serial console • 14x GPIO Flash instructions: Upgrading from ar71xx target: • Upload image into the board: scp openwrt-ath79-generic-8dev_lima-squashfs-sysupgrade.bin root@192.168.1.1/tmp/ • Run sysupgrade sysupgrade -F /tmp/openwrt-ath79-generic-8dev_lima-squashfs-sysupgrade.bin Upgrading from u-boot: • Set up tftp server with openwrt-ath79-generic-8dev_lima-initramfs-kernel.bin • Go to u-boot (reboot and press ESC when prompted) • Set TFTP server IP setenv serverip 192.168.1.254 • Set device ip from the same subnet setenv ipaddr 192.168.1.1 • Copy new firmware to board tftpboot 0x82000000 initramfs.bin • Boot OpenWRT bootm 0x82000000 • Upload image openwrt-ath79-generic-8dev_lima-squashfs-sysupgrade.bin into the board • Run sysupgrade. Signed-off-by: Andrey Bondar --- target/linux/ath79/dts/qca9531_8dev_lima.dts | 116 ++++++++++++++++++ .../etc/hotplug.d/firmware/10-ath9k-eeprom | 7 +- target/linux/ath79/image/generic.mk | 10 ++ 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 target/linux/ath79/dts/qca9531_8dev_lima.dts diff --git a/target/linux/ath79/dts/qca9531_8dev_lima.dts b/target/linux/ath79/dts/qca9531_8dev_lima.dts new file mode 100644 index 0000000000..118704ab40 --- /dev/null +++ b/target/linux/ath79/dts/qca9531_8dev_lima.dts @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca953x.dtsi" + +/ { + compatible = "8dev,lima", "qca,qca9531"; + model = "8devices Lima"; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux-code = "KEY_RESTART"; + gpios = <&gpio 16 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&pcie0 { + status = "okay"; +}; + +&uart { + status = "okay"; +}; + +&usb0 { + status = "okay"; + + dr_mode = "host"; +}; + +&usb_phy { + status = "okay"; +}; + +&wdt { + status = "okay"; +}; + +&spi { + status = "okay"; + + num-cs = <1>; + + /* Winbond W25Q256 SPI flash */ + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <45000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x000000 0x040000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x040000 0x040000>; + }; + + art: partition@80000 { + label = "art"; + reg = <0x080000 0x040000>; + read-only; + }; + + partition@c0000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x0c0000 0xf40000>; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; +}; + +ð0 { + status = "okay"; + + phy-handle = <&swphy0>; + mtd-mac-address = <&art 0x6>; + + gmac-config { + device = <&gmac>; + + switch-phy-addr-swap = <1>; + switch-phy-swap = <1>; + }; +}; + +ð1 { + status = "okay"; + + mtd-mac-address = <&art 0x0>; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; +}; diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 3db4d2a994..2573f66f4a 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -9,6 +9,10 @@ board=$(board_name) case "$FIRMWARE" in "ath9k-eeprom-ahb-18100000.wmac.bin") case $board in + 8dev,lima|\ + ubnt,unifi) + caldata_extract "art" 0x1000 0x800 + ;; avm,fritz1750e|\ avm,fritz4020|\ avm,fritz450e|\ @@ -110,9 +114,6 @@ case "$FIRMWARE" in ubnt,rocket-m) caldata_extract "art" 0x1000 0x1000 ;; - ubnt,unifi) - caldata_extract "art" 0x1000 0x800 - ;; wd,mynet-n750) caldata_extract "art" 0x5000 0x440 ath9k_patch_mac $(mtd_get_mac_ascii devdata "wlan5mac") diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 0e7efa32af..d8cac425e8 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -152,6 +152,16 @@ define Device/8dev_carambola2 endef TARGET_DEVICES += 8dev_carambola2 +define Device/8dev_lima + SOC := qca9531 + DEVICE_VENDOR := 8devices + DEVICE_MODEL := Lima + DEVICE_PACKAGES := kmod-usb2 + IMAGE_SIZE := 15616k + SUPPORTED_DEVICES += lima +endef +TARGET_DEVICES += 8dev_lima + define Device/adtran_bsap1880 SOC := ar7161 DEVICE_VENDOR := Adtran/Bluesocket From 4c2e475842fa4d1c2f1d8508d526fefac1a2948c Mon Sep 17 00:00:00 2001 From: Pawel Dembicki Date: Sat, 9 May 2020 22:08:02 +0200 Subject: [PATCH 26/55] uboot-kirkwood: add support for Zyxel NSA310S This patch modifies the u-boot config for the Zyxel NSA310S to work with OpenWrt. Signed-off-by: Pawel Dembicki --- package/boot/uboot-kirkwood/Makefile | 6 +++ .../uboot-kirkwood/patches/160-nsa310s.patch | 54 +++++++++++++++++++ .../patches/200-openwrt-config.patch | 20 +++++++ 3 files changed, 80 insertions(+) create mode 100644 package/boot/uboot-kirkwood/patches/160-nsa310s.patch diff --git a/package/boot/uboot-kirkwood/Makefile b/package/boot/uboot-kirkwood/Makefile index c1b33b4a82..d2cbc1041b 100644 --- a/package/boot/uboot-kirkwood/Makefile +++ b/package/boot/uboot-kirkwood/Makefile @@ -59,6 +59,11 @@ define U-Boot/nsa310 BUILD_DEVICES:=zyxel_nsa310b endef +define U-Boot/nsa310s + NAME:=Zyxel NSA310S + BUILD_DEVICES:=zyxel_nsa310s +endef + define U-Boot/nsa325 NAME:=Zyxel NSA325v1 and v2 BUILD_DEVICES:=zyxel_nsa325 @@ -85,6 +90,7 @@ UBOOT_TARGETS := \ ib62x0 ib62x0_second_stage \ iconnect iconnect_second_stage \ nsa310 \ + nsa310s \ nsa325 \ pogo_e02 pogo_e02_second_stage \ pogoplugv4 diff --git a/package/boot/uboot-kirkwood/patches/160-nsa310s.patch b/package/boot/uboot-kirkwood/patches/160-nsa310s.patch new file mode 100644 index 0000000000..fe0cd3f436 --- /dev/null +++ b/package/boot/uboot-kirkwood/patches/160-nsa310s.patch @@ -0,0 +1,54 @@ +--- a/configs/nsa310s_defconfig ++++ b/configs/nsa310s_defconfig +@@ -5,7 +5,7 @@ CONFIG_KIRKWOOD=y + CONFIG_SYS_TEXT_BASE=0x600000 + CONFIG_TARGET_NSA310S=y + CONFIG_ENV_SIZE=0x20000 +-CONFIG_ENV_OFFSET=0xE0000 ++CONFIG_ENV_OFFSET=0xC0000 + CONFIG_NR_DRAM_BANKS=2 + CONFIG_BOOTDELAY=3 + CONFIG_USE_PREBOOT=y +@@ -25,7 +25,7 @@ CONFIG_CMD_EXT2=y + CONFIG_CMD_FAT=y + CONFIG_CMD_JFFS2=y + CONFIG_CMD_MTDPARTS=y +-CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:0xe0000@0x0(uboot),0x20000@0xe0000(uboot_env),0x100000@0x100000(second_stage_uboot),-@0x200000(root)" ++CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:0xc0000@0x0(uboot),0x80000@0xc0000(uboot_env),-@0x140000(ubi)" + CONFIG_CMD_UBI=y + CONFIG_ISO_PARTITION=y + CONFIG_ENV_IS_IN_NAND=y +--- a/include/configs/nsa310s.h ++++ b/include/configs/nsa310s.h +@@ -30,22 +30,17 @@ + + /* default environment variables */ + #define CONFIG_BOOTCOMMAND \ +- "setenv bootargs ${console} ${mtdparts} ${bootargs_root}; " \ +- "ubi part root; " \ +- "ubifsmount ubi:rootfs; " \ +- "ubifsload 0x800000 ${kernel}; " \ +- "ubifsload 0x700000 ${fdt}; " \ +- "ubifsumount; " \ +- "fdt addr 0x700000; fdt resize; fdt chosen; " \ +- "bootz 0x800000 - 0x700000" ++ "setenv bootargs ${console} ${mtdparts} ${bootargs_root}; " \ ++ "ubi part ubi; " \ ++ "ubifsmount ubi:rootfs; " \ ++ "ubi read 0x800000 kernel; " \ ++ "bootm 0x800000" + + #define CONFIG_EXTRA_ENV_SETTINGS \ +- "console=console=ttyS0,115200\0" \ +- "mtdids=nand0=orion_nand\0" \ +- "mtdparts="CONFIG_MTDPARTS_DEFAULT \ +- "kernel=/boot/zImage\0" \ +- "fdt=/boot/nsa310s.dtb\0" \ +- "bootargs_root=ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs rw\0" ++ "console=console=ttyS0,115200\0" \ ++ "mtdids=nand0=orion_nand\0" \ ++ "mtdparts="CONFIG_MTDPARTS_DEFAULT "\0" \ ++ "bootargs_root=\0" + + /* Ethernet driver configuration */ + #ifdef CONFIG_CMD_NET diff --git a/package/boot/uboot-kirkwood/patches/200-openwrt-config.patch b/package/boot/uboot-kirkwood/patches/200-openwrt-config.patch index 2ff4f2f184..c7c811cee1 100644 --- a/package/boot/uboot-kirkwood/patches/200-openwrt-config.patch +++ b/package/boot/uboot-kirkwood/patches/200-openwrt-config.patch @@ -162,3 +162,23 @@ +CONFIG_FIT_VERBOSE=y +CONFIG_LZMA=y +CONFIG_LZO=y +--- a/configs/nsa310s_defconfig ++++ b/configs/nsa310s_defconfig +@@ -40,5 +40,8 @@ CONFIG_SYS_NS16550=y + CONFIG_USB=y + CONFIG_USB_EHCI_HCD=y + CONFIG_USB_STORAGE=y ++CONFIG_FIT=y ++CONFIG_FIT_VERBOSE=y + CONFIG_LZMA=y ++CONFIG_LZO=y + CONFIG_OF_LIBFDT=y +--- a/include/configs/nsa310s.h ++++ b/include/configs/nsa310s.h +@@ -63,4 +63,6 @@ + #define CONFIG_RTC_MV + #endif /* CONFIG_CMD_DATE */ + ++#include "openwrt-kirkwood-common.h" ++ + #endif /* _CONFIG_NSA310S_H */ From d2c3131b3fcc55d9c26abdb7cd3c32d3827c10ed Mon Sep 17 00:00:00 2001 From: Pawel Dembicki Date: Sat, 2 May 2020 15:33:14 +0200 Subject: [PATCH 27/55] kirkwood: add support for Zyxel NSA310S MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zyxel NSA310S is a NAS based on Marvell kirkwood SoC. Specification: - Processor Marvell 88F6702 1 GHz - 256MB RAM - 128MB NAND - 1x GBE LAN port (PHY: Marvell 88E1318) - 2x USB 2.0 - 1x SATA - 3x button - 7x leds - serial on J1 connector (115200 8N1) (GND-NOPIN-RX-TX-VCC) Known issues: - no kernel module for RTC. [*] - buzzer (connected to MPP43) need to be drived by 1kHz signal - no kernel module for internal MCU connected via I2C[**] [*] Karoly Pocsi made simple, unofficial driver for HT1382. It can be found here: https://www.madadmin.com/zyxel-nsa320s-es-debian-linux-4-resz/ [**] Karoly Pocsi found how CPU talk with MCU: It is possible to query the MCU-controlled fan speed and temperature: i2cget -y 0x0 0x0a 0x07 i2cget -y 0x0 0x0a 0x08 The first value (0x07) is the temperature in ° C, the second (0x08) is the time in milliseconds to complete one fan revolution (rpm = 60,000 / value). Info translated from: https://www.madadmin.com/zyxel-nsa320s-es-debian-linux-4-resz/ Installation: TFTP: 1. Run serial console and go to u-boot. 2. Copy u-boot via tftp and write to NAND: => mw 0x0800000 0xffff 0x100000 => nand erase 0x0 100000 => setenv ipaddr 192.168.1.2 => setenv serverip 192.168.1.4 => tftp 0x0800000 nsa310s-u-boot.kwb => nand write 0x0800000 0x0 0x100000 => reset 3. Run new u-Boot, repair bootcmd and restore MAC address from sticker => setenv ethaddr AA:BB:CC:DD:EE:FF => saveenv 4. Copy and run initramfs image => setenv ipaddr 192.168.1.2 => setenv serverip 192.168.1.4 => tftpboot zyxel_nsa310s-initramfs-uImage => bootm 0x800000 5. Download sysupgrade image and perform sysupgrade USB: 1. Prepare usb fat32 drive with u-boot.kwb and initramfs image. Stick it to USB 2.0 port. 2. Run serial console and go to u-boot. 3. Copy u-boot from usb and write to NAND: => mw 0x0800000 0xffff 0x100000 => nand erase 0x0 100000 => usb start => fatload usb 0 0x0800000 u-boot.kwb => nand write 0x0800000 0x0 0x100000 => reset 4. Run new u-Boot, repair bootcmd and restore MAC address from sticker => setenv ethaddr AA:BB:CC:DD:EE:FF => saveenv 5. Copy and run initramfs image: => usb start => fatload usb 0 0x0800000 initramfs-uImage => bootm 0x800000 6. Download sysupgrade image and perform sysupgrade. Based on work ThBexx DTS based on dropped support in 0ebdf0c. Tested-by: Lech Perczak Reviewed-by: Lech Perczak Signed-off-by: Pawel Dembicki [NSA310s -> NSA310S in DEVICE_MODEL] Signed-off-by: Petr Štetiar --- package/boot/uboot-envtools/files/kirkwood | 1 + .../base-files/etc/board.d/02_network | 3 +- target/linux/kirkwood/config-5.4 | 1 + .../arch/arm/boot/dts/kirkwood-nsa310s.dts | 271 ++++++++++++++++++ target/linux/kirkwood/image/Makefile | 8 + 5 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 target/linux/kirkwood/files-5.4/arch/arm/boot/dts/kirkwood-nsa310s.dts diff --git a/package/boot/uboot-envtools/files/kirkwood b/package/boot/uboot-envtools/files/kirkwood index b5f7ddccb7..5e87dd1d62 100644 --- a/package/boot/uboot-envtools/files/kirkwood +++ b/package/boot/uboot-envtools/files/kirkwood @@ -20,6 +20,7 @@ linksys,viper|\ raidsonic,ib-nas62x0|\ seagate,dockstar|\ zyxel,nsa310b|\ +zyxel,nsa310s|\ zyxel,nsa325) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" ;; diff --git a/target/linux/kirkwood/base-files/etc/board.d/02_network b/target/linux/kirkwood/base-files/etc/board.d/02_network index df01b0bb1b..a86c57117d 100755 --- a/target/linux/kirkwood/base-files/etc/board.d/02_network +++ b/target/linux/kirkwood/base-files/etc/board.d/02_network @@ -21,7 +21,8 @@ case "$board" in "raidsonic,ib-nas62x0"|\ "seagate,dockstar"|\ "seagate,goflexhome"|\ -"seagate,goflexnet") +"seagate,goflexnet"|\ +"zyxel,nsa310s") ucidef_set_interface_lan "eth0" "dhcp" ;; "linksys,audi"|\ diff --git a/target/linux/kirkwood/config-5.4 b/target/linux/kirkwood/config-5.4 index 6b68649d74..5529bf89df 100644 --- a/target/linux/kirkwood/config-5.4 +++ b/target/linux/kirkwood/config-5.4 @@ -212,6 +212,7 @@ CONFIG_LZO_DECOMPRESS=y CONFIG_MACH_KIRKWOOD=y CONFIG_MACH_MVEBU_ANY=y CONFIG_MANGLE_BOOTARGS=y +CONFIG_MARVELL_PHY=y CONFIG_MDIO_BUS=y CONFIG_MDIO_DEVICE=y CONFIG_MEMFD_CREATE=y diff --git a/target/linux/kirkwood/files-5.4/arch/arm/boot/dts/kirkwood-nsa310s.dts b/target/linux/kirkwood/files-5.4/arch/arm/boot/dts/kirkwood-nsa310s.dts new file mode 100644 index 0000000000..fe892ffdc2 --- /dev/null +++ b/target/linux/kirkwood/files-5.4/arch/arm/boot/dts/kirkwood-nsa310s.dts @@ -0,0 +1,271 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "kirkwood.dtsi" +#include "kirkwood-6281.dtsi" + +/ { + model = "ZyXEL NSA310S"; + compatible = "zyxel,nsa310s", "marvell,kirkwood-88f6702", "marvell,kirkwood"; + + aliases { + led-boot = &led_green_sys; + led-failsafe = &led_red_sys; + led-running = &led_green_sys; + led-upgrade = &led_red_sys; + }; + + memory { + device_type = "memory"; + reg = <0x00000000 0x10000000>; + }; + + chosen { + bootargs = "console=ttyS0,115200n8 earlyprintk"; + stdout-path = &uart0; + }; + + ocp@f1000000 { + pinctrl: pin-controller@10000 { + pinctrl-names = "default"; + + pmx_usb_power: pmx-usb-power { + marvell,pins = "mpp21"; + marvell,function = "gpio"; + }; + + pmx_pwr_off: pmx-pwr-off { + marvell,pins = "mpp27"; + marvell,function = "gpio"; + }; + + pmx_btn_reset: pmx-btn-reset { + marvell,pins = "mpp24"; + marvell,function = "gpio"; + }; + + pmx_btn_copy: pmx-btn-copy { + marvell,pins = "mpp25"; + marvell,function = "gpio"; + }; + + pmx_btn_power: pmx-btn-power { + marvell,pins = "mpp26"; + marvell,function = "gpio"; + }; + + pmx_led_usb_green: pmx-led-usb-green { + marvell,pins = "mpp15"; + marvell,function = "gpio"; + }; + + pmx_led_copy_green: pmx-led-copy-green { + marvell,pins = "mpp22"; + marvell,function = "gpio"; + }; + + pmx_led_copy_red: pmx-led-copy-red { + marvell,pins = "mpp23"; + marvell,function = "gpio"; + }; + + pmx_led_sys_green: pmx-led-sys-green { + marvell,pins = "mpp28"; + marvell,function = "gpio"; + }; + + pmx_led_sys_red: pmx-led-sys-red { + marvell,pins = "mpp29"; + marvell,function = "gpio"; + }; + + pmx_led_hdd1_green: pmx-led-hdd1-green { + marvell,pins = "mpp16"; + marvell,function = "gpio"; + }; + + pmx_led_hdd1_red: pmx-led-hdd1-red { + marvell,pins = "mpp13"; + marvell,function = "gpio"; + }; + + pmx_pwr_sata1: pmx-pwr-sata1 { + marvell,pins = "mpp33"; + marvell,function = "gpio"; + }; + + }; + + i2c@11000 { + status = "okay"; + + rtc@68 { + compatible = "htk,ht1382"; + reg = <0x68>; + }; + }; + + serial@12000 { + status = "okay"; + }; + }; + + regulators { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-0 = <&pmx_usb_power &pmx_pwr_sata1>; + pinctrl-names = "default"; + + usb0_power: regulator@1 { + compatible = "regulator-fixed"; + reg = <1>; + regulator-name = "USB Power"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + regulator-boot-on; + gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>; + }; + + sata1_power: regulator@2 { + compatible = "regulator-fixed"; + reg = <2>; + regulator-name = "SATA1 Power"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + regulator-boot-on; + gpio = <&gpio1 1 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-0 = <&pmx_btn_reset &pmx_btn_copy &pmx_btn_power>; + pinctrl-names = "default"; + + power { + label = "Power Button"; + linux,code = ; + gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>; + }; + + copy { + label = "Copy Button"; + linux,code = ; + gpios = <&gpio0 25 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "Reset Button"; + linux,code = ; + gpios = <&gpio0 24 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_green_sys: green-sys { + label = "nsa310s:green:sys"; + gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "default-on"; + }; + + led_red_sys: red-sys { + label = "nsa310s:red:sys"; + gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + }; + + green-hdd1 { + label = "nsa310s:green:hdd1"; + gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "ata1"; + }; + + red-hdd1 { + label = "nsa310s:red:hdd1"; + gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; + }; + + green-usb { + label = "nsa310s:green:usb"; + gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "usb-host"; + }; + + green-copy { + label = "nsa310s:green:copy"; + gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>; + }; + + red-copy { + label = "nsa310s:red:copy"; + gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; + }; + }; + + gpio_poweroff { + compatible = "gpio-poweroff"; + pinctrl-0 = <&pmx_pwr_off>; + pinctrl-names = "default"; + gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>; + }; +}; + + +ð0 { + status = "okay"; + + ethernet0-port@0 { + phy-handle = <ðphy0>; + }; +}; + +&mdio { + status = "okay"; + + ethphy0: ethernet-phy@1 { + reg = <1>; + phy-mode = "rgmii-id"; + marvell,reg-init = <0x1 0x16 0x0 0x3>, + <0x1 0x10 0x0 0x1017>, + <0x1 0x11 0x0 0x4408>, + <0x1 0x16 0x0 0x0>; + }; +}; + +&nand { + status = "okay"; + chip-delay = <35>; + + partition@0 { + label = "uboot"; + reg = <0x0000000 0x00c0000>; + read-only; + }; + partition@c0000 { + label = "uboot_env"; + reg = <0x00c0000 0x0080000>; + }; + partition@140000 { + label = "ubi"; + reg = <0x0140000 0x7ec0000>; + }; +}; + +&pciec { + status = "okay"; +}; + +&pcie0 { + status = "okay"; +}; + +&sata { + status = "okay"; + nr-ports = <1>; +}; diff --git a/target/linux/kirkwood/image/Makefile b/target/linux/kirkwood/image/Makefile index 87e0627a63..8cc69195b4 100644 --- a/target/linux/kirkwood/image/Makefile +++ b/target/linux/kirkwood/image/Makefile @@ -148,6 +148,14 @@ define Device/zyxel_nsa310b endef TARGET_DEVICES += zyxel_nsa310b +define Device/zyxel_nsa310s + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := NSA310S + DEVICE_PACKAGES := kmod-ata-marvell-sata kmod-fs-ext4 kmod-gpio-button-hotplug + DEVICE_DTS := kirkwood-nsa310s +endef +TARGET_DEVICES += zyxel_nsa310s + define Device/zyxel_nsa325 DEVICE_VENDOR := ZyXEL DEVICE_MODEL := NSA325 From 4a77a060ab6219f830390cd53c2817b621f39760 Mon Sep 17 00:00:00 2001 From: Yanase Yuki Date: Wed, 29 Jan 2020 19:27:25 +0900 Subject: [PATCH 28/55] ipq40xx: add support for Buffalo WTR-M2133HP Buffalo WTR-M2133HP is a Tri-Band router based on IPQ4019. Specification ------------- - SoC: Qualcomm IPQ4019 - RAM: 512MiB - Flash Memory: NAND 128MiB (MXIC MX30LF1G18AC) - Wi-Fi: Qualcomm IPQ4019 (2.4GHz, 1ch - 13ch) - Wi-Fi: Qualcomm IPQ4019 (5GHz, 36ch - 64ch) - Wi-Fi: Qualcomm QCA9984 (2T2R, 5GHz, 100ch - 140ch) - Ethernet: 4x 10/100/1000 Mbps (1x WAN, 3x LAN) - LED: 4x white LED, 4x orange LED, 1x blue LED - USB: 1x USB 3.0 port - Input: 2x tactile switch, 2x slide switch (2x SP3T) - Serial console: 115200bps, pinheader JP5 on PCB - Power: DC 12V 2A Flash instruction ----------------- 1. Set up a TFTP server (IP address: 192.168.11.10) 2. Rename "initramfs-fit-uImage.itb" to "WTR-M2133HP-initramfs.uImage" and put it into the TFTP server directory. 3. Connect the TFTP server and WTR-M2133HP. 4. Hold down the AOSS button, then power on the router. 5. After booting OpenWrt initramfs image, connect to the router by SSH. 6. Transfer "squashfs-nand-factory.ubi" to the router. 7. Execute the following commands. # ubidetach -p /dev/mtd15 # ubiformat /dev/mtd15 -f /tmp/openwrt-ipq40xx-generic-buffalo_wtr-m2133hp-squashfs-nand-factory.ubi # fw_setenv bootcmd bootipq 8. Perform reboot. Recover to stock firmware ------------------------- 1. Execute the following command. # fw_setenv bootcmd bootbf 2. Reboot and wait several minutes. Signed-off-by: Yanase Yuki --- package/boot/uboot-envtools/files/ipq40xx | 3 + package/firmware/ipq-wifi/Makefile | 2 + .../board-buffalo_wtr-m2133hp.qca4019 | Bin 0 -> 24332 bytes .../board-buffalo_wtr-m2133hp.qca9984 | Bin 0 -> 12172 bytes .../ipq40xx/base-files/etc/board.d/02_network | 5 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 12 + .../base-files/lib/upgrade/platform.sh | 1 + .../arm/boot/dts/qcom-ipq4019-wtr-m2133hp.dts | 419 ++++++++++++++++++ target/linux/ipq40xx/image/Makefile | 12 + .../901-arm-boot-add-dts-files.patch | 1 + .../901-arm-boot-add-dts-files.patch | 1 + 11 files changed, 456 insertions(+) create mode 100644 package/firmware/ipq-wifi/board-buffalo_wtr-m2133hp.qca4019 create mode 100644 package/firmware/ipq-wifi/board-buffalo_wtr-m2133hp.qca9984 create mode 100644 target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wtr-m2133hp.dts diff --git a/package/boot/uboot-envtools/files/ipq40xx b/package/boot/uboot-envtools/files/ipq40xx index 7bcad00b01..f427661cf7 100644 --- a/package/boot/uboot-envtools/files/ipq40xx +++ b/package/boot/uboot-envtools/files/ipq40xx @@ -37,6 +37,9 @@ openmesh,a42 |\ openmesh,a62) ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000" ;; +buffalo,wtr-m2133hp) + ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000" + ;; linksys,ea6350v3) ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000" ;; diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index 4868b75d16..ee7b194601 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -28,6 +28,7 @@ ALLWIFIBOARDS:= \ 8dev_habanero-dvk \ aruba_ap-303 \ avm_fritzrepeater-1200 \ + buffalo_wtr-m2133hp \ cellc_rtl30vw \ dlink_dap2610 \ engenius_eap2200 \ @@ -101,6 +102,7 @@ endef $(eval $(call generate-ipq-wifi-package,8dev_habanero-dvk,8devices Habanero DVK)) $(eval $(call generate-ipq-wifi-package,aruba_ap-303,Aruba AP-303)) $(eval $(call generate-ipq-wifi-package,avm_fritzrepeater-1200,AVM FRITZRepeater 1200)) +$(eval $(call generate-ipq-wifi-package,buffalo_wtr-m2133hp,Buffalo WTR-M2133HP)) $(eval $(call generate-ipq-wifi-package,cellc_rtl30vw, Cell C RTL30VW)) $(eval $(call generate-ipq-wifi-package,dlink_dap2610,D-Link DAP-2610)) $(eval $(call generate-ipq-wifi-package,engenius_eap2200,EnGenius EAP2200)) diff --git a/package/firmware/ipq-wifi/board-buffalo_wtr-m2133hp.qca4019 b/package/firmware/ipq-wifi/board-buffalo_wtr-m2133hp.qca4019 new file mode 100644 index 0000000000000000000000000000000000000000..8305ba0166a2c07054d0789f1abaf3119c7c31bf GIT binary patch literal 24332 zcmeHPdr(tX8b1j^kj26c2_WDlgl8-S2vmba2oGt12ox0!un1I<+!}d?hoK90d{Bsp zK&==eXc?48Q$)t%i&(6!ol$20*gtmmkG8Xq?##MtJ3gk}*rF3W(Y%3JyvPh)#}5jRi893_vLj#A5)WV91r1Y|Y8f_0N?_1K!P- z76wT7Z4J_uatm^b_u)lekbhZDu{7sU>DFj@US7_@f`HvSQv&Ef z%U@1K62SrvFi*KNRj*M$6L>;>&nx`@!>j!`@S2& z@D8bpnaRpyv`(9G2gz}Ou#?7RHF&;CQ zRsu>huWWhMcGl;Vhwb-Gb4wg)F0PJ~arZK#Z}$|n#+~phcFu0?&1elf!76dc>8i_- zhvoY0*bslK@le$^secAD;;Zh;kCRVuOE$cFqqn?udwoE;Ti)Qw{ECSEoHQitChQlB zaWfnuE_F%Iit64hcg?^4X<2(**&ZIAY!5a&jb=UNnS?Nj zOcxP>J$q7<*lc$=!_PlI`EhIve*)rjygl`G|NZe#KN!~G9XHroQE9aQ>1?8aN&Tl! zA3xIfT|{$rLl^eJ=Mk7ItZwMT177JgF78WQbPJdgAt-`Gp;1UM8jKXm4_6=ku%Y?v z^b8P;%dI(O=qQ~_e?UiEP#3O?*dDbWedHCu|Z3CafZ})Ao-!kT{?Yj~x(K)RpThjzMD{#~_JlA~#VS zf`&W}LBi2+Zn#*#6AWYBRC?$aJ;o2)!VlGbhQa$4#o*R5V|L1^@=C>(@Jvds!JI>Y zM2SRc76iycV-{eHs#hgSMhK7v5&;qc5&;qc5&;r{Rg8cW&k1p-zs-9aNv3b+ZAK#L z)`Wo6+@^~IcMW6W)qig3^f}fNvS4$p;$28CeU1n`ohEY}V6nOz5&%riVQxQDV=Tco zab~`9@F4&&tx$FhKAf7mkU}Ex8W9iz1UUS_sR1Au_&|P+J7fcS*#p3a0Z$w0!GO(n zb7N1D7Fa*Mmd(y=_5uPv1w1PNpv4NI2txtzvqpdb2x!@B5I|*8Z8BkMZ?AJYF2OUF zG-;s_c+qdmu%PY(xbKfbrCEOrQYYR6FRmSf-^`Z!`gnW2&Y<_)>3wy2 z@0>Vg=bp^$efi49ma}agotOLi2ZwHdaqpXlb8j&4cp)%icgyjsEoI(HCf)mZuHE}O$(Wf^LY&p0V9E3e_q`7X^h?boyAR~9Oht6_{W z5I59~>n3J^*s)kdjEcEpaV!WO3q=H|fGZG(F4+6^6Lz3v5c$<(2 zdipthn?43{pCi)c@`^K8?tQS?-1{3e3I!7HD;nuI_ntYI^aqMA z9Ea)g?JDtI_#0Uirz!0t8;L~gYN2-CvSYVpk@XCM(E5m=E3OmgRE z;@95|`oWG+OvhMYHow@o2E_#fg@`k*7JpYQ+dvEcceB+mk zDJ9)y#zge(fVM?lrbv?netTW3QdcRmBz)~P^%+HxB#!T`9nf?t6_|wYhX23VtvkMc z04g-A<%(Sr?r6W}w6Xw8mGCu#>JAK(B=P;VpR1b`GD$R_g)7`1@%06|ZkQrXkv4im z)25VTJ0zPmHzqO8Is5`jjmRAHr} zZGO(W8Q#M(^d@OXph=_GH7fNHr3~Aqy`s6Ou7k=+nw!d2tV|^GbJY&1Khl}xj+=Dn zt{(@$rM7EMspZOSXp&leOj)FmXs)Q+F_|ceA2@nbb5U7|?dH4a6*xZl8k*FHm3fLJ z*mz!9fu%?Sp&_jbxg?R#8NH@Cr!2;jMP9hV7b6^q(p7D%x?w*6S4R!8Oc9mf)j4X_7fRkVJ_@X%+-l!l5zC(#Yyni@@1|Lzg03 z0%~2$E@*zMiaq69wf<1)nYg2zB9~m-xI3NuPi|Fs9&nOe7%06I-5gl!Dj(?2Qzx8$ z^LMTVr#jLaf)BGWyQHtW4>k#Fyk+aNl>NKf`KR5h=vZxcRvYg)DyQcTT`oE!{D4zT z-*vY~+8kNqdC)nls(07>Ym@0pnW9t3S66*ac*XP;q?(RR(5!d8(n2~q3=g|4cI-d$g&ZSmq zZG?Q|0f)q{%LV7ck9rm}vd(qqv_{o?l+d$Ux}@g>$306NGEX+_em@jrXV8TMJtb{P zC;iHu_pjOmhg>*`zzRU%RlmeRcmQ?j40ud_iNo953;y6&I9Q$@9&C>^uw=f(F`XAr zQ17i5%x^z^4uX2WcERSD0e-TIL|{e)ox;pSUu=wKPX` S+N+$ubtLzGvG1Cu$NxVG<{kV1 literal 0 HcmV?d00001 diff --git a/package/firmware/ipq-wifi/board-buffalo_wtr-m2133hp.qca9984 b/package/firmware/ipq-wifi/board-buffalo_wtr-m2133hp.qca9984 new file mode 100644 index 0000000000000000000000000000000000000000..656cb99cbb2b6de86639ae8dc8eee73c5c7cb490 GIT binary patch literal 12172 zcmeHMYfuwc6ut={h*+{oL=CvSb$k#Zp@14*ks_5_udf5lX@?4@DwWdTYFAyIniscvQ<%#zn3`Yg@ zbGN;V(mE0m-#j)dm`52i+B=W;y}`$>^TD}u^8sz_fR|_likKteh9X35lX#|^o12S^ z3xz^~wN(JXdcLf^~g`f-1y zvLqud4NHyzG@8elbIi)n;GiIX*!%03pPrA7E`plXMi`&}`h@E0`nScG0w6xiiudwz z9mD74WeBad7cYJvv(08BYm?Qr!GN-3b!|i;Vh7I=nT`hpMUX@^5s5$}5Lxk&W0fcB z&YYd90N$8%JEhQ3I-CB0j<8S`n}yL(8nOiCqkK010Uz0nZf0-B63_%B1?8X|Hs=8c zS&yz~ugAjCa3lsDpM?6-^y>JWc)amhk?NG^GZRV}DB~#u@kM>vzSu@|Boa^+F5fGP z9~soQs=k!(5v?Ntr-%^@Cbd>kCEX`TGTbLL@vf9ueV@9$v`U* zuhhxq$}1^?4kSw?OAZ(yUkwMuykvHorI*lThhzYp?91umU0&JbbG*{<$yIIxsz792 zCfSWGEvssMOIy1o*EgwGR4*yk4;;O-<(gk5B5%2Kpq*aM zaoe`$)zz$$#{S*k#p(QU`jPts{EI7apU=GW)!mZzC{=(0DZJ2?-x{g(FQer*4@>Vv zYXg)>>A=t??JDJxQrdof->&xP^Zr$gVp%)?TxjLuq6Nb0q4ciR%}Y-%EV?pu;C7V8 z{}fW(a4%K2s(wkC_r7m?cD6<~EIUdstmxU%5!%2!<|U~##%Y7SYFMP zdF|;p#We*h82i04Zw!}oZ@v~#OFw+ZnB20wmRaPLJ=C|MDX;>OdWu?ZORk33vJQKT zHN%JQ32ua6WR@!oyz>E-A4omZ+f0%UcKy<_g*j*LWq0tJS>+$>BVQqs0g{2a%Yd8v z`~?fW5yqm$OMREwt;~onv0nH$ai1*H(4Z;LN(dM_D&U}@p&{@L4hjqi4h#$m6uNoX za+K4+W@w^NUEHXE>f$=j-33CZ?(>LkHg|U_Y~0;lhz7jcXEA3n;!oei*@SGPM{}Z) zc)Ev8z>e(tOE-Hb*S4jL=)2}F)YB0QAG z=3$Yuw!WSi)fvr)GDowHrn(QooUe?~Zr literal 0 HcmV?d00001 diff --git a/target/linux/ipq40xx/base-files/etc/board.d/02_network b/target/linux/ipq40xx/base-files/etc/board.d/02_network index cd336a9e6a..61d02a17bc 100755 --- a/target/linux/ipq40xx/base-files/etc/board.d/02_network +++ b/target/linux/ipq40xx/base-files/etc/board.d/02_network @@ -65,6 +65,11 @@ ipq40xx_setup_interfaces() engenius,eap2200) ucidef_set_interface_lan "eth0 eth1" ;; + buffalo,wtr-m2133hp) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ucidef_add_switch "switch0" \ + "0u@eth0" "2:lan:3" "3:lan:2" "4:lan:1" + ;; cellc,rtl30vw) ucidef_set_interface_lan "eth0" ucidef_add_switch "switch0" \ diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index b95bab7cae..8df7990f2e 100644 --- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -31,6 +31,10 @@ case "$FIRMWARE" in /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \ /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x212 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") ;; + buffalo,wtr-m2133hp) + caldata_extract "ART" 0x9000 0x2f20 + ath10k_patch_mac $(mtd_get_mac_binary ORGDATA 0x32) + ;; engenius,eap2200 |\ openmesh,a62) caldata_extract "0:ART" 0x9000 0x2f20 @@ -82,6 +86,10 @@ case "$FIRMWARE" in /usr/bin/fritz_cal_extract -i 1 -s 0x3C800 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \ /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x207 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") ;; + buffalo,wtr-m2133hp) + caldata_extract "ART" 0x1000 0x2f20 + ath10k_patch_mac $(mtd_get_mac_binary ORGDATA 0x26) + ;; cellc,rtl30vw |\ compex,wpj419 |\ compex,wpj428 |\ @@ -171,6 +179,10 @@ case "$FIRMWARE" in /usr/bin/fritz_cal_extract -i 1 -s 0x3D000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") || \ /usr/bin/fritz_cal_extract -i 1 -s 0x3C000 -e 0x208 -l 12064 -o /lib/firmware/$FIRMWARE $(find_mtd_chardev "urlader1") ;; + buffalo,wtr-m2133hp) + caldata_extract "ART" 0x5000 0x2f20 + ath10k_patch_mac $(mtd_get_mac_binary ORGDATA 0x2c) + ;; cellc,rtl30vw |\ compex,wpj419 |\ compex,wpj428 |\ diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh index 2abff3bd00..5b89710a22 100644 --- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh @@ -64,6 +64,7 @@ platform_do_upgrade() { avm,fritzbox-7530 |\ avm,fritzrepeater-1200 |\ avm,fritzrepeater-3000 |\ + buffalo,wtr-m2133hp |\ cilab,meshpoint-one |\ engenius,eap2200 |\ mobipromo,cm520-79f |\ diff --git a/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wtr-m2133hp.dts b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wtr-m2133hp.dts new file mode 100644 index 0000000000..1977358525 --- /dev/null +++ b/target/linux/ipq40xx/files/arch/arm/boot/dts/qcom-ipq4019-wtr-m2133hp.dts @@ -0,0 +1,419 @@ +// SPDX-License-Identifier: ISC +/* + * Copyright (c) 2015 - 2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2020 Yanase Yuki + */ + +#include "qcom-ipq4019.dtsi" +#include +#include +#include + +/ { + model = "Buffalo WTR-M2133HP"; + compatible = "buffalo,wtr-m2133hp", "qcom,ipq4019"; + + memory { + device_type = "memory"; + reg = <0x80000000 0x20000000>; + }; + + chosen { + /* + * U-Boot adds "ubi.mtd=rootfs root=mtd:ubi_rootfs" to + * kernel command line. But we use different partition names, + * so we have to set correct parameters. + */ + bootargs-append = " ubi.mtd=ubi root=/dev/ubiblock0_1"; + }; + + aliases { + led-boot = &led_power_blue; + led-failsafe = &led_power_orange; + led-running = &led_power_white; + led-upgrade = &led_power_blue; + label-mac-device = &gmac0; + }; + + soc { + rng@22000 { + status = "okay"; + }; + + tcsr@1949000 { + compatible = "qcom,tcsr"; + reg = <0x1949000 0x100>; + qcom,wifi_glb_cfg = ; + }; + + tcsr@194b000 { + compatible = "qcom,tcsr"; + reg = <0x194b000 0x100>; + qcom,usb-hsphy-mode-select = ; + status = "okay"; + }; + + ess_tcsr@1953000 { + compatible = "qcom,tcsr"; + reg = <0x1953000 0x1000>; + qcom,ess-interface-select = ; + }; + + tcsr@1957000 { + compatible = "qcom,tcsr"; + reg = <0x1957000 0x100>; + qcom,wifi_noc_memtype_m0_m2 = ; + }; + + crypto@8e3a000 { + status = "okay"; + }; + + watchdog@b017000 { + status = "okay"; + }; + + ess-switch@c000000 { + status = "okay"; + switch_lan_bmp = <0x1c>; + }; + + ess-psgmii@98000 { + status = "okay"; + }; + + edma@c080000 { + status = "okay"; + }; + + usb3@8af8800 { + status = "okay"; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power_white: power_white { + label = "wtr-m2133hp:white:power"; + gpios = <&tlmm 40 GPIO_ACTIVE_HIGH>; + }; + + led_power_orange: power_orange { + label = "wtr-m2133hp:orange:power"; + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + }; + + led_power_blue: power_blue { + label = "wtr-m2133hp:blue:power"; + gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>; + }; + + router_white { + label = "wtr-m2133hp:white:router"; + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + }; + + router_orange { + label = "wtr-m2133hp:orange:router"; + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + }; + + internet_white { + label = "wtr-m2133hp:white:internet"; + gpios = <&tlmm 27 GPIO_ACTIVE_HIGH>; + }; + + internet_orange { + label = "wtr-m2133hp:orange:internet"; + gpios = <&tlmm 45 GPIO_ACTIVE_HIGH>; + }; + + wireless_white { + label = "wtr-m2133hp:white:wireless"; + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + }; + + wireless_orange { + label = "wtr-m2133hp:orange:wireless"; + gpios = <&tlmm 44 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + auto_mode { + label = "auto_mode"; + gpios = <&tlmm 9 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + router_mode { + label = "router_mode"; + gpios = <&tlmm 10 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + ap_mode { + label = "ap_mode"; + gpios = <&tlmm 11 GPIO_ACTIVE_LOW>; + linux,code = ; + linux,input-type = ; + }; + + reset { + label = "reset"; + gpios = <&tlmm 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "AOSS Button"; + gpios = <&tlmm 32 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&tlmm { + serial_0_pins: serial0_pinmux { + mux { + pins = "gpio16", "gpio17"; + function = "blsp_uart0"; + bias-disable; + }; + }; + + mdio_pins: mdio_pinmux { + mux_1 { + pins = "gpio6"; + function = "mdio"; + bias-pull-up; + }; + + mux_2 { + pins = "gpio7"; + function = "mdc"; + bias-pull-up; + }; + }; + + nand_pins: nand_pins { + pullups { + pins = "gpio52", "gpio53", "gpio58", + "gpio59"; + function = "qpic"; + bias-pull-up; + }; + + pulldowns { + pins = "gpio54", "gpio55", "gpio56", + "gpio57", "gpio60", "gpio61", + "gpio62", "gpio63", "gpio64", + "gpio65", "gpio66", "gpio67", + "gpio68", "gpio69"; + function = "qpic"; + bias-pull-down; + }; + }; + + usb_power { + line-name = "USB power"; + gpios = <34 GPIO_ACTIVE_HIGH>; + gpio-hog; + output-high; + }; +}; + +&blsp_dma { + status = "okay"; +}; + +&blsp1_uart1 { + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + + bridge@0,0 { + reg = <0x00000000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + wifi@0,0 { + compatible = "qcom,ath10k"; + reg = <0 0 0 0 0>; + + qcom,ath10k-calibration-variant = "Buffalo-WTR-M2133HP"; + }; + }; +}; + +&qpic_bam { + status = "okay"; +}; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + status = "okay"; + + nand@0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "SBL1"; + reg = <0x0000000 0x0100000>; + read-only; + }; + + partition@100000 { + label = "MIBIB"; + reg = <0x0100000 0x0100000>; + read-only; + }; + + partition@200000 { + label = "BOOTCONFIG"; + reg = <0x0200000 0x0100000>; + read-only; + }; + + partition@300000 { + label = "QSEE"; + reg = <0x0300000 0x0100000>; + read-only; + }; + + partition@400000 { + label = "QSEE_1"; + reg = <0x0400000 0x0100000>; + read-only; + }; + + partition@500000 { + label = "CDT"; + reg = <0x0500000 0x0080000>; + read-only; + }; + + partition@580000 { + label = "CDT_1"; + reg = <0x0580000 0x0080000>; + read-only; + }; + + partition@600000 { + label = "BOOTCONFIG1"; + reg = <0x0600000 0x0080000>; + read-only; + }; + + partition@680000 { + label = "APPSBLENV"; + reg = <0x0680000 0x0080000>; + }; + + partition@700000 { + label = "APPSBL"; + reg = <0x0700000 0x0200000>; + read-only; + }; + + partition@900000 { + label = "APPSBL_1"; + reg = <0x0900000 0x0200000>; + read-only; + }; + + art: partition@b00000 { + label = "ART"; + reg = <0x0b00000 0x0080000>; + read-only; + }; + + partition@b80000 { + label = "ART_1"; + reg = <0x0b80000 0x0080000>; + read-only; + }; + + orgdata: partition@c00000 { + label = "ORGDATA"; + reg = <0x0c00000 0x0080000>; + read-only; + }; + + partition@c80000 { + label = "ORGDATA_1"; + reg = <0x0c80000 0x0080000>; + read-only; + }; + + partition@d00000 { + label = "ubi"; + reg = <0x0d00000 0x2900000>; + }; + + partition@3600000 { + label = "rootfs_recover"; + reg = <0x3600000 0x2900000>; + read-only; + }; + + partition@5f00000 { + label = "user_property"; + reg = <0x5f00000 0x1a20000>; + read-only; + }; + }; + }; +}; + +&wifi0 { + status = "okay"; + qcom,ath10k-calibration-variant = "Buffalo-WTR-M2133HP"; + ieee80211-freq-limit = <2400000 2483000>; +}; + +&wifi1 { + status = "okay"; + qcom,ath10k-calibration-variant = "Buffalo-WTR-M2133HP"; +}; + +&mdio { + status = "okay"; + pinctrl-0 = <&mdio_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 47 GPIO_ACTIVE_LOW>; +}; + +&gmac0 { + mtd-mac-address = <&orgdata 0x20>; +}; + +&gmac1 { + mtd-mac-address = <&orgdata 0x20>; +}; + +&usb3_ss_phy { + status = "okay"; +}; + +&usb3_hs_phy { + status = "okay"; +}; diff --git a/target/linux/ipq40xx/image/Makefile b/target/linux/ipq40xx/image/Makefile index 5336649c3d..51e8bcc7e3 100644 --- a/target/linux/ipq40xx/image/Makefile +++ b/target/linux/ipq40xx/image/Makefile @@ -245,6 +245,18 @@ define Device/avm_fritzrepeater-3000 endef TARGET_DEVICES += avm_fritzrepeater-3000 +define Device/buffalo_wtr-m2133hp + $(call Device/FitImage) + $(call Device/UbiFit) + DEVICE_VENDOR := Buffalo + DEVICE_MODEL := WTR-M2133HP + SOC := qcom-ipq4019 + DEVICE_PACKAGES := uboot-envtools ath10k-firmware-qca9984-ct ipq-wifi-buffalo_wtr-m2133hp + BLOCKSIZE := 128k + PAGESIZE := 2048 +endef +TARGET_DEVICES += buffalo_wtr-m2133hp + define Device/cellc_rtl30vw KERNEL_SUFFIX := -fit-uImage.itb KERNEL_INITRAMFS = kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb diff --git a/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch index fb358ed184..924715c9aa 100644 --- a/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch @@ -49,6 +49,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-rtl30vw.dtb \ + qcom-ipq4019-u4019-32m.dtb \ + qcom-ipq4019-wpj419.dtb \ ++ qcom-ipq4019-wtr-m2133hp.dtb \ + qcom-ipq4028-wpj428.dtb \ + qcom-ipq4029-ap-303.dtb \ + qcom-ipq4029-ap-303h.dtb \ diff --git a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch index 2db36aa597..c5b0981f49 100644 --- a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch @@ -50,6 +50,7 @@ Signed-off-by: John Crispin + qcom-ipq4019-rtl30vw.dtb \ + qcom-ipq4019-u4019-32m.dtb \ + qcom-ipq4019-wpj419.dtb \ ++ qcom-ipq4019-wtr-m2133hp.dtb \ + qcom-ipq4028-wpj428.dtb \ + qcom-ipq4029-ap-303.dtb \ + qcom-ipq4029-ap-303h.dtb \ From d64b20da21d796334840fe9614bb0cb572e22fda Mon Sep 17 00:00:00 2001 From: Andrea Dalla Costa Date: Sat, 11 Jan 2020 22:57:58 +0100 Subject: [PATCH 29/55] firmware-utils/hcsmakeimage: fix possible memory leak and resource leaks Add missing calls to `free` for variable `filebuffer`. Add missing calls to `fclose` for variables `fd` and `fd_out`. Signed-off-by: Andrea Dalla Costa --- tools/firmware-utils/src/hcsmakeimage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/firmware-utils/src/hcsmakeimage.c b/tools/firmware-utils/src/hcsmakeimage.c index 7baa7b5845..2888810cc7 100644 --- a/tools/firmware-utils/src/hcsmakeimage.c +++ b/tools/firmware-utils/src/hcsmakeimage.c @@ -183,6 +183,7 @@ int main ( int argc, char** argv ) char* filebuffer = malloc ( buf.st_size+10 ); FILE* fd = fopen ( input,"r" ); fread ( filebuffer, 1, buf.st_size,fd ); + fclose (fd); if (!output) { output = malloc(strlen(input+5)); @@ -194,10 +195,13 @@ int main ( int argc, char** argv ) if (!fd_out) { fprintf(stderr, "Failed to open output file: %s\n", output); + free(filebuffer); exit(1); } fwrite ( head,1,sizeof ( ldr_header_t ),fd_out ); fwrite ( filebuffer,1,buf.st_size,fd_out ); printf("Firmware image %s is ready\n", output); + free(filebuffer); + fclose(fd_out); return 0; } From 20c7abd4b7b9b4203b6858136b2c811b6dbd8dae Mon Sep 17 00:00:00 2001 From: Pawel Dembicki Date: Tue, 26 May 2020 21:14:11 +0200 Subject: [PATCH 30/55] ipq806x: add support for Linksys EA7500 V1 This patch adds support for the Linksys EA7500 V1 router. Specification: - CPU: Qualcomm IPQ8064 - RAM: 256MB - Flash: NAND 128MB - WiFi: QCA9982 an+ac + QCA9983 bgn - Ethernet: 5 GBE Ports (WAN+ 4xLAN) (QCA8337) - USB: 1x USB 3.0 1x USB2.0 - Serial console: RJ-45 115200 8n1 (1V8 Voltage level) - 2 Buttons - 1 LED Known issues: - Some devices won't flash via web gui Installation: - Newer stock images doesn't allow to install custom firmware. - Please downgrade software to 1.1.2 version. Official firmware: https://downloads.linksys.com/downloads/firmware/FW_EA7500_1.1.2.172843_prod.gpg.img - Do it two times to downgrade all stored images. - Apply factory image via web-gui. Serial + TFTP method: - downgrade to 1.1.2 two times - connect ehternet and serial cable - set ip address of tftp server to 192.168.1.254 - put openwrt factory image to tftp folder and rename it to macan.bin - stop device while booting in u-boot - run command: "run flashimg" - run command: "setenv boot_part 1" - run command "saveenv" - reset Back to stock: - Please use old non-gpg image like this 1.1.2: https://downloads.linksys.com/downloads/firmware/FW_EA7500_1.1.2.172843_prod.img - ssh to router and copy image to tmp - use sysupgrade -n -F Tested by github users: @jack338c and @grzesiczek1 Signed-off-by: Pawel Dembicki [removed i2c4_pins, mdio0_pins, nand_pins, rgmii2_pins from DTSI] Signed-off-by: Adrian Schmutzler --- package/boot/uboot-envtools/files/ipq806x | 1 + .../ipq806x/base-files/etc/board.d/02_network | 7 + .../etc/hotplug.d/firmware/11-ath10k-caldata | 2 + .../ipq806x/base-files/etc/init.d/bootcount | 1 + .../base-files/lib/upgrade/platform.sh | 1 + .../arm/boot/dts/qcom-ipq8064-ea7500-v1.dts | 302 ++++++++++++++++++ target/linux/ipq806x/image/Makefile | 17 + ...Mangle-bootloader-s-kernel-arguments.patch | 63 ++-- .../0069-arm-boot-add-dts-files.patch | 3 +- 9 files changed, 375 insertions(+), 22 deletions(-) create mode 100644 target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-ea7500-v1.dts diff --git a/package/boot/uboot-envtools/files/ipq806x b/package/boot/uboot-envtools/files/ipq806x index c27bea71c1..e2f2e611cd 100644 --- a/package/boot/uboot-envtools/files/ipq806x +++ b/package/boot/uboot-envtools/files/ipq806x @@ -31,6 +31,7 @@ ubootenv_mtdinfo () { } case "$board" in +linksys,ea7500-v1 |\ linksys,ea8500) ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000" ;; diff --git a/target/linux/ipq806x/base-files/etc/board.d/02_network b/target/linux/ipq806x/base-files/etc/board.d/02_network index a3aa0fce70..65946d7ac5 100755 --- a/target/linux/ipq806x/base-files/etc/board.d/02_network +++ b/target/linux/ipq806x/base-files/etc/board.d/02_network @@ -27,6 +27,13 @@ qcom,ipq8064-ap161) ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3u@eth1" "6:wan" "4u@eth0" ;; +linksys,ea7500-v1) + hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) + ucidef_add_switch "switch0" \ + "2:lan:1" "3:lan:2" "4:lan:3" "5:lan:4" "6@eth1" "1:wan" "0@eth0" + ucidef_set_interface_macaddr "lan" "$hw_mac_addr" + ucidef_set_interface_macaddr "wan" "$hw_mac_addr" + ;; linksys,ea8500) hw_mac_addr=$(mtd_get_mac_ascii devinfo hw_mac_addr) ucidef_add_switch "switch0" \ diff --git a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata index bb505d642f..8b4942dee1 100644 --- a/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata +++ b/target/linux/ipq806x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -13,6 +13,7 @@ case "$FIRMWARE" in caldata_extract "ART" 0x1000 0x2f20 ath10k_patch_mac $(mtd_get_mac_binary ART 0x1e) ;; + linksys,ea7500-v1 |\ linksys,ea8500) caldata_extract "art" 0x1000 0x2f20 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +1) @@ -47,6 +48,7 @@ case "$FIRMWARE" in caldata_extract "ART" 0x5000 0x2f20 ath10k_patch_mac $(mtd_get_mac_binary ART 0x18) ;; + linksys,ea7500-v1 |\ linksys,ea8500) caldata_extract "art" 0x5000 0x2f20 ath10k_patch_mac $(macaddr_add $(mtd_get_mac_ascii devinfo hw_mac_addr) +2) diff --git a/target/linux/ipq806x/base-files/etc/init.d/bootcount b/target/linux/ipq806x/base-files/etc/init.d/bootcount index d0bf708e66..6e57c72e51 100755 --- a/target/linux/ipq806x/base-files/etc/init.d/bootcount +++ b/target/linux/ipq806x/base-files/etc/init.d/bootcount @@ -4,6 +4,7 @@ START=99 boot() { case $(board_name) in + linksys,ea7500-v1 |\ linksys,ea8500) mtd resetbc s_env || true ;; diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh index 2be25f4a9c..560e64af3a 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh @@ -27,6 +27,7 @@ platform_do_upgrade() { zyxel,nbg6817) zyxel_do_upgrade "$1" ;; + linksys,ea7500-v1 |\ linksys,ea8500) platform_do_upgrade_linksys "$1" ;; diff --git a/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-ea7500-v1.dts b/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-ea7500-v1.dts new file mode 100644 index 0000000000..6454fae7f7 --- /dev/null +++ b/target/linux/ipq806x/files-5.4/arch/arm/boot/dts/qcom-ipq8064-ea7500-v1.dts @@ -0,0 +1,302 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +#include "qcom-ipq8064-v2.0.dtsi" + +#include + +/ { + model = "Linksys EA7500 V1 WiFi Router"; + compatible = "linksys,ea7500-v1", "qcom,ipq8064"; + + memory@0 { + reg = <0x42000000 0xe000000>; + device_type = "memory"; + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + rsvd@41200000 { + reg = <0x41200000 0x300000>; + no-map; + }; + }; + + aliases { + serial0 = &gsbi4_serial; + + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + chosen { + bootargs = "console=ttyMSM0,115200n8"; + stdout-path = "serial0:115200n8"; + append-rootblock = "ubi.mtd="; /* append to bootargs adding the root deviceblock nbr from bootloader */ + find-rootblock = "ubi.mtd="; /* look for root deviceblock nbr in this bootarg */ + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + reset { + label = "reset"; + gpios = <&qcom_pinmux 68 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps { + label = "wps"; + gpios = <&qcom_pinmux 65 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led_power: power { + label = "ea7500-v1:white:power"; + gpios = <&qcom_pinmux 6 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + }; +}; + +&qcom_pinmux { + button_pins: button_pins { + mux { + pins = "gpio65", "gpio68"; + function = "gpio"; + drive-strength = <2>; + bias-pull-up; + }; + }; + + led_pins: led_pins { + mux { + pins = "gpio6"; + function = "gpio"; + drive-strength = <2>; + bias-pull-up; + }; + }; +}; + +&gsbi4 { + qcom,mode = ; + status = "okay"; + serial@16340000 { + status = "okay"; + }; + /* + * The i2c device on gsbi4 should not be enabled. + * On ipq806x designs gsbi4 i2c is meant for exclusive + * RPM usage. Turning this on in kernel manifests as + * i2c failure for the RPM. + */ +}; + +&usb3_0 { + status = "okay"; +}; + +&usb3_1 { + status = "okay"; +}; + +&pcie0 { + status = "okay"; + force_gen1 = <1>; +}; + +&pcie1 { + status = "okay"; +}; + +&pcie2 { + status = "okay"; +}; + +&nand_controller { + status = "okay"; + + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + + nand@0 { + reg = <0>; + compatible = "qcom,nandcs"; + + nand-ecc-strength = <4>; + nand-bus-width = <8>; + nand-ecc-step-size = <512>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "SBL1"; + reg = <0x0000000 0x0040000>; + read-only; + }; + + partition@40000 { + label = "MIBIB"; + reg = <0x0040000 0x0140000>; + read-only; + }; + + partition@180000 { + label = "SBL2"; + reg = <0x0180000 0x0140000>; + read-only; + }; + + partition@2c0000 { + label = "SBL3"; + reg = <0x02c0000 0x0280000>; + read-only; + }; + + partition@540000 { + label = "DDRCONFIG"; + reg = <0x0540000 0x0120000>; + read-only; + }; + + partition@660000 { + label = "SSD"; + reg = <0x0660000 0x0120000>; + read-only; + }; + + partition@780000 { + label = "TZ"; + reg = <0x0780000 0x0280000>; + read-only; + }; + + partition@a00000 { + label = "RPM"; + reg = <0x0a00000 0x0280000>; + read-only; + }; + + art: partition@c80000 { + label = "art"; + reg = <0x0c80000 0x0140000>; + read-only; + }; + + partition@dc0000 { + label = "APPSBL"; + reg = <0x0dc0000 0x0100000>; + read-only; + }; + + partition@ec0000 { + label = "u_env"; + reg = <0x0ec0000 0x0040000>; + }; + + partition@f00000 { + label = "s_env"; + reg = <0x0f00000 0x0040000>; + }; + + partition@f40000 { + label = "devinfo"; + reg = <0x0f40000 0x0040000>; + }; + + partition@f80000 { + label = "kernel1"; + reg = <0x0f80000 0x2800000>; /* 3 MB spill to rootfs*/ + }; + + partition@1280000 { + label = "rootfs1"; + reg = <0x1280000 0x2500000>; + }; + + partition@3780000 { + label = "kernel2"; + reg = <0x3780000 0x2800000>; + }; + + partition@3a80000 { + label = "rootfs2"; + reg = <0x3a80000 0x2500000>; + }; + + partition@5f80000 { + label = "sysdiag"; + reg = <0x5f80000 0x100000>; + }; + + partition@6080000 { + label = "syscfg"; + reg = <0x6080000 0x1f80000>; + }; + }; + }; +}; + +&mdio0 { + status = "okay"; + + pinctrl-0 = <&mdio0_pins>; + pinctrl-names = "default"; + + phy0: ethernet-phy@0 { + reg = <0>; + qca,ar8327-initvals = < + 0x00004 0x7600000 /* PAD0_MODE */ + 0x00008 0x1000000 /* PAD5_MODE */ + 0x0000c 0x80 /* PAD6_MODE */ + 0x00010 0x2613a0 /* PWS_REG */ + 0x000e4 0x6a545 /* MAC_POWER_SEL */ + 0x000e0 0xc74164de /* SGMII_CTRL */ + 0x0007c 0x4e /* PORT0_STATUS */ + 0x00094 0x4e /* PORT6_STATUS */ + >; + }; +}; + +&gmac1 { + status = "okay"; + phy-mode = "rgmii"; + qcom,id = <1>; + + pinctrl-0 = <&rgmii2_pins>; + pinctrl-names = "default"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&gmac2 { + status = "okay"; + phy-mode = "sgmii"; + qcom,id = <2>; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&adm_dma { + status = "okay"; +}; diff --git a/target/linux/ipq806x/image/Makefile b/target/linux/ipq806x/image/Makefile index 578303e9e0..5cc66daa21 100644 --- a/target/linux/ipq806x/image/Makefile +++ b/target/linux/ipq806x/image/Makefile @@ -109,6 +109,23 @@ define Device/compex_wpq864 endef TARGET_DEVICES += compex_wpq864 +define Device/linksys_ea7500-v1 + $(call Device/LegacyImage) + DEVICE_VENDOR := Linksys + DEVICE_MODEL := EA7500 + DEVICE_VARIANT := v1 + SOC := qcom-ipq8064 + PAGESIZE := 2048 + BLOCKSIZE := 128k + KERNEL_SIZE := 3072k + KERNEL = kernel-bin | append-dtb | uImage none | append-uImage-fakehdr filesystem + UBINIZE_OPTS := -E 5 + IMAGES := factory.bin sysupgrade.bin + IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | pad-to $$$$(PAGESIZE) + DEVICE_PACKAGES := ath10k-firmware-qca99x0-ct +endef +TARGET_DEVICES += linksys_ea7500-v1 + define Device/linksys_ea8500 $(call Device/LegacyImage) DEVICE_VENDOR := Linksys diff --git a/target/linux/ipq806x/patches-5.4/0067-generic-Mangle-bootloader-s-kernel-arguments.patch b/target/linux/ipq806x/patches-5.4/0067-generic-Mangle-bootloader-s-kernel-arguments.patch index 396309d203..99a64ccadc 100644 --- a/target/linux/ipq806x/patches-5.4/0067-generic-Mangle-bootloader-s-kernel-arguments.patch +++ b/target/linux/ipq806x/patches-5.4/0067-generic-Mangle-bootloader-s-kernel-arguments.patch @@ -51,41 +51,62 @@ Signed-off-by: Adrian Panella #else #define do_extend_cmdline 0 #endif -@@ -67,6 +69,59 @@ static uint32_t get_cell_size(const void +@@ -67,6 +69,80 @@ static uint32_t get_cell_size(const void return cell_size; } +#if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_MANGLE) ++/** ++ * taken from arch/x86/boot/string.c ++ * local_strstr - Find the first substring in a %NUL terminated string ++ * @s1: The string to be searched ++ * @s2: The string to search for ++ */ ++static char *local_strstr(const char *s1, const char *s2) ++{ ++ size_t l1, l2; ++ ++ l2 = strlen(s2); ++ if (!l2) ++ return (char *)s1; ++ l1 = strlen(s1); ++ while (l1 >= l2) { ++ l1--; ++ if (!memcmp(s1, s2, l2)) ++ return (char *)s1; ++ s1++; ++ } ++ return NULL; ++} + +static char *append_rootblock(char *dest, const char *str, int len, void *fdt) +{ -+ char *ptr, *end; ++ char *ptr, *end, *tmp; + char *root="root="; ++ char *find_rootblock; + int i, l; + const char *rootblock; + -+ //ARM doesn't have __HAVE_ARCH_STRSTR, so search manually -+ ptr = str - 1; ++ find_rootblock = getprop(fdt, "/chosen", "find-rootblock", &l); ++ if(!find_rootblock) ++ find_rootblock = root; + -+ do { -+ //first find an 'r' at the begining or after a space -+ do { -+ ptr++; -+ ptr = strchr(ptr, 'r'); -+ if(!ptr) return dest; ++ //ARM doesn't have __HAVE_ARCH_STRSTR, so it was copied from x86 ++ ptr = local_strstr(str, find_rootblock); + -+ } while (ptr != str && *(ptr-1) != ' '); -+ -+ //then check for the rest -+ for(i = 1; i <= 4; i++) -+ if(*(ptr+i) != *(root+i)) break; -+ -+ } while (i != 5); ++ if(!ptr) ++ return dest; + + end = strchr(ptr, ' '); + end = end ? (end - 1) : (strchr(ptr, 0) - 1); + -+ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX ) ++ // Some boards ubi.mtd=XX,ZZZZ, so let's check for '," too. ++ tmp = strchr(ptr, ','); ++ ++ if(tmp) ++ end = end < tmp ? end : tmp - 1; ++ ++ //find partition number (assumes format root=/dev/mtdXX | /dev/mtdblockXX | yy:XX | ubi.mtd=XX,ZZZZ ) + for( i = 0; end >= ptr && *end >= '0' && *end <= '9'; end--, i++); + ptr = end + 1; + @@ -111,7 +132,7 @@ Signed-off-by: Adrian Panella static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) { char cmdline[COMMAND_LINE_SIZE]; -@@ -86,12 +141,21 @@ static void merge_fdt_bootargs(void *fdt +@@ -86,12 +162,21 @@ static void merge_fdt_bootargs(void *fdt /* and append the ATAG_CMDLINE */ if (fdt_cmdline) { @@ -133,7 +154,7 @@ Signed-off-by: Adrian Panella } *ptr = '\0'; -@@ -166,7 +230,9 @@ int atags_to_fdt(void *atag_list, void * +@@ -166,7 +251,9 @@ int atags_to_fdt(void *atag_list, void * else setprop_string(fdt, "/chosen", "bootargs", atag->u.cmdline.cmdline); @@ -144,7 +165,7 @@ Signed-off-by: Adrian Panella if (memcount >= sizeof(mem_reg_property)/4) continue; if (!atag->u.mem.size) -@@ -210,6 +276,10 @@ int atags_to_fdt(void *atag_list, void * +@@ -210,6 +297,10 @@ int atags_to_fdt(void *atag_list, void * setprop(fdt, "/memory", "reg", mem_reg_property, 4 * memcount * memsize); } diff --git a/target/linux/ipq806x/patches-5.4/0069-arm-boot-add-dts-files.patch b/target/linux/ipq806x/patches-5.4/0069-arm-boot-add-dts-files.patch index 1d21703bdd..8cdd198c29 100644 --- a/target/linux/ipq806x/patches-5.4/0069-arm-boot-add-dts-files.patch +++ b/target/linux/ipq806x/patches-5.4/0069-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -843,6 +843,18 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -843,6 +843,19 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-ipq4019-ap.dk07.1-c1.dtb \ qcom-ipq4019-ap.dk07.1-c2.dtb \ qcom-ipq8064-ap148.dtb \ @@ -18,6 +18,7 @@ Signed-off-by: John Crispin + qcom-ipq8064-d7800.dtb \ + qcom-ipq8064-db149.dtb \ + qcom-ipq8064-ap161.dtb \ ++ qcom-ipq8064-ea7500-v1.dtb \ + qcom-ipq8064-ea8500.dtb \ + qcom-ipq8064-r7500.dtb \ + qcom-ipq8064-r7500v2.dtb \ From d512657195de2f8062fc2354af1c3d96bf378d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Sun, 5 Apr 2020 16:17:11 +0200 Subject: [PATCH 31/55] mt7621-qtn-rgmii: enable RGMII connected Quantenna QV840 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Write a magic value to a magic destination. This might be specific to the Mitrastar designed ZyXEL WAP6805. Signed-off-by: Bjørn Mork --- package/kernel/mt7621-qtn-rgmii/Makefile | 45 +++++++++++++++++ package/kernel/mt7621-qtn-rgmii/src/Makefile | 1 + .../mt7621-qtn-rgmii/src/mt7621-qtn-rgmii.c | 48 +++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 package/kernel/mt7621-qtn-rgmii/Makefile create mode 100644 package/kernel/mt7621-qtn-rgmii/src/Makefile create mode 100644 package/kernel/mt7621-qtn-rgmii/src/mt7621-qtn-rgmii.c diff --git a/package/kernel/mt7621-qtn-rgmii/Makefile b/package/kernel/mt7621-qtn-rgmii/Makefile new file mode 100644 index 0000000000..f5587f5363 --- /dev/null +++ b/package/kernel/mt7621-qtn-rgmii/Makefile @@ -0,0 +1,45 @@ +# +# Copyright (C) 2020 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=mt7621-qtn-rgmii +PKG_RELEASE:=1 +PKG_LICENSE:=GPL-2.0 + +PKG_MAINTAINER:=Bjørn Mork + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/mt7621-qtn-rgmii + SECTION:=kernel + SUBMENU:=Other modules + TITLE:=Enable RGMII connected Quantenna module on MT7621 + DEPENDS:=@TARGET_ramips_mt7621 + HIDDEN:=1 + FILES:=$(PKG_BUILD_DIR)/mt7621-qtn-rgmii.ko + AUTOLOAD:=$(call AutoLoad,30,mt7621-qtn-rgmii,1) +endef + +define KernelPackage/mt7621-qtn-rgmii/description + Enable RGMII connected Quantenna module on MT7621. + + The Mitrastar designed ZyXEL WAP6805 has a Quantenna QV840 + module connected to the RGMII pins of the MT7621 SoC. For + unknown reasons, it is necessary to change the value of + the register at 0x1e110008 from default (usually 0xc000c) + to 0x9000c for this connection wo work. + + This driver simply does that without much fuzz. +endef + +define Build/Compile + $(KERNEL_MAKE) M=$(PKG_BUILD_DIR) modules +endef + +$(eval $(call KernelPackage,mt7621-qtn-rgmii)) diff --git a/package/kernel/mt7621-qtn-rgmii/src/Makefile b/package/kernel/mt7621-qtn-rgmii/src/Makefile new file mode 100644 index 0000000000..c993ac45bd --- /dev/null +++ b/package/kernel/mt7621-qtn-rgmii/src/Makefile @@ -0,0 +1 @@ +obj-m += mt7621-qtn-rgmii.o diff --git a/package/kernel/mt7621-qtn-rgmii/src/mt7621-qtn-rgmii.c b/package/kernel/mt7621-qtn-rgmii/src/mt7621-qtn-rgmii.c new file mode 100644 index 0000000000..5f223b5d75 --- /dev/null +++ b/package/kernel/mt7621-qtn-rgmii/src/mt7621-qtn-rgmii.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2020 Bjørn Mork + */ +#include +#include + +#define MODULE_NAME "mt7621-qtn-rgmii" +#define RGMII_REG_BASE 0x1e110008 +#define RGMII_REG_SIZE 4 +#define RGMII_REG_VALUE 0x9000c + +static u32 oldval; + +static int __init mt7621_qtn_rgmii_init(void) +{ + void __iomem *base = ioremap(RGMII_REG_BASE, RGMII_REG_SIZE); + + if (!base) + return -ENOMEM; + oldval = ioread32(base); + if (oldval != RGMII_REG_VALUE) { + iowrite32(RGMII_REG_VALUE, base); + pr_info(MODULE_NAME ": changed register 0x%08x value from 0x%08x to 0x%08x\n", RGMII_REG_BASE, oldval, RGMII_REG_VALUE); + } + iounmap(base); + return 0; +} + +static void __exit mt7621_qtn_rgmii_exit(void) +{ + void __iomem *base = ioremap(RGMII_REG_BASE, RGMII_REG_SIZE); + + if (!base) + return; + if (oldval != RGMII_REG_VALUE) { + iowrite32(oldval, base); + pr_info(MODULE_NAME ": reset register 0x%08x back to 0x%08x\n", RGMII_REG_BASE, oldval); + } + iounmap(base); +} + +module_init(mt7621_qtn_rgmii_init); +module_exit(mt7621_qtn_rgmii_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Bjørn Mork "); +MODULE_DESCRIPTION("Enable RGMII connected Quantenna module on MT7621"); From c1794d653c89b33f85b68aaa655a736202925155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Wed, 18 Apr 2018 21:57:52 +0200 Subject: [PATCH 32/55] ramips: add support for ZyXEL WAP6805 (Altibox WiFi+) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hardware -------- SoC: MediaTek MT7621ST WiFi: MediaTek MT7603 Quantenna QT3840BC Flash: 128M NAND RAM: 64M LED: Dual colour red and green BTN: Reset WPS Eth: 4 x 10/100/1000 connected to MT7621 internal switch MT7621 RGMII port connected to Quantenna module GPIO: Power/reset of Quantenna module Quantenna module ---------------- The Quantenna QT3840BC (or QV840) is a separate SoC running another Linux installation. It is mounted on a wide mini-PCIe form factor module, but is connected to the RGMII port of the MT7621. It loads both a second uboot stage and an os image from the MT7621 using tftp. The module is configured using Quantenna specific RPC calls over IP, using 802.1q over the RGMII link to support multiple SSIDs. There is no support for using this module as a WiFi device in OpenWrt. A package with basic firmware and management tools is being prepared. Serial ports ------------ Two serial ports with headers: RRJ1 - 115200 8N1 - Connected to the Quantenna console J1 - 57600 8N1 - Connected to the MT7621 console Both share pinout with many other Zyxel/Mitrastar devices: 1 - NC (VDD) 2 - TX 3 - RX 4 - NC (no pin) 5 - GND Dual system partitions ---------------------- The vendor firmware and boot loader use a dual partition scheme storing a counter in the header of each partition. The partition with the highest number will be selected for boot. OpenWrt does not support this scheme and will always use the first OS partition. It will reset both counters to zero the first time sysupgrade is run, making sure the first partition is selected by the boot loader. Installation from vendor firmware --------------------------------- 1. Run a DHCP server. The WAP6805 is configured as a client device and does not have a default static IP address. Make a note of which address it is assigned 2. tftp the OpenWrt initramfs-kernel.bin image to this address. Wait for the WAP6805 to reboot. 3. ssh to the OpenWrt initramfs system on 192.168.1.1. Make a backup of all mtd partitions now. The last used OEM image is still present in either "Kernel" or "Kernel2" at this point, and can be restored later if you save a copy. 4. sysupgrade to the OpenWrt sysupgrade.bin image. Installation from U-Boot ------------------------ This requires serial console access 1. Copy the OpenWrt initramfs-kernel.bin image as "ras.bin" to your tftp server directory. Configure the server address as 192.168.0.33/24 2. Hit ESC when the message "Hit ESC key to stop autoboot" appears 3. Type "ATGU" + Enter, and then "2" immediately after pressing enter. 4. Answer Y to the question "Erase Linux in Flash then burn new one. Are you sure?", and answer the address/filename questions. Defaults: Input device IP (192.168.0.2) Input server IP (192.168.0.33) Input Linux Kernel filename ("ras.bin") 5. Wait until after you see the message "Done!" and power cycle the device. It will hang after flashing. 6. Continue with step 3 and 4 from the vendor firmware procedure. Notes on the WAP6805 U-Boot --------------------------- The bootloader has been modified with both ZyXELs zyloader and the device specific dual partition scheme. These changes appear to have broken a few things. The zyloader shell claims to support a number of ZyXEL AT commands, but not all of them work. The image selection scheme is unreliable and inconsistent. A limited U-Boot menu is available - and used by the above U-Boot install procedure. But direct booting into an uploaded image does not work, neither with ram nor with flash. Flashing works, but requires a hard reset after it is finished. Reverting to OEM firmware ------------------------- The OEM firmware can be restored by using mtd write from OpenWrt, flashing it to the "Kernel" partition. E.g. ssh root@192.168.1.1 "mtd -r -e Kernel write - Kernel" < oem.bin OEM firmwares for the WAP6805 are not avaible for public download, so a backup of the original installation is required. See above. Alternatively, firmware for the WAP6806 (Armor X1) may be used. This is exactly the same hardware. But the branding features do obviously differ. LED controller -------------- Hardware implementation is unknown. The dual-color LED is controlled by 3 GPIOs: 4: red 7: blinking green 13: green Enabling both red and green makes the LED appear yellow. The boot loader enables hardware blinking, causing the green LED to blink slowly on power-on, until the OpenWrt boot mode starts a faster software blink. Signed-off-by: Bjørn Mork [fix alphabetic sorting for image build statement] Signed-off-by: Petr Štetiar --- .../linux/ramips/dts/mt7621_zyxel_wap6805.dts | 178 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 19 ++ .../mt7621/base-files/etc/board.d/02_network | 4 + .../base-files/etc/board.d/03_gpio_switches | 3 + .../mt7621/base-files/lib/upgrade/platform.sh | 9 + 5 files changed, 213 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_zyxel_wap6805.dts diff --git a/target/linux/ramips/dts/mt7621_zyxel_wap6805.dts b/target/linux/ramips/dts/mt7621_zyxel_wap6805.dts new file mode 100644 index 0000000000..8152ca11f8 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_zyxel_wap6805.dts @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "zyxel,wap6805", "mediatek,mt7621-soc"; + model = "ZyXEL WAP6805"; + + aliases { + led-boot = &led_status_green; + led-failsafe = &led_status_red; + led-running = &led_status_green; + led-upgrade = &led_status_green; + label-mac-device = &gmac0; + }; + + chosen { + bootargs = "console=ttyS0,57600"; + }; + + leds { + compatible = "gpio-leds"; + + led_status_red: status_red { + label = "wap6805:red:status"; + gpios = <&gpio 4 GPIO_ACTIVE_HIGH>; + }; + + status_blink { + label = "wap6805:blink:status"; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + }; + + led_status_green: status_green { + label = "wap6805:green:status"; + gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "MRD"; + reg = <0x100000 0x100000>; + read-only; + }; + + factory: partition@200000 { + label = "Factory"; + reg = <0x200000 0x100000>; + read-only; + }; + + partition@300000 { + label = "Config"; + reg = <0x300000 0x100000>; + }; + + partition@400000 { + label = "Kernel"; + reg = <0x400000 0x2000000>; + }; + + partition@800000 { + label = "ubi"; + reg = <0x800000 0x1c00000>; + }; + + partition@2400000 { + label = "Kernel2"; + reg = <0x2400000 0x2000000>; + }; + + partition@4400000 { + label = "Private"; + reg = <0x4400000 0x100000>; + }; + + partition@4500000 { + label = "Log"; + reg = <0x4500000 0x1000000>; + }; + + partition@5500000 { + label = "App"; + reg = <0x5500000 0x2b00000>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + mt76@0,0 { + reg = <0x0000 0 0 0 0>; + mediatek,mtd-eeprom = <&factory 0x0>; + }; +}; + +&gmac0 { + mtd-mac-address = <&factory 0xe000>; +}; + +&gmac1 { + status = "okay"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&switch0 { + ports { + port@0 { + status = "okay"; + label = "lan4"; + }; + port@1 { + status = "okay"; + label = "lan3"; + }; + port@2 { + status = "okay"; + label = "lan2"; + }; + port@3 { + status = "okay"; + label = "lan1"; + }; + }; +}; + +&xhci { + status = "disabled"; +}; + +&state_default { + gpio { + groups = "i2c", "uart3", "jtag", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 9103fd6762..ad61440c4c 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -81,6 +81,11 @@ define Build/iodata-mstc-header ) endef +define Build/mitrastarimage + uimage_padhdr -l 160 -i $@ -o $@.new + mv $@.new $@ +endef + define Build/ubnt-erx-factory-image if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \ echo '21001:7' > $(1).compat; \ @@ -1129,3 +1134,17 @@ define Device/zio_freezio kmod-usb-ledtrig-usbport wpad-basic endef TARGET_DEVICES += zio_freezio + +define Device/zyxel_wap6805 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL_SIZE := 4096k + UBINIZE_OPTS := -E 5 + IMAGE_SIZE := 32448k + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := WAP6805 + DEVICE_PACKAGES := kmod-mt7603 wpad-basic kmod-mt7621-qtn-rgmii + KERNEL := $(KERNEL_DTB) | uImage lzma | mitrastarimage + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata +endef +TARGET_DEVICES += zyxel_wap6805 diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index 4b65dd2364..ec05def88f 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -53,6 +53,10 @@ ramips_setup_interfaces() ubnt,edgerouter-x-sfp) ucidef_set_interface_lan_wan "eth1 eth2 eth3 eth4 eth5" "eth0" ;; + zyxel,wap6805) + ucidef_set_interface_lan "lan1 lan2 lan3 lan4" + ucidef_set_interface "qtn" ifname "eth1" protocol "static" ipaddr "1.1.1.1" netmask "255.255.255.0" + ;; *) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" ;; diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches index 24bfcb2051..e24e04f1d8 100755 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/03_gpio_switches @@ -23,6 +23,9 @@ ubnt,edgerouter-x-sfp) ucidef_add_gpio_switch "poe_power_port3" "PoE Power Port3" "403" ucidef_add_gpio_switch "poe_power_port4" "PoE Power Port4" "404" ;; +zyxel,wap6805) + ucidef_add_gpio_switch "qtn_power" "Quantenna Module Power" "496" "1" + ;; esac board_config_flush diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 00b2ffa89e..a9a0bd40b9 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -71,6 +71,15 @@ platform_do_upgrade() { ubnt,edgerouter-x-sfp) platform_upgrade_ubnt_erx "$1" ;; + zyxel,wap6805) + local kernel2_mtd="$(find_mtd_part Kernel2)" + [ "$(hexdump -n 4 -e '"%x"' $kernel2_mtd)" = "56190527" ] &&\ + [ "$(hexdump -n 4 -s 104 -e '"%x"' $kernel2_mtd)" != "0" ] &&\ + dd bs=4 count=1 seek=26 conv=notrunc if=/dev/zero of=$kernel2_mtd 2>/dev/null &&\ + echo "Kernel2 sequence number was reset to 0" + CI_KERNPART="Kernel" + nand_do_upgrade "$1" + ;; *) default_do_upgrade "$1" ;; From f3921acdf0e030b02735683df0f3d368607bd91f Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Wed, 8 Jul 2020 17:48:15 +0200 Subject: [PATCH 33/55] ipq40xx: fix patches on dts Makefile The patches for arch/arm/boot/dts/Makefile have not been updated in a syntactically correct way (just body was changed). Fix it. Fixes: 4a77a060ab62 ("ipq40xx: add support for Buffalo WTR-M2133HP") Signed-off-by: Adrian Schmutzler --- .../linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch | 2 +- .../linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch index 924715c9aa..77c48a36d6 100644 --- a/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-4.19/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -785,11 +785,48 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -785,11 +785,49 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ diff --git a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch index c5b0981f49..d281bb468d 100644 --- a/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch +++ b/target/linux/ipq40xx/patches-5.4/901-arm-boot-add-dts-files.patch @@ -10,7 +10,7 @@ Signed-off-by: John Crispin --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile -@@ -837,11 +837,49 @@ dtb-$(CONFIG_ARCH_QCOM) += \ +@@ -837,11 +837,50 @@ dtb-$(CONFIG_ARCH_QCOM) += \ qcom-apq8074-dragonboard.dtb \ qcom-apq8084-ifc6540.dtb \ qcom-apq8084-mtp.dtb \ From bbdd99619c714d338c14982913d3879f0a088c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0tetiar?= Date: Wed, 8 Jul 2020 21:11:40 +0200 Subject: [PATCH 34/55] kernel: iscsi-initator: fix missing dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes following issue: Package kmod-iscsi-initiator is missing dependencies for the following libraries: crypto_hash.ko Fixes: b88f8202c4ce ("kernel: add iscsi-initator support") Signed-off-by: Petr Štetiar --- package/kernel/linux/modules/block.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/kernel/linux/modules/block.mk b/package/kernel/linux/modules/block.mk index a86c60da2a..faea5cc34e 100644 --- a/package/kernel/linux/modules/block.mk +++ b/package/kernel/linux/modules/block.mk @@ -273,7 +273,7 @@ $(eval $(call KernelPackage,dm-raid)) define KernelPackage/iscsi-initiator SUBMENU:=$(BLOCK_MENU) TITLE:=iSCSI Initiator over TCP/IP - DEPENDS:=+kmod-scsi-core + DEPENDS:=+kmod-scsi-core +kmod-crypto-hash KCONFIG:= \ CONFIG_INET \ CONFIG_SCSI_LOWLEVEL \ From 7de08be913d2769678792fae121fa248dfc2bdf5 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Wed, 8 Jul 2020 21:12:27 +0200 Subject: [PATCH 35/55] ramips: add missing kmod-mt7615-firmware for TP-Link RE500 v1 Adding this has been overlooked when rebasing the commit prior to merge. Fixes: ba0f4f0cfddc ("ramips: add support for TP-Link RE500 v1") Signed-off-by: Adrian Schmutzler --- target/linux/ramips/image/mt7621.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index ad61440c4c..6ab77d0f01 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -869,7 +869,7 @@ define Device/tplink_re500-v1 $(Device/tplink-safeloader) DEVICE_MODEL := RE500 DEVICE_VARIANT := v1 - DEVICE_PACKAGES := kmod-mt7615e wpad-basic + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic TPLINK_BOARD_ID := RE500-V1 IMAGE_SIZE := 14208k endef From 9e6257c26ca29a6040f55c517030e04be95005f2 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Wed, 8 Jul 2020 21:18:12 +0200 Subject: [PATCH 36/55] ramips: move adslr_g7 in image/mt7621.mk to keep sorting Move this device to the top to maintain alphabetic sorting in the file. Signed-off-by: Adrian Schmutzler --- target/linux/ramips/image/mt7621.mk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 6ab77d0f01..5e67d46ade 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -110,6 +110,14 @@ define Build/ubnt-erx-factory-image fi endef +define Device/adslr_g7 + IMAGE_SIZE := 16064k + DEVICE_VENDOR := ADSLR + DEVICE_MODEL := G7 + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic +endef +TARGET_DEVICES += adslr_g7 + define Device/afoundry_ew1200 IMAGE_SIZE := 16064k DEVICE_VENDOR := AFOUNDRY @@ -846,14 +854,6 @@ define Device/totolink_a7000r endef TARGET_DEVICES += totolink_a7000r -define Device/adslr_g7 - IMAGE_SIZE := 16064k - DEVICE_VENDOR := ADSLR - DEVICE_MODEL := G7 - DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware wpad-basic -endef -TARGET_DEVICES += adslr_g7 - define Device/tplink_re350-v1 $(Device/tplink-safeloader) DEVICE_MODEL := RE350 From 4dc9ad4af8c921494d20b303b6772fc6b5af3a69 Mon Sep 17 00:00:00 2001 From: Sergei Burakov Date: Thu, 28 May 2020 21:24:55 +0300 Subject: [PATCH 37/55] ramips: add support for ZyXEL Keenetic Lite Rev.B Device specification: SoC: RT5350 CPU Frequency: 360 MHz Flash Chip: Macronix MX25L6406E (8192 KiB) RAM: Winbond W9825G6JH-6 (32768 KiB) 5x 10/100 Mbps Ethernet (4x LAN, 1x WAN) 1x external antenna UART (J1) header on PCB (57800 8n1) Wireless: SoC-intergated: 2.4GHz 802.11bgn USB: None 8x LED, 2x button Flash instruction: Configure PC with static IP 192.168.99.8/24 and start TFTP server. Rename "openwrt-ramips-rt305x-zyxel_keenetic-lite-b-squashfs-sysupgrade.bin" to "rt305x_firmware.bin" and place it in TFTP server directory. Connect PC with one of LAN ports, press the reset button, power up the router and keep button pressed until power LED start blinking. Router will download file from TFTP server, write it to flash and reboot. Signed-off-by: Sergei Burakov --- .../dts/rt5350_zyxel_keenetic-lite-b.dts | 110 ++++++++++++++++++ target/linux/ramips/image/rt305x.mk | 9 ++ .../rt305x/base-files/etc/board.d/02_network | 1 + 3 files changed, 120 insertions(+) create mode 100644 target/linux/ramips/dts/rt5350_zyxel_keenetic-lite-b.dts diff --git a/target/linux/ramips/dts/rt5350_zyxel_keenetic-lite-b.dts b/target/linux/ramips/dts/rt5350_zyxel_keenetic-lite-b.dts new file mode 100644 index 0000000000..74c7fa920f --- /dev/null +++ b/target/linux/ramips/dts/rt5350_zyxel_keenetic-lite-b.dts @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/dts-v1/; + +#include "rt5350.dtsi" + +#include +#include + +/ { + compatible = "zyxel,keenetic-lite-b", "ralink,rt5350-soc"; + model = "ZyXEL Keenetic Lite Rev.B"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "keenetic-lite-b:green:power"; + gpios = <&gpio0 9 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "keenetic-lite-b:green:wps"; + gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + gpios = <&gpio0 0 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; +}; + +&spi0 { + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <60000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x10000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0x7b0000>; + }; + }; + }; +}; + +&state_default { + gpio { + groups = "uartf"; + function = "gpio"; + }; +}; + +ðernet { + mtd-mac-address = <&factory 0x28>; +}; + +&esw { + mediatek,portmap = <0x2f>; + mediatek,led_polarity = <0x17>; +}; + +&wmac { + ralink,led-polarity = <1>; + ralink,mtd-eeprom = <&factory 0x0>; +}; diff --git a/target/linux/ramips/image/rt305x.mk b/target/linux/ramips/image/rt305x.mk index 3171646b8a..b75d9078e5 100644 --- a/target/linux/ramips/image/rt305x.mk +++ b/target/linux/ramips/image/rt305x.mk @@ -1193,6 +1193,15 @@ define Device/zyxel_keenetic endef TARGET_DEVICES += zyxel_keenetic +define Device/zyxel_keenetic-lite-b + SOC := rt5350 + IMAGE_SIZE := 7872k + DEVICE_VENDOR := ZyXEL + DEVICE_MODEL := Keenetic Lite + DEVICE_VARIANT := B +endef +TARGET_DEVICES += zyxel_keenetic-lite-b + define Device/zyxel_keenetic-start SOC := rt5350 IMAGE_SIZE := 3776k diff --git a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network index f34ade8f68..56c786bc95 100755 --- a/target/linux/ramips/rt305x/base-files/etc/board.d/02_network +++ b/target/linux/ramips/rt305x/base-files/etc/board.d/02_network @@ -164,6 +164,7 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:wan" "6@eth0" ;; + zyxel,keenetic-lite-b|\ zyxel,keenetic-start) ucidef_add_switch "switch0" \ "0:lan:3" "1:lan:2" "2:lan:1" "3:lan:0" "4:wan" "6@eth0" From 541faf2c937bdbb1eb6fae9e146090be57e86a25 Mon Sep 17 00:00:00 2001 From: Furkan Alaca Date: Fri, 3 Jul 2020 01:51:03 -0400 Subject: [PATCH 38/55] ramips: mt7621: use lzma-loader for ra21s & rg21s The rg21s fails to boot if the kernel is larger than about 2,376 KiB. The ra21s is virtually identical hardware. Enabling lzma-loader resolves the issue on both the rg21s and ra21s (see FS#3057 on the issue tracker). Fixes: FS#3057 Signed-off-by: Furkan Alaca --- target/linux/ramips/image/mt7621.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 5e67d46ade..0215683671 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -262,6 +262,7 @@ endef TARGET_DEVICES += d-team_pbr-m1 define Device/edimax_ra21s + $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Edimax DEVICE_MODEL := RA21S @@ -293,6 +294,7 @@ endef TARGET_DEVICES += edimax_re23s define Device/edimax_rg21s + $(Device/uimage-lzma-loader) IMAGE_SIZE := 16064k DEVICE_VENDOR := Edimax DEVICE_MODEL := Gemini AC2600 RG21S From 3e992ea790f470d754eaba3e76608630f38055db Mon Sep 17 00:00:00 2001 From: John Audia Date: Wed, 8 Jul 2020 14:43:04 -0400 Subject: [PATCH 39/55] ipq806x: compile in schedutil governor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gives users a third option to augment ondemand and performance. Kernel docs[1] explain differences and this PR empowers users w/ the choice to select between the older ondemand and newer and more simplistic schedutil should they wish to use one that is not the performance governor. 1. Documentation/admin-guide/pm/cpufreq.rst Signed-off-by: John Audia [fixed From: to match SoB:] Signed-off-by: Petr Štetiar --- target/linux/ipq806x/config-5.4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/ipq806x/config-5.4 b/target/linux/ipq806x/config-5.4 index f2120e6935..794ce95042 100644 --- a/target/linux/ipq806x/config-5.4 +++ b/target/linux/ipq806x/config-5.4 @@ -99,6 +99,7 @@ CONFIG_CPU_FREQ_GOV_COMMON=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y CONFIG_CPU_FREQ_GOV_PERFORMANCE=y # CONFIG_CPU_FREQ_GOV_POWERSAVE is not set +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y # CONFIG_CPU_FREQ_GOV_USERSPACE is not set CONFIG_CPU_FREQ_STAT=y CONFIG_CPU_HAS_ASID=y @@ -503,6 +504,7 @@ CONFIG_UBIFS_FS_ADVANCED_COMPR=y CONFIG_UBIFS_FS_LZO=y CONFIG_UBIFS_FS_ZLIB=y CONFIG_UBIFS_FS_ZSTD=y +# CONFIG_UCLAMP_TASK is not set CONFIG_UEVENT_HELPER_PATH="" CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h" CONFIG_UNWINDER_ARM=y From 691bf54369fbccf9c27a14231a14dcdf07acaf36 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 11 Jan 2020 20:44:34 -0800 Subject: [PATCH 40/55] target.mk: change i386 CPU type to pentium-mmx f4f8f4a180366ee90fd8e153213db2cb746ca361 broke ffmpeg compilation with x86 The reason is that ffmpeg's x86 assembly requires at least MMX, which the pentium CPU_TYPE was preventing. Fixes ffmpeg compilation on x86_legacy and x86_geode. Ref: https://github.com/openwrt/openwrt/pull/3061 Signed-off-by: Rosen Penev --- include/target.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/target.mk b/include/target.mk index 64292138b7..aba477e83b 100644 --- a/include/target.mk +++ b/include/target.mk @@ -174,8 +174,8 @@ ifeq ($(DUMP),1) CPU_CFLAGS_octeonplus = -march=octeon+ -mabi=64 endif ifeq ($(ARCH),i386) - CPU_TYPE ?= pentium - CPU_CFLAGS_pentium = -march=pentium-mmx + CPU_TYPE ?= pentium-mmx + CPU_CFLAGS_pentium-mmx = -march=pentium-mmx CPU_CFLAGS_pentium4 = -march=pentium4 endif ifneq ($(findstring arm,$(ARCH)),) From 14599c59457f04b425603a08dde6aefbc515ff3b Mon Sep 17 00:00:00 2001 From: Sebastian Schaper Date: Wed, 13 May 2020 17:37:31 +0200 Subject: [PATCH 41/55] ath79: add support for D-Link DCH-G020 Rev. A1 The DCH-G020 is a Smart Home Gateway for Z-Wave devices. Specifications: * QCA9531, 16 MiB Flash, 64 MiB RAM * On-Board USB SD3503A Z-Wave dongle * GL850 USB 2.0 Hub (one rear port, internal Z-Wave) * Two Ethernet Ports (10/100) Installation: * Web UI: http://192.168.0.60 (or different address obtained via DHCP) Login with 'admin' and the 6-digit PIN Code from the bottom label * Recovery Web UI: Keep reset button pressed during power-on until LED starts flashing red, upgrade via http://192.168.0.60 * Some modern browsers may have problems flashing via the Web UI, if this occurs consider booting to recovery mode and flashing via: curl -F \ files=@openwrt-ath79-generic-dlink_dch-g020-a1-squashfs-factory.bin \ http://192.168.0.60/cgi/index Known issues: * Real-Time-Clock is not working as there is currently no matching driver It is still included in the dts as compatible = "pericom,pt7c43390"; * openzwave was tested on v19.07 (running MinOZW as a proof-of-concept), but the package grew too big as lots of device pictures were included, thus any use of Z-Wave is up to the user (e.g. extroot and domoticz) The device will use the same MAC address for both wired and wireless interfaces, however it is stored at two different locations in the flash. Signed-off-by: Sebastian Schaper --- .../ath79/dts/qca9531_dlink_dch-g020-a1.dts | 171 ++++++++++++++++++ .../generic/base-files/etc/board.d/02_network | 8 + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 3 + target/linux/ath79/image/generic.mk | 25 +++ 4 files changed, 207 insertions(+) create mode 100644 target/linux/ath79/dts/qca9531_dlink_dch-g020-a1.dts diff --git a/target/linux/ath79/dts/qca9531_dlink_dch-g020-a1.dts b/target/linux/ath79/dts/qca9531_dlink_dch-g020-a1.dts new file mode 100644 index 0000000000..5d6aebf92f --- /dev/null +++ b/target/linux/ath79/dts/qca9531_dlink_dch-g020-a1.dts @@ -0,0 +1,171 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "qca953x.dtsi" + +/ { + compatible = "dlink,dch-g020-a1", "qca,qca9531"; + model = "D-Link DCH-G020 A1"; + + aliases { + led-boot = &led_power; + led-failsafe = &led_power; + led-running = &led_power; + led-upgrade = &led_power; + }; + + i2c { + compatible = "i2c-gpio"; + #address-cells = <1>; + #size-cells = <1>; + + sda-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + scl-gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + + gpio_ext: gpio_ext@38 { + compatible = "nxp,pca9554"; + reg = <0x38 0x1>; + + gpio-controller; + #gpio-cells = <2>; + }; + + rtc@30 { + compatible = "pericom,pt7c43390"; + reg = <0x30 0x8>; + }; + }; + + gpio-export { + compatible = "gpio-export"; + + usb_power { + label = "d-link:power:usb"; + gpio-export,name = "d-link:power:usb"; + gpio-export,output = <0>; + gpios = <&gpio_ext 3 GPIO_ACTIVE_LOW>; + }; + + zwave_power { + label = "d-link:power:zwave"; + gpio-export,name = "d-link:power:zwave"; + gpio-export,output = <0>; + gpios = <&gpio_ext 1 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + wps { + label = "wps"; + linux,code = ; + gpios = <&gpio 3 GPIO_ACTIVE_LOW>; + }; + + reset { + label = "reset"; + linux,code = ; + gpios = <&gpio 17 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_power: power { + label = "d-link:green:power"; + gpios = <&gpio 13 GPIO_ACTIVE_LOW>; + }; + + status { + label = "d-link:red:status"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&spi { + status = "okay"; + + num-cs = <1>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x10000>; + read-only; + }; + + art: partition@10000 { + label = "art"; + reg = <0x10000 0x10000>; + read-only; + }; + + partition@20000 { + label = "mp"; + reg = <0x20000 0x10000>; + read-only; + }; + + partition@30000 { + label = "config"; + reg = <0x30000 0x10000>; + read-only; + }; + + partition@40000 { + label = "bootarg"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + label = "firmware"; + reg = <0x50000 0xe70000>; + compatible = "denx,uimage"; + }; + + partition@ec0000 { + label = "dlink"; + reg = <0xec0000 0x140000>; + read-only; + }; + }; + }; +}; + +&uart { + status = "okay"; +}; + +&usb0 { + status = "okay"; +}; + +&usb_phy { + status = "okay"; +}; + +ð0 { + status = "okay"; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index f2b6ef0aed..4580f3ab4e 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -147,6 +147,10 @@ ath79_setup_interfaces() dlink,dap-2695-a1) ucidef_add_switch "switch0" "0@eth0" "2:lan" "3:wan" "6@eth1" ;; + dlink,dch-g020-a1) + ucidef_add_switch "switch0" \ + "0@eth0" "1:lan:2" "2:lan:1" + ;; dlink,dir-825-b1) ucidef_set_interface_wan "eth1" ucidef_add_switch "switch0" \ @@ -379,6 +383,10 @@ ath79_setup_macs() dlink,dap-2695-a1) label_mac=$(mtd_get_mac_ascii bdcfg "wlanmac") ;; + dlink,dch-g020-a1) + lan_mac=$(mtd_get_mac_text "mp" 0x1) + label_mac=$lan_mac + ;; dlink,dir-825-b1) lan_mac=$(mtd_get_mac_text "caldata" 0xffa0) wan_mac=$(mtd_get_mac_text "caldata" 0xffb4) diff --git a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index f814bd46ad..cf582b8465 100644 --- a/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -17,6 +17,9 @@ case "$board" in adtran,bsap1840) macaddr_add "$(mtd_get_mac_binary 'Board data' 2)" $(($PHYNBR * 8 + 1)) > /sys${DEVPATH}/macaddress ;; + dlink,dch-g020-a1) + mtd_get_mac_text "mp" 0x13 > /sys${DEVPATH}/macaddress + ;; iodata,wn-ac1600dgr) # There is no eeprom data for 5 GHz wlan in "art" partition # which would allow to patch the macaddress diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index d8cac425e8..14e72140dc 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -50,6 +50,17 @@ define Build/cybertan-trx -rm $@-empty.bin endef +define Build/mkdapimg2 + $(STAGING_DIR_HOST)/bin/mkdapimg2 \ + -i $@ -o $@.new \ + -s $(DAP_SIGNATURE) \ + -v $(VERSION_DIST)-$(firstword $(subst +, , \ + $(firstword $(subst -, ,$(REVISION))))) \ + -r Default \ + $(if $(1),-k $(1)) + mv $@.new $@ +endef + define Build/mkmylofw_16m $(eval device_id=$(word 1,$(1))) $(eval revision=$(word 2,$(1))) @@ -563,6 +574,20 @@ define Device/dlink_dap-2695-a1 endef TARGET_DEVICES += dlink_dap-2695-a1 +define Device/dlink_dch-g020-a1 + SOC := qca9531 + DEVICE_VENDOR := D-Link + DEVICE_MODEL := DCH-G020 + DEVICE_VARIANT := A1 + DEVICE_PACKAGES := kmod-gpio-pca953x kmod-i2c-gpio kmod-usb2 kmod-usb-acm + IMAGES += factory.bin + IMAGE_SIZE := 14784k + IMAGE/factory.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | \ + append-rootfs | pad-rootfs | check-size | mkdapimg2 0x20000 + DAP_SIGNATURE := HONEYBEE-FIRMWARE-DCH-G020 +endef +TARGET_DEVICES += dlink_dch-g020-a1 + define Device/dlink_dir-505 SOC := ar9330 DEVICE_VENDOR := D-Link From 7d9fb6aed9e3a225200d44a34256d646c199934c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 17 Jun 2020 22:31:59 +0100 Subject: [PATCH 42/55] fstools: update to the latest version d34ea8e Use autoclear for overlay loopback device Signed-off-by: David Woodhouse --- package/system/fstools/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package/system/fstools/Makefile b/package/system/fstools/Makefile index d5f44893c2..6b813cb433 100644 --- a/package/system/fstools/Makefile +++ b/package/system/fstools/Makefile @@ -12,9 +12,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git -PKG_MIRROR_HASH:=1b875efd7d675d74a56602f57dd27093e2feef8761ba28b567e2d2f43db14b48 -PKG_SOURCE_DATE:=2020-05-12 -PKG_SOURCE_VERSION:=84269037b75de93bdd4ea75b7f50ba77ba976377 +PKG_MIRROR_HASH:=7ff4fae22bf518db200f0c4dd73bc32970678e39e3acc6e8dc98b65319c379cd +PKG_SOURCE_DATE:=2020-06-17 +PKG_SOURCE_VERSION:=d34ea8eb1e12259a315cdef7aa0cd3ceaea68e00 CMAKE_INSTALL:=1 PKG_LICENSE:=GPL-2.0 From c07d0d7f3ecccbd8f877059030060cd7fe6926a9 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 17 Jun 2020 22:04:46 +0100 Subject: [PATCH 43/55] mediatek: mt7623: refresh 5.4 kernel config Some options were not explicitly specified, causing the kernel build to drop to interactive mode. Set the missing options. Signed-off-by: David Woodhouse --- target/linux/mediatek/mt7623/config-5.4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/linux/mediatek/mt7623/config-5.4 b/target/linux/mediatek/mt7623/config-5.4 index cbd16586bc..2ebdae7077 100644 --- a/target/linux/mediatek/mt7623/config-5.4 +++ b/target/linux/mediatek/mt7623/config-5.4 @@ -295,6 +295,7 @@ CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_WORK=y CONFIG_JBD2=y CONFIG_KALLSYMS=y +# CONFIG_KEYBOARD_MTK_PMIC is not set CONFIG_LEDS_MT6323=y CONFIG_LIBFDT=y CONFIG_LOCK_DEBUGGING_SUPPORT=y @@ -465,6 +466,8 @@ CONFIG_SERIAL_MCTRL_GPIO=y CONFIG_SGL_ALLOC=y CONFIG_SMP=y # CONFIG_SMP_ON_UP is not set +# CONFIG_SND_SOC_MT6797 is not set +# CONFIG_SND_SOC_MT8183 is not set CONFIG_SPARSE_IRQ=y CONFIG_SPI=y CONFIG_SPI_BITBANG=y From dca867c5a368045efe38db0ed9bc393ba9a2c9f4 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 13 Jun 2020 23:39:15 +0100 Subject: [PATCH 44/55] firmware-utils/ptgen: allow explicit placement of partitions For Banana Pi R2 we need to place the U-Boot partition at precisely 0x50000. Signed-off-by: David Woodhouse --- tools/firmware-utils/src/ptgen.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c index 83067c104d..223ee29561 100644 --- a/tools/firmware-utils/src/ptgen.c +++ b/tools/firmware-utils/src/ptgen.c @@ -106,6 +106,7 @@ struct pte { }; struct partinfo { + unsigned long start; unsigned long size; int type; }; @@ -290,8 +291,16 @@ static int gen_ptable(uint32_t signature, int nr) pte[i].type = parts[i].type; start = sect + sectors; - if (kb_align != 0) + if (parts[i].start != 0) { + if (parts[i].start * 2 < start) { + fprintf(stderr, "Invalid start %ld for partition %d!\n", + parts[i].start, i); + return ret; + } + start = parts[i].start * 2; + } else if (kb_align != 0) { start = round_to_kb(start); + } pte[i].start = cpu_to_le32(start); sect = start + parts[i].size * 2; @@ -369,8 +378,16 @@ static int gen_gptable(uint32_t signature, guid_t guid, unsigned nr) return ret; } start = sect + sectors; - if (kb_align != 0) + if (parts[i].start != 0) { + if (parts[i].start * 2 < start) { + fprintf(stderr, "Invalid start %ld for partition %d!\n", + parts[i].start, i); + return ret; + } + start = parts[i].start * 2; + } else if (kb_align != 0) { start = round_to_kb(start); + } gpte[i].start = cpu_to_le64(start); sect = start + parts[i].size * 2; @@ -481,13 +498,14 @@ fail: static void usage(char *prog) { - fprintf(stderr, "Usage: %s [-v] [-n] [-g] -h -s -o [-a 0..4] [-l ] [-G ] [[-t ] -p ...] \n", prog); + fprintf(stderr, "Usage: %s [-v] [-n] [-g] -h -s -o [-a 0..4] [-l ] [-G ] [[-t ] -p [@]...] \n", prog); exit(EXIT_FAILURE); } int main (int argc, char **argv) { unsigned char type = 0x83; + char *p; int ch; int part = 0; uint32_t signature = 0x5452574F; /* 'OWRT' */ @@ -519,7 +537,13 @@ int main (int argc, char **argv) fputs("Too many partitions\n", stderr); exit(EXIT_FAILURE); } + p = strchr(optarg, '@'); + if (p) { + *(p++) = 0; + parts[part].start = to_kbytes(p); + } parts[part].size = to_kbytes(optarg); + fprintf(stderr, "part %ld %ld\n", parts[part].start, parts[part].size); parts[part++].type = type; break; case 't': From c848bc6cd576baf1d538d97662e410289214f0b7 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 15 Jun 2020 09:47:09 +0100 Subject: [PATCH 45/55] mediatek/mt7623: unify features and packages, add ext4 and usb The supported MT7623 boards are mostly identical (what with being a System-on-Chip and all), so unify the DEVICE_PACKAGES for them, and add ext4 and usb support for them. Signed-off-by: David Woodhouse --- target/linux/mediatek/image/mt7623.mk | 6 ++++-- target/linux/mediatek/mt7623/target.mk | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/target/linux/mediatek/image/mt7623.mk b/target/linux/mediatek/image/mt7623.mk index 4514719c1d..2257d8010f 100644 --- a/target/linux/mediatek/image/mt7623.mk +++ b/target/linux/mediatek/image/mt7623.mk @@ -5,6 +5,8 @@ define Device/bpi_bananapi-r2 DEVICE_MODEL := Banana Pi R2 DEVICE_DTS := mt7623n-bananapi-bpi-r2 SUPPORTED_DEVICES := bananapi,bpi-r2 + DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ + mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 endef TARGET_DEVICES += bpi_bananapi-r2 @@ -13,9 +15,9 @@ define Device/unielec_u7623-02-emmc-512m DEVICE_MODEL := U7623-02 DEVICE_VARIANT := eMMC/512MB RAM DEVICE_DTS := mt7623a-unielec-u7623-02-emmc-512m - DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ - mkf2fs e2fsprogs IMAGES := sysupgrade-emmc.bin.gz IMAGE/sysupgrade-emmc.bin.gz := sysupgrade-emmc | gzip | append-metadata + DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ + mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 endef TARGET_DEVICES += unielec_u7623-02-emmc-512m diff --git a/target/linux/mediatek/mt7623/target.mk b/target/linux/mediatek/mt7623/target.mk index 9f995f9951..df7d3bf4ed 100644 --- a/target/linux/mediatek/mt7623/target.mk +++ b/target/linux/mediatek/mt7623/target.mk @@ -7,8 +7,8 @@ SUBTARGET:=mt7623 BOARDNAME:=MT7623 CPU_TYPE:=cortex-a7 CPU_SUBTYPE:=neon-vfpv4 - KERNELNAME:=Image dtbs zImage +FEATURES+=ext4 usb define Target/Description Build firmware images for MediaTek mt7623 ARM based boards. From 91e43a1d7a68ead78b6510a706e42e52d6f1a9aa Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 10 Jun 2020 16:23:04 +0100 Subject: [PATCH 46/55] mediatek: enable SATA for mt7623 The MT7623 SoC has the same SATA block as the MT7622, so enable it in MT7623 builds too and add it to the DEVICE_PACKAGES for those boards. Signed-off-by: David Woodhouse --- target/linux/mediatek/image/mt7623.mk | 4 ++-- target/linux/mediatek/modules.mk | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target/linux/mediatek/image/mt7623.mk b/target/linux/mediatek/image/mt7623.mk index 2257d8010f..a38c03deb9 100644 --- a/target/linux/mediatek/image/mt7623.mk +++ b/target/linux/mediatek/image/mt7623.mk @@ -6,7 +6,7 @@ define Device/bpi_bananapi-r2 DEVICE_DTS := mt7623n-bananapi-bpi-r2 SUPPORTED_DEVICES := bananapi,bpi-r2 DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ - mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 + mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk endef TARGET_DEVICES += bpi_bananapi-r2 @@ -18,6 +18,6 @@ define Device/unielec_u7623-02-emmc-512m IMAGES := sysupgrade-emmc.bin.gz IMAGE/sysupgrade-emmc.bin.gz := sysupgrade-emmc | gzip | append-metadata DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ - mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 + mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk endef TARGET_DEVICES += unielec_u7623-02-emmc-512m diff --git a/target/linux/mediatek/modules.mk b/target/linux/mediatek/modules.mk index 7f8c038cae..eb81afe235 100644 --- a/target/linux/mediatek/modules.mk +++ b/target/linux/mediatek/modules.mk @@ -6,7 +6,7 @@ define KernelPackage/ata-ahci-mtk $(LINUX_DIR)/drivers/ata/libahci_platform.ko AUTOLOAD:=$(call AutoLoad,40,libahci libahci_platform ahci_mtk,1) $(call AddDepends/ata) - DEPENDS+=@TARGET_mediatek_mt7622 + DEPENDS+=@(TARGET_mediatek_mt7622||TARGET_mediatek_mt7623) endef define KernelPackage/ata-ahci-mtk/description From 1e4c885395720236d3c7206e019c136795724f6c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 11 Jun 2020 19:33:42 +0100 Subject: [PATCH 47/55] mediatek: new mt7623n preloader package for Banana Pi Download the boot preloader code from the Banana Pi github repo and make it available for bootable SD card image creation. Supports only Banana Pi R2 for now. Based on work by Alexey Loukianov and others. Signed-off-by: David Woodhouse --- package/boot/mt7623n-preloader/Makefile | 61 +++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 package/boot/mt7623n-preloader/Makefile diff --git a/package/boot/mt7623n-preloader/Makefile b/package/boot/mt7623n-preloader/Makefile new file mode 100644 index 0000000000..801c6d19b3 --- /dev/null +++ b/package/boot/mt7623n-preloader/Makefile @@ -0,0 +1,61 @@ +# +# Copyright © 2020 David Woodhouse +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=mt7623n-preloader +PKG_VERSION:=2020-03-11 +PKG_RELEASE:=b27114e184449a33b5d875fda14198f5e6fee2bb + +PKG_MAINTAINER:=David Woodhouse + +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_RELEASE) + +PKG_FLAGS:=nonshared + +include $(INCLUDE_DIR)/package.mk + +BPI_PRELOADER_URL:=@GITHUB/BPI-SINOVOIP/BPI-files/$(PKG_RELEASE)/SD/100MB/ +BPI_PRELOADER_PREFIX:=bpi-preloader-$(PKG_RELEASE) + +define Download/BPI-R2-preloader-2k.img.gz + FILE:=$(BPI_PRELOADER_PREFIX)-BPI-R2-preloader-DDR1600-20191024-2k.img.gz + URL:=$(BPI_PRELOADER_URL) + URL_FILE:=BPI-R2-preloader-DDR1600-20191024-2k.img.gz + HASH:=c731cc166c912c84846e2ed5faf727504e4dec1463754baa6328e9908c84a373 +endef +$(eval $(call Download,BPI-R2-preloader-2k.img.gz)) + + +define Package/mt7623n-preloader + SECTION:=boot + CATEGORY:=Boot Loaders + DEPENDS:=@TARGET_mediatek_mt7623 + TITLE:=mt7623n-preloader + DEFAULT:=y if TARGET_mediatek +endef + +define Package/mt7623n-preloader/description + Preloader image for mt7623n based boards like Banana Pi R2. +endef + +define Build/Prepare + rm -rf $(PKG_BUILD_DIR) + mkdir -p $(PKG_BUILD_DIR) + cp $(DL_DIR)/$(BPI_PRELOADER_PREFIX)-BPI-R2-preloader-DDR1600-20191024-2k.img.gz $(PKG_BUILD_DIR)/mt7623n_bpir2-preloader.bin.gz +endef + +define Build/Compile + true +endef + +define Build/InstallDev + mkdir -p $(STAGING_DIR_IMAGE) + gunzip -c $(PKG_BUILD_DIR)/mt7623n_bpir2-preloader.bin.gz > $(STAGING_DIR_IMAGE)/mt7623n_bpir2-preloader.bin +endef + +$(eval $(call BuildPackage,mt7623n-preloader)) From f0b51c1389e495d6fba3694b76e4df29c00617d5 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Thu, 11 Jun 2020 19:32:12 +0100 Subject: [PATCH 48/55] mediatek: add mt7623 u-boot build for Banana Pi R2 For building full SD/eMMC images for Banana Pi R2 we'll want a u-boot image built for that platform. Signed-off-by: David Woodhouse --- package/boot/uboot-mediatek/Makefile | 9 ++++++++- .../patches/005-update-bpir2-defconfig.patch | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index a8256529bf..f6745f6cad 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -27,7 +27,14 @@ define U-Boot/mt7622 UBOOT_CONFIG:=mt7622_rfb endef -UBOOT_TARGETS := mt7629 mt7622 +define U-Boot/mt7623n_bpir2 + NAME:=Banana Pi R2 (mt7623) + BUILD_SUBTARGET:=mt7623 + UBOOT_IMAGE:=u-boot.bin + UBOOT_CONFIG:=mt7623n_bpir2 +endef + +UBOOT_TARGETS := mt7629 mt7622 mt7623n_bpir2 UBOOT_MAKE_FLAGS += $(UBOOT_IMAGE) diff --git a/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch new file mode 100644 index 0000000000..4ec0edeca5 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch @@ -0,0 +1,14 @@ +diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig +index 6b9fbd7e22..fb2a004803 100644 +--- a/configs/mt7623n_bpir2_defconfig ++++ b/configs/mt7623n_bpir2_defconfig +@@ -52,3 +52,9 @@ CONFIG_TIMER=y + CONFIG_WDT_MTK=y + CONFIG_LZMA=y + # CONFIG_EFI_LOADER is not set ++CONFIG_CMD_BOOTZ=y ++CONFIG_OF_LIBFDT_OVERLAY=y ++#enables savenenv-command ++CONFIG_ENV_IS_IN_MMC=y ++CONFIG_CMD_ASKENV=y ++CONFIG_ENV_SIZE=0x2000 From dc4699470bb634faf683b30494afeb4c0d9a0073 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 19 Jun 2020 12:43:10 +0100 Subject: [PATCH 49/55] mediatek: fix U-Boot pinctrl setup for mt7623 eMMC The U-Boot pinctrl driver for mt7623 was incomplete and didn't handle the settings required for eMMC to work. Submitted upstream at https://patchwork.ozlabs.org/project/uboot/list/?series=184529 Signed-off-by: David Woodhouse --- .../patches/006-mt7623-pinctrl-fix.patch | 236 ++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 package/boot/uboot-mediatek/patches/006-mt7623-pinctrl-fix.patch diff --git a/package/boot/uboot-mediatek/patches/006-mt7623-pinctrl-fix.patch b/package/boot/uboot-mediatek/patches/006-mt7623-pinctrl-fix.patch new file mode 100644 index 0000000000..c5a0cb9c6d --- /dev/null +++ b/package/boot/uboot-mediatek/patches/006-mt7623-pinctrl-fix.patch @@ -0,0 +1,236 @@ +From eca387ea507bde160558a0e5301bf2e0f1985b3b Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Fri, 19 Jun 2020 11:34:32 +0100 +Subject: [PATCH] pinctrl: mediatek: add PUPD/R0/R1 support for MT7623 + +The pins for the MMC controller weren't being set up correctly because the +pinctrl driver only sets the GPIO pullup/pulldown config and doesn't +handle the special cases with PUPD/R0/R1 control. + +Signed-off-by: David Woodhouse +--- + drivers/pinctrl/mediatek/pinctrl-mt7623.c | 129 ++++++++++++++++++ + drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 19 ++- + drivers/pinctrl/mediatek/pinctrl-mtk-common.h | 3 + + 3 files changed, 146 insertions(+), 5 deletions(-) + +diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7623.c b/drivers/pinctrl/mediatek/pinctrl-mt7623.c +index d58d840e08..0f5dcb2c63 100644 +--- a/drivers/pinctrl/mediatek/pinctrl-mt7623.c ++++ b/drivers/pinctrl/mediatek/pinctrl-mt7623.c +@@ -262,6 +262,132 @@ static const struct mtk_pin_field_calc mt7623_pin_drv_range[] = { + PIN_FIELD16(278, 278, 0xf70, 0x10, 8, 4), + }; + ++static const struct mtk_pin_field_calc mt7623_pin_pupd_range[] = { ++ /* MSDC0 */ ++ PIN_FIELD16(111, 111, 0xd00, 0x10, 12, 1), ++ PIN_FIELD16(112, 112, 0xd00, 0x10, 8, 1), ++ PIN_FIELD16(113, 113, 0xd00, 0x10, 4, 1), ++ PIN_FIELD16(114, 114, 0xd00, 0x10, 0, 1), ++ PIN_FIELD16(115, 115, 0xd10, 0x10, 0, 1), ++ PIN_FIELD16(116, 116, 0xcd0, 0x10, 8, 1), ++ PIN_FIELD16(117, 117, 0xcc0, 0x10, 8, 1), ++ PIN_FIELD16(118, 118, 0xcf0, 0x10, 12, 1), ++ PIN_FIELD16(119, 119, 0xcf0, 0x10, 8, 1), ++ PIN_FIELD16(120, 120, 0xcf0, 0x10, 4, 1), ++ PIN_FIELD16(121, 121, 0xcf0, 0x10, 0, 1), ++ /* MSDC1 */ ++ PIN_FIELD16(105, 105, 0xd40, 0x10, 8, 1), ++ PIN_FIELD16(106, 106, 0xd30, 0x10, 8, 1), ++ PIN_FIELD16(107, 107, 0xd60, 0x10, 0, 1), ++ PIN_FIELD16(108, 108, 0xd60, 0x10, 10, 1), ++ PIN_FIELD16(109, 109, 0xd60, 0x10, 4, 1), ++ PIN_FIELD16(110, 110, 0xc60, 0x10, 12, 1), ++ /* MSDC1 */ ++ PIN_FIELD16(85, 85, 0xda0, 0x10, 8, 1), ++ PIN_FIELD16(86, 86, 0xd90, 0x10, 8, 1), ++ PIN_FIELD16(87, 87, 0xdc0, 0x10, 0, 1), ++ PIN_FIELD16(88, 88, 0xdc0, 0x10, 10, 1), ++ PIN_FIELD16(89, 89, 0xdc0, 0x10, 4, 1), ++ PIN_FIELD16(90, 90, 0xdc0, 0x10, 12, 1), ++ /* MSDC0E */ ++ PIN_FIELD16(249, 249, 0x140, 0x10, 0, 1), ++ PIN_FIELD16(250, 250, 0x130, 0x10, 12, 1), ++ PIN_FIELD16(251, 251, 0x130, 0x10, 8, 1), ++ PIN_FIELD16(252, 252, 0x130, 0x10, 4, 1), ++ PIN_FIELD16(253, 253, 0x130, 0x10, 0, 1), ++ PIN_FIELD16(254, 254, 0xf40, 0x10, 12, 1), ++ PIN_FIELD16(255, 255, 0xf40, 0x10, 8, 1), ++ PIN_FIELD16(256, 256, 0xf40, 0x10, 4, 1), ++ PIN_FIELD16(257, 257, 0xf40, 0x10, 0, 1), ++ PIN_FIELD16(258, 258, 0xcb0, 0x10, 8, 1), ++ PIN_FIELD16(259, 259, 0xc90, 0x10, 8, 1), ++ PIN_FIELD16(261, 261, 0x140, 0x10, 8, 1), ++}; ++ ++static const struct mtk_pin_field_calc mt7623_pin_r1_range[] = { ++ /* MSDC0 */ ++ PIN_FIELD16(111, 111, 0xd00, 0x10, 13, 1), ++ PIN_FIELD16(112, 112, 0xd00, 0x10, 9, 1), ++ PIN_FIELD16(113, 113, 0xd00, 0x10, 5, 1), ++ PIN_FIELD16(114, 114, 0xd00, 0x10, 1, 1), ++ PIN_FIELD16(115, 115, 0xd10, 0x10, 1, 1), ++ PIN_FIELD16(116, 116, 0xcd0, 0x10, 9, 1), ++ PIN_FIELD16(117, 117, 0xcc0, 0x10, 9, 1), ++ PIN_FIELD16(118, 118, 0xcf0, 0x10, 13, 1), ++ PIN_FIELD16(119, 119, 0xcf0, 0x10, 9, 1), ++ PIN_FIELD16(120, 120, 0xcf0, 0x10, 5, 1), ++ PIN_FIELD16(121, 121, 0xcf0, 0x10, 1, 1), ++ /* MSDC1 */ ++ PIN_FIELD16(105, 105, 0xd40, 0x10, 9, 1), ++ PIN_FIELD16(106, 106, 0xd30, 0x10, 9, 1), ++ PIN_FIELD16(107, 107, 0xd60, 0x10, 1, 1), ++ PIN_FIELD16(108, 108, 0xd60, 0x10, 9, 1), ++ PIN_FIELD16(109, 109, 0xd60, 0x10, 5, 1), ++ PIN_FIELD16(110, 110, 0xc60, 0x10, 13, 1), ++ /* MSDC2 */ ++ PIN_FIELD16(85, 85, 0xda0, 0x10, 9, 1), ++ PIN_FIELD16(86, 86, 0xd90, 0x10, 9, 1), ++ PIN_FIELD16(87, 87, 0xdc0, 0x10, 1, 1), ++ PIN_FIELD16(88, 88, 0xdc0, 0x10, 9, 1), ++ PIN_FIELD16(89, 89, 0xdc0, 0x10, 5, 1), ++ PIN_FIELD16(90, 90, 0xdc0, 0x10, 13, 1), ++ /* MSDC0E */ ++ PIN_FIELD16(249, 249, 0x140, 0x10, 1, 1), ++ PIN_FIELD16(250, 250, 0x130, 0x10, 13, 1), ++ PIN_FIELD16(251, 251, 0x130, 0x10, 9, 1), ++ PIN_FIELD16(252, 252, 0x130, 0x10, 5, 1), ++ PIN_FIELD16(253, 253, 0x130, 0x10, 1, 1), ++ PIN_FIELD16(254, 254, 0xf40, 0x10, 13, 1), ++ PIN_FIELD16(255, 255, 0xf40, 0x10, 9, 1), ++ PIN_FIELD16(256, 256, 0xf40, 0x10, 5, 1), ++ PIN_FIELD16(257, 257, 0xf40, 0x10, 1, 1), ++ PIN_FIELD16(258, 258, 0xcb0, 0x10, 9, 1), ++ PIN_FIELD16(259, 259, 0xc90, 0x10, 9, 1), ++ PIN_FIELD16(261, 261, 0x140, 0x10, 9, 1), ++}; ++ ++static const struct mtk_pin_field_calc mt7623_pin_r0_range[] = { ++ /* MSDC0 */ ++ PIN_FIELD16(111, 111, 0xd00, 0x10, 14, 1), ++ PIN_FIELD16(112, 112, 0xd00, 0x10, 10, 1), ++ PIN_FIELD16(113, 113, 0xd00, 0x10, 6, 1), ++ PIN_FIELD16(114, 114, 0xd00, 0x10, 2, 1), ++ PIN_FIELD16(115, 115, 0xd10, 0x10, 2, 1), ++ PIN_FIELD16(116, 116, 0xcd0, 0x10, 10, 1), ++ PIN_FIELD16(117, 117, 0xcc0, 0x10, 10, 1), ++ PIN_FIELD16(118, 118, 0xcf0, 0x10, 14, 1), ++ PIN_FIELD16(119, 119, 0xcf0, 0x10, 10, 1), ++ PIN_FIELD16(120, 120, 0xcf0, 0x10, 6, 1), ++ PIN_FIELD16(121, 121, 0xcf0, 0x10, 2, 1), ++ /* MSDC1 */ ++ PIN_FIELD16(105, 105, 0xd40, 0x10, 10, 1), ++ PIN_FIELD16(106, 106, 0xd30, 0x10, 10, 1), ++ PIN_FIELD16(107, 107, 0xd60, 0x10, 2, 1), ++ PIN_FIELD16(108, 108, 0xd60, 0x10, 8, 1), ++ PIN_FIELD16(109, 109, 0xd60, 0x10, 6, 1), ++ PIN_FIELD16(110, 110, 0xc60, 0x10, 14, 1), ++ /* MSDC2 */ ++ PIN_FIELD16(85, 85, 0xda0, 0x10, 10, 1), ++ PIN_FIELD16(86, 86, 0xd90, 0x10, 10, 1), ++ PIN_FIELD16(87, 87, 0xdc0, 0x10, 2, 1), ++ PIN_FIELD16(88, 88, 0xdc0, 0x10, 8, 1), ++ PIN_FIELD16(89, 89, 0xdc0, 0x10, 6, 1), ++ PIN_FIELD16(90, 90, 0xdc0, 0x10, 14, 1), ++ /* MSDC0E */ ++ PIN_FIELD16(249, 249, 0x140, 0x10, 2, 1), ++ PIN_FIELD16(250, 250, 0x130, 0x10, 14, 1), ++ PIN_FIELD16(251, 251, 0x130, 0x10, 10, 1), ++ PIN_FIELD16(252, 252, 0x130, 0x10, 6, 1), ++ PIN_FIELD16(253, 253, 0x130, 0x10, 2, 1), ++ PIN_FIELD16(254, 254, 0xf40, 0x10, 14, 1), ++ PIN_FIELD16(255, 255, 0xf40, 0x10, 10, 1), ++ PIN_FIELD16(256, 256, 0xf40, 0x10, 6, 1), ++ PIN_FIELD16(257, 257, 0xf40, 0x10, 5, 1), ++ PIN_FIELD16(258, 258, 0xcb0, 0x10, 10, 1), ++ PIN_FIELD16(259, 259, 0xc90, 0x10, 10, 1), ++ PIN_FIELD16(261, 261, 0x140, 0x10, 10, 1), ++}; ++ + static const struct mtk_pin_reg_calc mt7623_reg_cals[] = { + [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7623_pin_mode_range), + [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7623_pin_dir_range), +@@ -272,6 +398,9 @@ static const struct mtk_pin_reg_calc mt7623_reg_cals[] = { + [PINCTRL_PIN_REG_PULLSEL] = MTK_RANGE(mt7623_pin_pullsel_range), + [PINCTRL_PIN_REG_PULLEN] = MTK_RANGE(mt7623_pin_pullen_range), + [PINCTRL_PIN_REG_DRV] = MTK_RANGE(mt7623_pin_drv_range), ++ [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt7623_pin_pupd_range), ++ [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt7623_pin_r0_range), ++ [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt7623_pin_r1_range), + }; + + static const struct mtk_pin_desc mt7623_pins[] = { +diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +index 5fdc150295..f5199fc574 100644 +--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c ++++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c +@@ -296,7 +296,7 @@ static const struct pinconf_param mtk_conf_params[] = { + }; + + +-int mtk_pinconf_bias_set_v0(struct udevice *dev, u32 pin, u32 arg) ++int mtk_pinconf_bias_set_v0(struct udevice *dev, u32 pin, u32 arg, u32 val) + { + int err, disable, pullup; + +@@ -323,12 +323,14 @@ int mtk_pinconf_bias_set_v0(struct udevice *dev, u32 pin, u32 arg) + return 0; + } + +-int mtk_pinconf_bias_set_v1(struct udevice *dev, u32 pin, u32 arg) ++int mtk_pinconf_bias_set_v1(struct udevice *dev, u32 pin, u32 arg, u32 val) + { +- int err, disable, pullup; ++ int err, disable, pullup, r0, r1; + + disable = (arg == PIN_CONFIG_BIAS_DISABLE); + pullup = (arg == PIN_CONFIG_BIAS_PULL_UP); ++ r0 = !!(val & 1); ++ r1 = !!(val & 2); + + if (disable) { + err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PULLEN, 0); +@@ -344,6 +346,13 @@ int mtk_pinconf_bias_set_v1(struct udevice *dev, u32 pin, u32 arg) + return err; + } + ++ /* Also set PUPD/R0/R1 if the pin has them */ ++ err = mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_PUPD, !pullup); ++ if (err != -EINVAL) { ++ mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R0, r0); ++ mtk_hw_set_value(dev, pin, PINCTRL_PIN_REG_R1, r1); ++ } ++ + return 0; + } + +@@ -419,9 +428,9 @@ static int mtk_pinconf_set(struct udevice *dev, unsigned int pin, + case PIN_CONFIG_BIAS_PULL_UP: + case PIN_CONFIG_BIAS_PULL_DOWN: + if (rev == MTK_PINCTRL_V0) +- err = mtk_pinconf_bias_set_v0(dev, pin, param); ++ err = mtk_pinconf_bias_set_v0(dev, pin, param, arg); + else +- err = mtk_pinconf_bias_set_v1(dev, pin, param); ++ err = mtk_pinconf_bias_set_v1(dev, pin, param, arg); + if (err) + goto err; + break; +diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +index e815761450..5e51a9a90c 100644 +--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.h ++++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.h +@@ -51,6 +51,9 @@ enum { + PINCTRL_PIN_REG_PULLEN, + PINCTRL_PIN_REG_PULLSEL, + PINCTRL_PIN_REG_DRV, ++ PINCTRL_PIN_REG_PUPD, ++ PINCTRL_PIN_REG_R0, ++ PINCTRL_PIN_REG_R1, + PINCTRL_PIN_REG_MAX, + }; + +-- +2.26.2 + From 0c7bce7efd4ac675d154a3c3372d19e0340cea9c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 19 Jun 2020 23:11:48 +0100 Subject: [PATCH 50/55] mediatek: use U-Boot FAT environment support for Banana Pi R2 Instead of building in a default environment which loads our environment from the FAT partition.... just ask U-Boot to do it. Submitted upstream at https://patchwork.ozlabs.org/project/uboot/list/?series=184688 Signed-off-by: David Woodhouse --- .../patches/005-update-bpir2-defconfig.patch | 7 +- .../patches/007-env-fat-use-bootdevice.patch | 88 +++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 package/boot/uboot-mediatek/patches/007-env-fat-use-bootdevice.patch diff --git a/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch index 4ec0edeca5..104994bf63 100644 --- a/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch +++ b/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch @@ -2,13 +2,16 @@ diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig index 6b9fbd7e22..fb2a004803 100644 --- a/configs/mt7623n_bpir2_defconfig +++ b/configs/mt7623n_bpir2_defconfig -@@ -52,3 +52,9 @@ CONFIG_TIMER=y +@@ -52,3 +52,12 @@ CONFIG_TIMER=y CONFIG_WDT_MTK=y CONFIG_LZMA=y # CONFIG_EFI_LOADER is not set +CONFIG_CMD_BOOTZ=y +CONFIG_OF_LIBFDT_OVERLAY=y +#enables savenenv-command -+CONFIG_ENV_IS_IN_MMC=y ++CONFIG_ENV_IS_IN_FAT=y ++CONFIG_ENV_FAT_INTERFACE="mmc" ++CONFIG_ENV_FAT_DEVICE_AND_PART=":2" ++CONFIG_ENV_FAT_FILE="uboot.env" +CONFIG_CMD_ASKENV=y +CONFIG_ENV_SIZE=0x2000 diff --git a/package/boot/uboot-mediatek/patches/007-env-fat-use-bootdevice.patch b/package/boot/uboot-mediatek/patches/007-env-fat-use-bootdevice.patch new file mode 100644 index 0000000000..20b6620d71 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/007-env-fat-use-bootdevice.patch @@ -0,0 +1,88 @@ +From fb2810b2c7209d4ed690e48e5bffa52d1af2eda3 Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Fri, 19 Jun 2020 22:57:04 +0100 +Subject: [PATCH] env/fat.c: allow loading from a FAT partition on the MMC boot + device + +I don't want to have to specify the device; only the partition. + +Signed-off-by: David Woodhouse +--- + env/Kconfig | 4 ++++ + env/fat.c | 31 +++++++++++++++++++++++++++++-- + 2 files changed, 33 insertions(+), 2 deletions(-) + +diff --git a/env/Kconfig b/env/Kconfig +index 0d6f559b39..a2020a8661 100644 +--- a/env/Kconfig ++++ b/env/Kconfig +@@ -432,6 +432,10 @@ config ENV_FAT_DEVICE_AND_PART + If none, first valid partition in device D. If no + partition table then means device D. + ++ If ENV_FAT_INTERFACE is set to "mmc" then device 'D' can be omitted, ++ leaving the string starting with a colon, and the boot device will ++ be used. ++ + config ENV_FAT_FILE + string "Name of the FAT file to use for the environment" + depends on ENV_IS_IN_FAT +diff --git a/env/fat.c b/env/fat.c +index 1836556f36..1c32d17bd5 100644 +--- a/env/fat.c ++++ b/env/fat.c +@@ -31,6 +31,33 @@ + # endif + #endif + ++#if defined(CMD_SAVEENV) || defined(CMD_LOADENV) ++__weak int mmc_get_env_dev(void) ++{ ++ return CONFIG_SYS_MMC_ENV_DEV; ++} ++ ++static char *env_fat_device_and_part(void) ++{ ++#ifdef CONFIG_MMC ++ static char *part_str; ++ ++ if (!part_str) { ++ part_str = CONFIG_ENV_FAT_DEVICE_AND_PART; ++ if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "mmc") ++ && part_str[0] == ':') { ++ part_str = "0" CONFIG_ENV_FAT_DEVICE_AND_PART; ++ part_str[0] += mmc_get_env_dev(); ++ } ++ } ++ ++ return part_str; ++#else ++ return CONFIG_ENV_FAT_DEVICE_AND_PART; ++#endif ++} ++#endif ++ + #ifdef CMD_SAVEENV + static int env_fat_save(void) + { +@@ -46,7 +73,7 @@ static int env_fat_save(void) + return err; + + part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, +- CONFIG_ENV_FAT_DEVICE_AND_PART, ++ env_fat_device_and_part(), + &dev_desc, &info, 1); + if (part < 0) + return 1; +@@ -93,7 +120,7 @@ static int env_fat_load(void) + #endif + + part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, +- CONFIG_ENV_FAT_DEVICE_AND_PART, ++ env_fat_device_and_part(), + &dev_desc, &info, 1); + if (part < 0) + goto err_env_relocate; +-- +2.26.2 + From 7adc29f59ede5112b94b3df4688b47a88f84f544 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 12 Jun 2020 11:06:38 +0100 Subject: [PATCH 51/55] mediatek: add SD card image creation for Banana Pi R2 Based on work by Alexey Loukianov and others. Signed-off-by: David Woodhouse --- .../patches/005-update-bpir2-defconfig.patch | 3 +- target/linux/mediatek/image/Config.in | 4 + .../linux/mediatek/image/gen_banana_pi_img.sh | 145 ++++++++++++++++++ target/linux/mediatek/image/mt7623.mk | 30 ++++ .../mediatek/image/mt7623n_bpir2-uEnv.txt | 78 ++++++++++ 5 files changed, 259 insertions(+), 1 deletion(-) create mode 100644 target/linux/mediatek/image/Config.in create mode 100755 target/linux/mediatek/image/gen_banana_pi_img.sh create mode 100644 target/linux/mediatek/image/mt7623n_bpir2-uEnv.txt diff --git a/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch b/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch index 104994bf63..a45665eff6 100644 --- a/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch +++ b/package/boot/uboot-mediatek/patches/005-update-bpir2-defconfig.patch @@ -2,7 +2,7 @@ diff --git a/configs/mt7623n_bpir2_defconfig b/configs/mt7623n_bpir2_defconfig index 6b9fbd7e22..fb2a004803 100644 --- a/configs/mt7623n_bpir2_defconfig +++ b/configs/mt7623n_bpir2_defconfig -@@ -52,3 +52,12 @@ CONFIG_TIMER=y +@@ -52,3 +52,13 @@ CONFIG_TIMER=y CONFIG_WDT_MTK=y CONFIG_LZMA=y # CONFIG_EFI_LOADER is not set @@ -15,3 +15,4 @@ index 6b9fbd7e22..fb2a004803 100644 +CONFIG_ENV_FAT_FILE="uboot.env" +CONFIG_CMD_ASKENV=y +CONFIG_ENV_SIZE=0x2000 ++CONFIG_CMD_SETEXPR=y diff --git a/target/linux/mediatek/image/Config.in b/target/linux/mediatek/image/Config.in new file mode 100644 index 0000000000..f32f83c321 --- /dev/null +++ b/target/linux/mediatek/image/Config.in @@ -0,0 +1,4 @@ +config BANANA_PI_BOOT_PARTSIZE + int "Boot (SD Card) filesystem partition size (in MiB)" + depends on TARGET_mediatek_mt7623_DEVICE_bpi_bananapi-r2 + default 32 diff --git a/target/linux/mediatek/image/gen_banana_pi_img.sh b/target/linux/mediatek/image/gen_banana_pi_img.sh new file mode 100755 index 0000000000..26fbca1388 --- /dev/null +++ b/target/linux/mediatek/image/gen_banana_pi_img.sh @@ -0,0 +1,145 @@ +#!/bin/sh +# +# Copyright © 2019 Alexey Loukianov +# Copyright © 2020 David Woodhouse +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +# Generates a bootable SD card image for Banana Pi R2 (and probably +# other similar boards) as documented at +# http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:storage +# +# The first sector must contain the SDMMC_BOOT header shown +# below, and also contains the MBR partition table in the end +# of the sector. The partition table must contain no active +# partitions. +# +# The second sector must contain the BRLYT header, and the +# special preloader image goes in sector 4; 2KiB into the image. +# +# The preloader loads U-Boot from sector 640; 320KiB into the image. +# The location and the size (512KiB) are fixed and not read from +# the partition table. We set up a partition for it merely for +# our own convenience for upgrades, etc. +# +# The second partition is a FAT file system containing the kernel +# image and a uboot.env file, which is provided to this script as +# $4 (bootfs image). Its size is configurable with the +# CONFIG_BANANA_PI_BOOT_PARTSIZE option; by default 32MiB. +# +# The root filesystem comes next in the third partition. +# +# +# ------------------------ Sector Offset +# | MBR + SDMMC_BOOT | 0 0x0 +# |----------------------| +# | BRLYT header | 1 0x200 +# |----------------------| +# . . +# . . +# |----------------------| +# | | 4 0x800 +# | | +# | Preloader | +# . . +# . . +# | | 639 +# |----------------------| +# | MBR partition #1 | 640 0x50000 +# | | +# | U-Boot | +# . . +# . . +# | | 1663 +# |----------------------| +# | MBR partition #2 | +# | | +# | FAT partition | ( BANANA_PI_BOOT_PARTSIZE +# . . default 32MiB ) +# . (kernel, uEnv) . +# | | +# |----------------------| +# | MBR partition #3 | +# | | +# | Root partition | +# | | ( TARGET_ROOTFS_PARTSIZE +# | (squashfs+overlay | default 104MiB ) +# . or ext4, etc.) . +# . . +# | | +# ------------------------ +# +# For eMMC boot, everything up to and including the preloader must be +# written to /dev/mmcblk0boot0, with the SDMMC_BOOT header changed to +# read EMMC_BOOT\0 instead. +# +# The contents of the main eMMC are identical to the SD card layout, +# with the preloader loading 512KiB of U-Boot starting at 0x50000. + +function usage() { + echo "SYNTAX: $0 sd " + echo " OR: $0 emmc " + exit 1 +} + +set -e + +PRELOADER_OFFSET=2 # 2KiB + +SDMMC_BOOT="SDMMC_BOOT\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00" +EMMC_BOOT="EMMC_BOOT\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00" +BRLYT="BRLYT\x00\x00\x00\x01\x00\x00\x00\x00\x08\x00\x00\ +\x00\x08\x00\x00\x42\x42\x42\x42\x08\x00\x01\x00\x00\x08\x00\x00\ +\x00\x08\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + +case $1 in + sd) + [ $# -eq 8 ] || usage + OUTPUT="$2" + PRELOADER="$3" + UBOOT="$4" + BOOTFS="$5" + ROOTFS="$6" + BOOTFSSIZE="$7" + ROOTFSSIZE="$8" + + head=4 + sect=63 + + set $(ptgen -o $OUTPUT -h $head -s $sect -a 0 -l 1024 \ + -t 41 -p 512k@320k \ + -t c -p ${BOOTFSSIZE}M \ + -t 83 -p ${ROOTFSSIZE}M ) + + UBOOT_OFFSET="$(($1 / 512))" + UBOOT_SIZE="$(($2 / 512))" + BOOTFS_OFFSET="$(($3 / 512))" + BOOTFS_SIZE="$(($4 / 512))" + ROOTFS_OFFSET="$(($5 / 512))" + ROOTFS_SIZE="$(($6 / 512))" + + echo -en "${SDMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0 conv=notrunc + echo -en "${BRLYT}" | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc + + dd bs=1024 if="${PRELOADER}" of="${OUTPUT}" seek="${PRELOADER_OFFSET}" conv=notrunc + dd bs=512 if="${UBOOT}" of="${OUTPUT}" seek="${UBOOT_OFFSET}" conv=notrunc + dd bs=512 if="${BOOTFS}" of="${OUTPUT}" seek="${BOOTFS_OFFSET}" conv=notrunc + dd bs=512 if="${ROOTFS}" of="${OUTPUT}" seek="${ROOTFS_OFFSET}" conv=notrunc + dd bs=128k if=/dev/zero of="${OUTPUT}" count=1 oflag=append conv=notrunc + ;; + emmc) + [ $# -eq 3 ] || usage + OUTPUT="$2" + PRELOADER="$3" + + echo -en "${EMMC_BOOT}" | dd bs=1 of="${OUTPUT}" seek=0 + echo -en "${BRLYT}" | dd bs=1 of="${OUTPUT}" seek=512 conv=notrunc + + dd bs=1024 if="${PRELOADER}" of="${OUTPUT}" seek="${PRELOADER_OFFSET}" conv=notrunc + ;; + *) + usage + ;; +esac diff --git a/target/linux/mediatek/image/mt7623.mk b/target/linux/mediatek/image/mt7623.mk index a38c03deb9..1c2dcf7624 100644 --- a/target/linux/mediatek/image/mt7623.mk +++ b/target/linux/mediatek/image/mt7623.mk @@ -1,5 +1,30 @@ KERNEL_LOADADDR := 0x80008000 +ifneq ($(CONFIG_BANANA_PI_BOOT_PARTSIZE),) +BOOTFS_BLOCK_SIZE := 1024 +BOOTFS_BLOCKS := $(shell echo $$(($(CONFIG_BANANA_PI_BOOT_PARTSIZE)*1024*1024/$(BOOTFS_BLOCK_SIZE)))) +endif + +define Build/banana-pi-sdcard + rm -f $@.boot + mkfs.fat -C $@.boot $(BOOTFS_BLOCKS) + + ./gen_banana_pi_img.sh emmc $@.emmc \ + $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-preloader.bin + + mkenvimage -s 0x2000 -o $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-uboot.env $(UBOOT_TARGET)-uEnv.txt + mcopy -i $@.boot $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-uboot.env ::uboot.env + mcopy -i $@.boot $(IMAGE_KERNEL) ::uImage + mcopy -i $@.boot $@.emmc ::eMMCboot.bin + ./gen_banana_pi_img.sh sd $@ \ + $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-preloader.bin \ + $(STAGING_DIR_IMAGE)/$(UBOOT_TARGET)-u-boot.bin \ + $@.boot \ + $(IMAGE_ROOTFS) \ + $(CONFIG_BANANA_PI_BOOT_PARTSIZE) \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) +endef + define Device/bpi_bananapi-r2 DEVICE_VENDOR := Bpi DEVICE_MODEL := Banana Pi R2 @@ -7,6 +32,11 @@ define Device/bpi_bananapi-r2 SUPPORTED_DEVICES := bananapi,bpi-r2 DEVICE_PACKAGES := kmod-fs-vfat kmod-nls-cp437 kmod-nls-iso8859-1 kmod-mmc \ mkf2fs e2fsprogs kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-ata-ahci-mtk + UBOOT_TARGET := mt7623n_bpir2 + IMAGES := img.gz + IMAGE/img.gz := banana-pi-sdcard | gzip | append-metadata + KERNEL := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb + KERNEL_INITRAMFS := endef TARGET_DEVICES += bpi_bananapi-r2 diff --git a/target/linux/mediatek/image/mt7623n_bpir2-uEnv.txt b/target/linux/mediatek/image/mt7623n_bpir2-uEnv.txt new file mode 100644 index 0000000000..f260ed9176 --- /dev/null +++ b/target/linux/mediatek/image/mt7623n_bpir2-uEnv.txt @@ -0,0 +1,78 @@ +# Boot menu for Banana Pi R2 +# Copyright © 2020 David Woodhouse + +kernel=uImage +loadaddr=0x88000000 +dtaddr=0x83f00000 +fdt_high=0xffffffff + +console=ttyS2,115200 +bootopts=rootfstype=squashfs,ext4 rootwait + +# Create the command line (with appropriate root=) and boot the Linux FIT image. +boot1=setenv bootargs "console=${console} root=${rootdev} ${bootopts}";printenv bootargs;\ + fatload mmc ${partition} ${loadaddr} ${kernel}; bootm + +# The preloader leaves a breadcrumb behind to say what it booted from. +checkbootedfrom=if itest.l *81dffff0 == 434d4d65 ; then setenv bootedfrom eMMC; else setenv bootedfrom SD; fi; + +# Build the boot menu one item at a time +bm_count=0 +checkkernel=test -e mmc ${bm_part} ${kernel} +addbm=if run checkkernel; then setenv bootmenu_${bm_count} "Boot from ${bm_dev}.=setenv partition ${bm_part};setenv rootdev ${bm_root};run boot1";if test "${bootedfrom}" = "${bm_dev}"; then setenv bootmenu_default ${bm_count};fi;setexpr bm_count ${bm_count} + 1; fi +# Here we assume that SD card id mmcblk1 and eMMC is mmcblk0 in linux. Swap them if your DTS define them in reverse order. +addeMMCbm=setenv bm_part 0:2;setenv bm_root /dev/mmcblk0p3;setenv bm_dev eMMC;run addbm +addSDbm=setenv bm_part 1:2;setenv bm_root /dev/mmcblk1p3;setenv bm_dev SD;run addbm +addinstallbm=if test "${bootedfrom}" = "SD";then run checkinstall; if run validparts; then setenv bootmenu_${bm_count} "Install OpenWrt from SD to internal eMMC.=run doinstall";setexpr bm_count ${bm_count} + 1;fi;fi + +runbootmenu=if test "${bootedfrom}" = "";then run checkbootedfrom;fi;\ + setenv bm_count 0;run addeMMCbm;run addSDbm;run addinstallbm;setenv bootmenu_${bm_count};\ + bootmenu + +bootdelay=0 +bootcmd=run checkbootedfrom;run runbootmenu + +# XX: Can we read this from the device, or must we trust they're all the same as mine? +# Probably not that important as we're unlikely ever to hit the limit anyway. +maxsect=0xe8ffff +validparts=false + +# We could use 'part size' here but I'd like to check the types too. +checkinstall=mmc dev 1;\ + mmc read 0x88000002 0 1;\ + setenv validparts true;\ + test -e mmc 1:2 eMMCboot.bin || setenv validparts false && echo "eMMCboot.bin not present on SD partition 2";\ + if run validparts && itest.b *0x880001c4 != 0x41; then echo "SD partition 1 is not a PReP Boot partition"; setenv validparts false; fi;\ + if run validparts && itest.l *0x880001c8 != 0x280; then echo "SD partition 1 does not start at 320KiB for U-Boot"; mmc part; exit; fi;\ + if run validparts && itest.l *0x880001cc != 0x400; then echo "SD partition 1 is not 512KiB in size for U-Boot"; mmc part; exit; fi;\ + if run validparts && itest.b *0x880001d4 != 0x0c; then echo "SD partition 2 is not a FAT32 partition"; setenv validparts false; fi;\ + if run validparts && itest.b *0x880001e4 != 0x83; then echo "SD partition 3 is not a Linux partition"; setenv validparts false; fi;\ + setexpr.l part2_start *0x880001d8;setexpr.l part2_len *0x880001dc;setexpr.l part3_start *0x880001e8;setexpr.l part3_len *0x880001ec;\ + if run validparts && test 0x${part2_start} -gt ${maxsect}; then echo "SD partition 2 start too high"; setenv validparts false; fi;\ + if run validparts && test 0x${part2_len} -gt ${maxsect}; then echo "SD partition 2 is too large"; setenv validparts false; fi;\ + if run validparts && test 0x${part3_start} -gt ${maxsect}; then echo "SD partition 3 start too high"; setenv validparts false; fi;\ + if run validparts && test 0x${part3_len} -gt ${maxsect}; then echo "SD partition 2 is too large"; setenv validparts false; fi;\ + setexpr.l part2_end 0x$(part2_start} + 0x${part2_len};setexpr.l part3_end 0x${part3_start} + 0x${part3_len};\ + if run validparts && test 0x${part2_end} -ge ${maxsect}; then echo "SD partition 2 end too high"; setenv validparts false; fi;\ + if run validparts && test 0x${part3_end} -ge ${maxsect}; then echo "SD partition 3 end too high"; setenv validparts false; fi; + +# Copy a single chunk, up to 0x8000 sectors / 16MiB, from SD to eMMC at the specified offset. +writechunk=setenv thislen 8000; if test 0x${partlen} -lt 0x${thislen}; then setenv thislen ${partlen};fi;\ + mmc dev 1;mmc read ${loadaddr} 0x${partofs} 0x${thislen};\ + mmc dev 0; mmc write ${loadaddr} 0x${partofs} 0x${thislen};\ + setexpr partofs 0x${partofs} + 0x${thislen};setexpr partlen 0x${partlen} - 0x${thislen} + +# Copy a partition defined by ${partofs} / ${partlen} from SD to eMMC +writepart=while test 0x${partlen} -ne 0; do run writechunk; done + +# Configure the eMMC boot partition and write eMMCboot.bin to it +writeboot=mmc partconf 0 1 1 0;fatload mmc 1:2 ${loadaddr} eMMCboot.bin;\ + setexpr filesize ${filesize} + 0x1ff;setexpr blocks ${filesize} / 0x200;\ + mmc dev 0 1;mmc write ${loadaddr} 0 ${blocks} + +# Install OpenWrt from the SD card to internal eMMC. +doinstall=run checkinstall;if run validparts;then run writeboot;\ + echo "Copying preloader and U-Boot";setenv partofs 0;setenv partlen 680;run writepart;\ + echo "Copying FAT boot partition";setenv partofs ${part2_start};setenv partlen ${part2_len};run writepart;\ + echo "Copying root partition";setenv partofs ${part3_start};setenv partlen ${part3_len};run writepart;\ + echo "Installed OpenWrt to eMMC";setenv bootedfrom eMMC;run runbootmenu;fi From e19ffb25d97e3859693c6d4582caf32e45265aa7 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sun, 14 Jun 2020 14:20:36 +0100 Subject: [PATCH 52/55] mediatek: store MAC address in boot partition on Banana Pi R2 Like many boards, the Banana Pi R2 doesn't have permanant storage of its MAC address, and we store the first random one that the kernel generates in order to use it later and at least be consistent. Store it in the FAT boot partition, just as the U7623 board (and others) do. Signed-off-by: David Woodhouse --- .../base-files/lib/preinit/07_set_iface_mac | 59 +++++++++++-------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac b/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac index f64458526f..60b699d9c9 100644 --- a/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac +++ b/target/linux/mediatek/mt7623/base-files/lib/preinit/07_set_iface_mac @@ -1,23 +1,19 @@ # Copyright (C) 2018 OpenWrt.org -RECOVERY_PART=/dev/mmcblk0p1 +. /lib/functions.sh +. /lib/functions/system.sh -preinit_set_mac_address() { +set_recovery_mac_address() { + local RECOVERY_PART="$1" local mac - . /lib/functions.sh - . /lib/functions/system.sh - - case $(board_name) in - unielec,u7623-02-emmc-512m) - if [ -b $RECOVERY_PART ]; then - insmod nls_cp437 - insmod nls_iso8859-1 - insmod fat - insmod vfat - mkdir -p /tmp/recovery - mount -o rw,noatime $RECOVERY_PART /tmp/recovery - + if [ -b $RECOVERY_PART ]; then + insmod nls_cp437 + insmod nls_iso8859-1 + insmod fat + insmod vfat + mkdir -p /tmp/recovery + if mount -o rw,noatime $RECOVERY_PART -t vfat /tmp/recovery; then if [ -f "/tmp/recovery/mac_addr" ]; then mac=$(cat /tmp/recovery/mac_addr) @@ -28,17 +24,34 @@ preinit_set_mac_address() { sync umount /tmp/recovery - rm -rf /tmp/recovery + rmdir /tmp/recovery + + ip link set dev wan address $mac 2> /dev/null + + mac=$(macaddr_add $mac 1) + + ip link set dev lan0 address $mac 2>/dev/null + ip link set dev lan1 address $mac 2>/dev/null + ip link set dev lan2 address $mac 2>/dev/null + ip link set dev lan3 address $mac 2>/dev/null fi + fi +} - ip link set dev wan address $mac 2> /dev/null +preinit_set_mac_address() { + local rootpart - mac=$(macaddr_add $mac 1) - - ip link set dev lan0 address $mac 2>/dev/null - ip link set dev lan1 address $mac 2>/dev/null - ip link set dev lan2 address $mac 2>/dev/null - ip link set dev lan3 address $mac 2>/dev/null + case $(board_name) in + bananapi,bpi-r2) + rootpart=$(cat /proc/cmdline) + rootpart="${rootpart##*root=}" + rootpart="${rootpart%%p3 *}" + if [ "$rootpart" = "/dev/mmcblk0" -o "$rootpart" = "/dev/mmcblk1" ]; then + set_recovery_mac_address ${rootpart}p2 + fi + ;; + unielec,u7623-02-emmc-512m) + set_recovery_mac_address /dev/mmcblk0p1 ;; esac } From af9932c9b7b94417d46ba59439793514e93ba8a6 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Mon, 15 Jun 2020 17:48:19 +0100 Subject: [PATCH 53/55] mediatek: Implement sysupgrade support for Banana Pi R2 Based on work by Alexey Loukianov and others. Signed-off-by: David Woodhouse --- target/linux/mediatek/image/Config.in | 2 +- .../base-files/lib/preinit/79_move_config | 20 ++- .../mt7623/base-files/lib/upgrade/platform.sh | 118 ++++++++++++++++-- 3 files changed, 128 insertions(+), 12 deletions(-) diff --git a/target/linux/mediatek/image/Config.in b/target/linux/mediatek/image/Config.in index f32f83c321..0e5449e2f9 100644 --- a/target/linux/mediatek/image/Config.in +++ b/target/linux/mediatek/image/Config.in @@ -1,4 +1,4 @@ config BANANA_PI_BOOT_PARTSIZE int "Boot (SD Card) filesystem partition size (in MiB)" - depends on TARGET_mediatek_mt7623_DEVICE_bpi_bananapi-r2 + depends on TARGET_mediatek_mt7623_DEVICE_bpi_bananapi-r2 || TARGET_DEVICE_mediatek_mt7623_DEVICE_bpi_bananapi-r2 default 32 diff --git a/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config b/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config index 895240a3bc..cbb6c604c8 100644 --- a/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config +++ b/target/linux/mediatek/mt7623/base-files/lib/preinit/79_move_config @@ -2,16 +2,28 @@ . /lib/upgrade/common.sh -RECOVERY_PART=/dev/mmcblk0p1 - move_config() { - if [ -b $RECOVERY_PART ]; then + local partdev partnum + + case $(board_name) in + bananapi,bpi-r2) + partnum=2 + ;; + unielec,u7623-02-emmc-512m) + partnum=1 + ;; + *) + return 1 + ;; + esac + + if export_bootdevice && export_partdevice partdev $partnum; then insmod nls_cp437 insmod nls_iso8859-1 insmod fat insmod vfat mkdir -p /recovery - mount -o rw,noatime $RECOVERY_PART /recovery + mount -o rw,noatime "/dev/$partdev" -t vfat /recovery [ -f "/recovery/$BACKUP_FILE" ] && mv -f "/recovery/$BACKUP_FILE" / umount /recovery fi diff --git a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh index 225fec0bca..2b37846456 100755 --- a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh @@ -2,6 +2,75 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in + bananapi,bpi-r2) + local diskdev partdev diff + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + #Keep the persistent random mac address (if it exists) + mkdir -p /tmp/recovery + export_partdevice recoverydev 2 + if mount -o rw,noatime "/dev/$recoverydev" -tvfat /tmp/recovery; then + [ -f "/tmp/recovery/mac_addr" ] && cp /tmp/recovery/mac_addr /tmp/ + umount /tmp/recovery + fi + sync + + if [ "$SAVE_PARTITIONS" = "1" ]; then + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + else + diff=1 + fi + + if [ -n "$diff" ]; then + get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync + + # Separate removal and addtion is necessary; otherwise, partition 1 + # will be missing if it overlaps with the old partition 2 + partx -d - "/dev/$diskdev" + partx -a - "/dev/$diskdev" + else + #iterate over each partition from the image and write it to the boot disk + while read part start size; do + part="$(($part - 2))" + if export_partdevice partdev $part; then + echo "Writing image to /dev/$partdev..." + get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync + else + echo "Unable to find partition $part device, skipped." + fi + done < /tmp/partmap.image + + #copy partition uuid + echo "Writing new UUID to /dev/$diskdev..." + get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync + fi + + if mount -o rw,noatime "/dev/$recoverydev" -t vfat /tmp/recovery; then + [ -f "/tmp/mac_addr" ] && cp /tmp/mac_addr /tmp/recovery + + if [ "$diskdev" = "mmcblk0" -a -r /tmp/recovery/eMMCboot.bin ]; then + echo 0 > /sys/block/mmcblk0boot0/force_ro + dd if=/tmp/recovery/eMMCboot.bin of=/dev/mmcblk0boot0 conv=fsync + sync + echo 1 > /sys/block/mmcblk0boot0/force_ro + fi + sync + umount /tmp/recovery + fi + ;; + unielec,u7623-02-emmc-512m) #Keep the persisten random mac address (if it exists) mkdir -p /tmp/recovery @@ -30,11 +99,39 @@ PART_NAME=firmware platform_check_image() { local board=$(board_name) local magic="$(get_magic_long "$1")" + local diskdev partdev diff [ "$#" -gt 1 ] && return 1 case "$board" in - bananapi,bpi-r2|\ + bananapi,bpi-r2) + [ "$magic" != "53444d4d" ] && { + echo "Invalid image type." + return 1 + } + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + get_partitions "/dev/$diskdev" bootdisk + + #extract the boot sector from the image + get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b 2>/dev/null + + get_partitions /tmp/image.bs image + + #compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + + rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image + + if [ -n "$diff" ]; then + echo "Partition layout has changed. Full image will be written." + ask_bool 0 "Abort" && exit 1 + return 0 + fi + ;; unielec,u7623-02-emmc-512m) [ "$magic" != "27051956" ] && { echo "Invalid image type." @@ -52,17 +149,24 @@ platform_check_image() { } platform_copy_config_emmc() { - mkdir -p /recovery - mount -o rw,noatime /dev/mmcblk0p1 /recovery - cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE" - sync - umount /recovery + local partdev + + if export_bootdevice && export_partdevice partdev $1; then + mkdir -p /recovery + mount -o rw,noatime "/dev/$partdev" -t vfat /recovery + cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE" + sync + umount /recovery + fi } platform_copy_config() { case "$(board_name)" in + bananapi,bpi-r2) + platform_copy_config_emmc 2 + ;; unielec,u7623-02-emmc-512m) - platform_copy_config_emmc + platform_copy_config_emmc 1 ;; esac } From dc61e3b7ffdc2e3873af238a9100d44ee685578c Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Sat, 25 Jan 2020 23:06:07 +0900 Subject: [PATCH 54/55] base-files: add functions to set or clear bit in MAC address Some devices (e.g. Arduino Yun) need bitwise operations during MAC address setup. This commit adds generalized versions of macaddr_setbit_la(), which are helpful when manipulating a single bit in a MAC address. Signed-off-by: Sungbo Eo --- .../base-files/files/lib/functions/system.sh | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh index c7aa7bf75c..f3c901ff79 100644 --- a/package/base-files/files/lib/functions/system.sh +++ b/package/base-files/files/lib/functions/system.sh @@ -152,10 +152,26 @@ macaddr_geteui() { echo ${mac:9:2}$sep${mac:12:2}$sep${mac:15:2} } -macaddr_setbit_la() { +macaddr_setbit() { local mac=$1 + local bit=${2:-0} - printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} + [ $bit -gt 0 -a $bit -le 48 ] || return + + printf "%012x" $(( 0x${mac//:/} | 2**(48-bit) )) | sed -e 's/\(.\{2\}\)/\1:/g' -e 's/:$//' +} + +macaddr_unsetbit() { + local mac=$1 + local bit=${2:-0} + + [ $bit -gt 0 -a $bit -le 48 ] || return + + printf "%012x" $(( 0x${mac//:/} & ~(2**(48-bit)) )) | sed -e 's/\(.\{2\}\)/\1:/g' -e 's/:$//' +} + +macaddr_setbit_la() { + macaddr_setbit $1 7 } macaddr_2bin() { From 358aec77756d6bf850a533272f2685a45220dc0c Mon Sep 17 00:00:00 2001 From: Sungbo Eo Date: Sun, 12 Jan 2020 21:36:23 +0900 Subject: [PATCH 55/55] ath79: add support for Arduino Yun Arduino Yun is a microcontroller development board, based on Atmel ATmega32u4 and Atheros AR9331. Specifications: - MCU: ATmega32U4 - SoC: AR9331 - RAM: DDR2 64MB - Flash: SPI NOR 16MB - WiFi: - 2.4GHz: SoC internal - Ethernet: 1x 10/100Mbps - USB: 1x 2.0 - MicroSD: 1x SDHC Notes: - Stock firmware is based on OpenWrt AA. - The SoC UART can be accessed only through the MCU. YunSerialTerminal is recommended for access to serial console. - Stock firmware uses non-standard 250000 baudrate by default. - The MCU can be reprogrammed from the SoC with avrdude linuxgpio. Installation: 1. Update U-Boot environment variables to adapt to new partition scheme. > setenv bootcmd "run addboard; run addtty; run addparts; run addrootfs; bootm 0x9f050000 || bootm 0x9fea0000" > setenv mtdparts "spi0.0:256k(u-boot)ro,64k(u-boot-env),15936k(firmware),64k(nvram),64k(art)ro" > saveenv 2. Boot into stock firmware normally and perform sysupgrade with sysupgrade image. # sysupgrade -n -F /tmp/sysupgrade.bin Signed-off-by: Sungbo Eo --- package/boot/uboot-envtools/files/ath79 | 1 + target/linux/ath79/dts/ar9331_arduino_yun.dts | 223 ++++++++++++++++++ .../generic/base-files/etc/board.d/02_network | 6 + .../etc/uci-defaults/04_led_migration | 3 + target/linux/ath79/image/generic.mk | 11 + ...support-for-boot-console-with-arbitr.patch | 54 +++++ ...support-for-boot-console-with-arbitr.patch | 54 +++++ 7 files changed, 352 insertions(+) create mode 100644 target/linux/ath79/dts/ar9331_arduino_yun.dts create mode 100644 target/linux/ath79/patches-4.19/921-serial-core-add-support-for-boot-console-with-arbitr.patch create mode 100644 target/linux/ath79/patches-5.4/921-serial-core-add-support-for-boot-console-with-arbitr.patch diff --git a/package/boot/uboot-envtools/files/ath79 b/package/boot/uboot-envtools/files/ath79 index 3754b521a4..5f5a448861 100644 --- a/package/boot/uboot-envtools/files/ath79 +++ b/package/boot/uboot-envtools/files/ath79 @@ -14,6 +14,7 @@ board=$(board_name) case "$board" in alfa-network,ap121f|\ +arduino,yun|\ buffalo,bhr-4grv2|\ devolo,magic-2-wifi|\ engenius,ecb1750|\ diff --git a/target/linux/ath79/dts/ar9331_arduino_yun.dts b/target/linux/ath79/dts/ar9331_arduino_yun.dts new file mode 100644 index 0000000000..0237fe58bf --- /dev/null +++ b/target/linux/ath79/dts/ar9331_arduino_yun.dts @@ -0,0 +1,223 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include +#include + +#include "ar9331.dtsi" + +/ { + model = "Arduino Yun"; + compatible = "arduino,yun", "qca,ar9331"; + + aliases { + serial0 = &uart; + }; + + chosen { + bootargs = "console=ttyATH0,250000"; + }; + + ahb { + apb { + pinmux_extended: pinmux@18040030 { + compatible = "pinctrl-single"; + reg = <0x18040030 0x4>; + + pinctrl-single,bit-per-mux; + pinctrl-single,register-width = <32>; + pinctrl-single,function-mask = <0x1>; + #pinctrl-cells = <2>; + + enable_gpio11: pinmux_enable_gpio11 { + pinctrl-single,bits = <0x0 0x200 0x200>; + }; + }; + + pinmux_bootstrap: pinmux@180600ac { + compatible = "pinctrl-single"; + reg = <0x180600ac 0x4>; + + pinctrl-single,bit-per-mux; + pinctrl-single,register-width = <32>; + pinctrl-single,function-mask = <0x1>; + #pinctrl-cells = <2>; + + enable_gpio26_gpio27: pinmux_enable_gpio26_gpio27 { + pinctrl-single,bits = <0x0 0x40000 0x40000>; + }; + }; + }; + }; + + leds { + compatible = "gpio-leds"; + + wlan { + label = "yun:blue:wlan"; + gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0tpt"; + }; + + usb { + label = "yun:white:usb"; + gpios = <&gpio 1 GPIO_ACTIVE_HIGH>; + trigger-sources = <&hub_port1>; + linux,default-trigger = "usbport"; + }; + }; + + keys { + compatible = "gpio-keys"; + + config { + label = "config"; + linux,code = ; + gpios = <&gpio 20 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-export { + compatible = "gpio-export"; + + gpio_spi_enable { + gpio-export,name = "yun:oe:spi"; + gpio-export,output = <0>; + gpios = <&gpio 21 GPIO_ACTIVE_HIGH>; + }; + + gpio_handshake_enable { + gpio-export,name = "yun:oe:hs"; + gpio-export,output = <0>; + gpios = <&gpio 22 GPIO_ACTIVE_HIGH>; + }; + + gpio_uart_enable { + gpio-export,name = "yun:oe:uart"; + gpio-export,output = <0>; + gpios = <&gpio 23 GPIO_ACTIVE_LOW>; + }; + }; + + reg_usb_vbus: reg_usb_vbus { + compatible = "regulator-fixed"; + regulator-name = "usb_vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + enable-active-high; + }; +}; + +&uart { + status = "okay"; +}; + +&gpio { + status = "okay"; +}; + +&pinmux { + pinctrl-names = "default"; + pinctrl-0 = <&jtag_disable_pins &switch_led_disable_pins>; +}; + +&switch_led_disable_pins { + pinctrl-single,bits = <0x0 0x80 0xf8>; +}; + +&pinmux_extended { + pinctrl-names = "default"; + pinctrl-0 = <&enable_gpio11>; +}; + +&pinmux_bootstrap { + pinctrl-names = "default"; + pinctrl-0 = <&enable_gpio26_gpio27>; +}; + +&usb { + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + dr_mode = "host"; + vbus-supply = <®_usb_vbus>; + + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + #trigger-source-cells = <0>; + + hub_port1: port@1 { + reg = <1>; + #trigger-source-cells = <0>; + }; + }; +}; + +&usb_phy { + status = "okay"; +}; + +&spi { + status = "okay"; + + num-cs = <1>; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <50000000>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x40000>; + read-only; + }; + + partition@40000 { + label = "u-boot-env"; + reg = <0x40000 0x10000>; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xf90000>; + }; + + partition@fe0000 { + label = "nvram"; + reg = <0xfe0000 0x10000>; + }; + + art: partition@ff0000 { + label = "art"; + reg = <0xff0000 0x10000>; + read-only; + }; + }; + }; +}; + +ð0 { + status = "okay"; +}; + +ð1 { + status = "okay"; + + compatible = "syscon", "simple-mfd"; +}; + +&wmac { + status = "okay"; + + mtd-cal-data = <&art 0x1000>; +}; diff --git a/target/linux/ath79/generic/base-files/etc/board.d/02_network b/target/linux/ath79/generic/base-files/etc/board.d/02_network index 4580f3ab4e..eb43788fce 100755 --- a/target/linux/ath79/generic/base-files/etc/board.d/02_network +++ b/target/linux/ath79/generic/base-files/etc/board.d/02_network @@ -12,6 +12,7 @@ ath79_setup_interfaces() adtran,bsap1800-v2|\ adtran,bsap1840|\ alfa-network,ap121f|\ + arduino,yun|\ aruba,ap-105|\ avm,fritz1750e|\ avm,fritz300e|\ @@ -361,6 +362,11 @@ ath79_setup_macs() alfa-network,ap121f) label_mac=$(mtd_get_mac_binary art 0x1002) ;; + arduino,yun) + base_mac=$(mtd_get_mac_binary art 0x1002) + lan_mac=$(macaddr_setbit $base_mac 29) + [ $lan_mac = $base_mac ] && lan_mac=$(macaddr_unsetbit $base_mac 29) + ;; avm,fritz1750e|\ avm,fritz450e|\ avm,fritzdvbc) diff --git a/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration b/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration index 757b0c9974..23a9c8282f 100644 --- a/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration +++ b/target/linux/ath79/generic/base-files/etc/uci-defaults/04_led_migration @@ -5,6 +5,9 @@ board=$(board_name) boardonly="${board##*,}" case "$board" in +arduino,yun) + migrate_leds "arduino:=yun:" + ;; engenius,epg5000) migrate_leds ":wlan-2g=:wlan2g" ":wlan-5g=:wlan5g" ;; diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk index 14e72140dc..46a8705b85 100644 --- a/target/linux/ath79/image/generic.mk +++ b/target/linux/ath79/image/generic.mk @@ -210,6 +210,17 @@ define Device/alfa-network_ap121f endef TARGET_DEVICES += alfa-network_ap121f +define Device/arduino_yun + SOC := ar9331 + DEVICE_VENDOR := Arduino + DEVICE_MODEL := Yun + DEVICE_PACKAGES := kmod-usb2 kmod-usb-chipidea2 kmod-usb-ledtrig-usbport \ + kmod-usb-storage block-mount -swconfig + IMAGE_SIZE := 15936k + SUPPORTED_DEVICES += arduino-yun +endef +TARGET_DEVICES += arduino_yun + define Device/aruba_ap-105 SOC := ar7161 DEVICE_VENDOR := Aruba diff --git a/target/linux/ath79/patches-4.19/921-serial-core-add-support-for-boot-console-with-arbitr.patch b/target/linux/ath79/patches-4.19/921-serial-core-add-support-for-boot-console-with-arbitr.patch new file mode 100644 index 0000000000..f726b05200 --- /dev/null +++ b/target/linux/ath79/patches-4.19/921-serial-core-add-support-for-boot-console-with-arbitr.patch @@ -0,0 +1,54 @@ +From 4d3c17975c7814884a721fe693b3adf5c426d759 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Tue, 10 Nov 2015 22:18:39 +0100 +Subject: [RFC] serial: core: add support for boot console with arbitrary + baud rates + +The Arduino Yun uses a baud rate of 250000 by default. The serial is +going over the Atmel ATmega and is used to connect to this chip. +Without this patch Linux wants to switch the console to 9600 Baud. + +With this patch Linux will use the configured baud rate and not a +default one specified in uart_register_driver(). + +Signed-off-by: Hauke Mehrtens +[rebased to 4.14, slightly reworded commit message] +Signed-off-by: Sungbo Eo +--- + drivers/tty/serial/serial_core.c | 6 +++++- + include/linux/console.h | 1 + + 2 files changed, 6 insertions(+), 1 deletions(-) + +--- a/drivers/tty/serial/serial_core.c ++++ b/drivers/tty/serial/serial_core.c +@@ -219,6 +219,8 @@ static int uart_port_startup(struct tty_ + if (retval == 0) { + if (uart_console(uport) && uport->cons->cflag) { + tty->termios.c_cflag = uport->cons->cflag; ++ tty->termios.c_ospeed = uport->cons->baud; ++ tty->termios.c_ispeed = uport->cons->baud; + uport->cons->cflag = 0; + } + /* +@@ -2058,8 +2060,10 @@ uart_set_options(struct uart_port *port, + * Allow the setting of the UART parameters with a NULL console + * too: + */ +- if (co) ++ if (co) { + co->cflag = termios.c_cflag; ++ co->baud = baud; ++ } + + return 0; + } +--- a/include/linux/console.h ++++ b/include/linux/console.h +@@ -153,6 +153,7 @@ struct console { + short flags; + short index; + int cflag; ++ int baud; + void *data; + struct console *next; + }; diff --git a/target/linux/ath79/patches-5.4/921-serial-core-add-support-for-boot-console-with-arbitr.patch b/target/linux/ath79/patches-5.4/921-serial-core-add-support-for-boot-console-with-arbitr.patch new file mode 100644 index 0000000000..dc863a511b --- /dev/null +++ b/target/linux/ath79/patches-5.4/921-serial-core-add-support-for-boot-console-with-arbitr.patch @@ -0,0 +1,54 @@ +From 4d3c17975c7814884a721fe693b3adf5c426d759 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Tue, 10 Nov 2015 22:18:39 +0100 +Subject: [RFC] serial: core: add support for boot console with arbitrary + baud rates + +The Arduino Yun uses a baud rate of 250000 by default. The serial is +going over the Atmel ATmega and is used to connect to this chip. +Without this patch Linux wants to switch the console to 9600 Baud. + +With this patch Linux will use the configured baud rate and not a +default one specified in uart_register_driver(). + +Signed-off-by: Hauke Mehrtens +[rebased to 4.14, slightly reworded commit message] +Signed-off-by: Sungbo Eo +--- + drivers/tty/serial/serial_core.c | 6 +++++- + include/linux/console.h | 1 + + 2 files changed, 6 insertions(+), 1 deletions(-) + +--- a/drivers/tty/serial/serial_core.c ++++ b/drivers/tty/serial/serial_core.c +@@ -220,6 +220,8 @@ static int uart_port_startup(struct tty_ + if (retval == 0) { + if (uart_console(uport) && uport->cons->cflag) { + tty->termios.c_cflag = uport->cons->cflag; ++ tty->termios.c_ospeed = uport->cons->baud; ++ tty->termios.c_ispeed = uport->cons->baud; + uport->cons->cflag = 0; + } + /* +@@ -2104,8 +2106,10 @@ uart_set_options(struct uart_port *port, + * Allow the setting of the UART parameters with a NULL console + * too: + */ +- if (co) ++ if (co) { + co->cflag = termios.c_cflag; ++ co->baud = baud; ++ } + + return 0; + } +--- a/include/linux/console.h ++++ b/include/linux/console.h +@@ -153,6 +153,7 @@ struct console { + short flags; + short index; + int cflag; ++ int baud; + void *data; + struct console *next; + };