From b20b997c680e38f999e4608b158ef08718527ca0 Mon Sep 17 00:00:00 2001 From: Russell Senior Date: Tue, 12 Nov 2019 15:33:48 -0800 Subject: [PATCH 1/8] base-files: add /usr/share/libubox/jshn.sh to sysupgrade stage2 Discovered recent changes had broken sysupgrade for ar71xx mikrotik rb-493g, traced the problem to missing /usr/share/libubox/jshn.sh after switching to tmpfs. Signed-off-by: Russell Senior --- package/base-files/files/lib/upgrade/stage2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2 index 5d3d46ee80..41a3b2aeb3 100755 --- a/package/base-files/files/lib/upgrade/stage2 +++ b/package/base-files/files/lib/upgrade/stage2 @@ -48,7 +48,7 @@ switch_to_ramfs() { local file="$(which "$binary" 2>/dev/null)" [ -n "$file" ] && install_bin "$file" done - install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh /lib/upgrade/do_stage2 $RAMFS_COPY_DATA + install_file /etc/resolv.conf /lib/*.sh /lib/functions/*.sh /lib/upgrade/*.sh /lib/upgrade/do_stage2 /usr/share/libubox/jshn.sh $RAMFS_COPY_DATA [ -L "/lib64" ] && ln -s /lib $RAM_ROOT/lib64 From bc173ddd8381b03dde8cc2e6c66d0cd392c62bbd Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Tue, 29 Oct 2019 23:25:56 +0100 Subject: [PATCH 2/8] ramips: support dual image feature on ALFA Network boards New U-Boot version for MediaTek MT76x8/MT762x based ALFA Network boards includes support for a 'dual image' feature. Users can enable it using U-Boot environment variable 'dual_image' ('1' -> enabled). When 'dual image' feature is enabled, U-Boot will modify DTB and divide the original 'firmware' flash area into two, equal in size and aligned to 64 KB partitions: 'firmware' and 'backup'. U-Boot will also adjust size of 'firmware' area to match installed flash chip size. U-Boot will load kernel from active partition which is marked with env variable 'bootactive' ('1' -> first partition, '2' -> second partition) and rename both partitions accordingly ('firmware' <-> 'backup'). There are 3 additional env variables used to control 'dual image' mode: - bootlimit - maximum number of unsuccessful boot tries (default: '3') - bootcount - current number of boot tries - bootchanged - flag which informs that active partition was changed; if it is set and 'bootcount' reaches 'bootlimit' value, U-Boot will start web-based recovery which then updates both partitions with provided image Signed-off-by: Piotr Dymacz --- .../mt7620/base-files/etc/init.d/bootcount | 13 +++++++++++++ .../mt7620/base-files/lib/upgrade/platform.sh | 16 ++++++++++++++++ .../mt76x8/base-files/etc/init.d/bootcount | 4 ++++ .../mt76x8/base-files/lib/upgrade/platform.sh | 15 +++++++++++++++ 4 files changed, 48 insertions(+) create mode 100755 target/linux/ramips/mt7620/base-files/etc/init.d/bootcount diff --git a/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount new file mode 100755 index 0000000000..c7b6919926 --- /dev/null +++ b/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount @@ -0,0 +1,13 @@ +#!/bin/sh /etc/rc.common + +START=99 + +boot() { + case $(board_name) in + alfa-network,ac1200rm|\ + alfa-network,tube-e4g) + [ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\ + echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - + ;; + esac +} diff --git a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh index 786d57fc70..aad243c1f9 100755 --- a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh @@ -5,6 +5,9 @@ PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 +RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + platform_check_image() { return 0 } @@ -13,6 +16,19 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in + alfa-network,ac1200rm|\ + alfa-network,tube-e4g) + [ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\ + [ -n "$(find_mtd_part backup)" ] && { + PART_NAME=backup + if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then + fw_setenv bootactive 2 || exit 1 + else + fw_setenv bootactive 1 || exit 1 + fi + } + default_do_upgrade "$1" + ;; *) default_do_upgrade "$1" ;; diff --git a/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount b/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount index 0d64deb9e0..3c21433cc5 100755 --- a/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount @@ -4,6 +4,10 @@ START=99 boot() { case $(board_name) in + alfa-network,awusfree1) + [ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\ + echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - + ;; xiaomi,miwifi-nano) fw_setenv flag_boot_success 1 ;; diff --git a/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh index 606a9f2bf6..a3de97abf7 100755 --- a/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt76x8/base-files/lib/upgrade/platform.sh @@ -5,6 +5,9 @@ PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 +RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + platform_check_image() { return 0 } @@ -13,6 +16,18 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in + alfa-network,awusfree1) + [ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\ + [ -n "$(find_mtd_part backup)" ] && { + PART_NAME=backup + if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then + fw_setenv bootactive 2 || exit 1 + else + fw_setenv bootactive 1 || exit 1 + fi + } + default_do_upgrade "$1" + ;; tplink,archer-c50-v4) MTD_ARGS="-t romfile" default_do_upgrade "$1" From dfecf94c2059998411f95067de3866aa7cdf5ec9 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Wed, 30 Oct 2019 00:10:40 +0100 Subject: [PATCH 3/8] ramips: add support for ALFA Network R36M-E4G ALFA Network R36M-E4G is a dual-SIM, N300 Wi-Fi, compact size platform based on MediaTek MT7620A WiSoC. This product is designed for operation with 4G modem (can be bought in bundle with Quectel EC25, EG25 or EP06) but supports also Wi-Fi modules (miniPCIe slot has USB and PCIe buses). Specification: - MT7620A (580 MHz) - 64/128/256 MB of RAM (DDR2) - 16/32+ MB of FLASH (SPI NOR) - 2x 10/100 Mbps Ethernet, with passive PoE support (24 V) - 2T2R 2.4 GHz (MT7620A), with ext. LNA (RFFM4227) - 1x miniPCIe slot (with PCIe and USB 2.0 buses and optional 5 V) - 2x SIM slot (mini, micro) with detect and switch driven by GPIO - 2x u.fl antenna connectors (for Wi-Fi) - 8x LED (7 driven by GPIO) - 2x button (reset, wifi) - 2x UART (4-pin/2.54 mm pitch, 10-pin/1.27 mm pitch) headers on PCB - 1x I2C (4-pin, 1.27 mm pitch) header on PCB - 1x LED (8-pin, 1.27 mm pitch) header on PCB - 1x DC jack with lock (12 V) Other: - there is a dedicated, 4-pin connector for optional RTC module (Holtek HT138x) with 'enable' input, not available at the time of preparing support for this board - miniPCIe slot supports additional 5 V supply on pins 47 and 49 but a jumper resistor (R174) is not installed by default - U-Boot selects default SIM slot, based on value of 'default_sim' env variable: '1' or unset -> SIM1 (mini), '2' -> SIM2 (micro). This will work only if both slots are occupied, otherwise U-Boot will always select slot with SIM card inside (user can override it later, in user-space) - U-Boot resets the modem, using PERSTn signal, before starting kernel - this board supports 'dual image' feature (controlled by 'dual_image' U-Boot environment variable) Flash instruction: You can use the 'sysupgrade' image directly in vendor firmware which is based on OpenWrt (make sure to not preserve settings - use 'sysupgrade -n -F ...' command). Alternatively, use web recovery mode in U-Boot: 1. Power the device with reset button pressed, the modem LED will start blinking slowly and after ~3 seconds, when it starts blinking faster, you can release the button. 2. Setup static IP 192.168.1.2/24 on your PC. 3. Go to 192.168.1.1 in browser and upload 'sysupgrade' image. Signed-off-by: Piotr Dymacz --- .../dts/mt7620a_alfa-network_r36m-e4g.dts | 218 ++++++++++++++++++ target/linux/ramips/image/mt7620.mk | 9 + .../mt7620/base-files/etc/board.d/01_leds | 5 + .../mt7620/base-files/etc/board.d/02_network | 18 +- .../mt7620/base-files/etc/init.d/bootcount | 1 + .../mt7620/base-files/lib/upgrade/platform.sh | 1 + 6 files changed, 244 insertions(+), 8 deletions(-) create mode 100644 target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts b/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts new file mode 100644 index 0000000000..ce839f72f1 --- /dev/null +++ b/target/linux/ramips/dts/mt7620a_alfa-network_r36m-e4g.dts @@ -0,0 +1,218 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7620a.dtsi" + +#include +#include + +/ { + compatible = "alfa-network,r36m-e4g", "ralink,mt7620a-soc"; + model = "ALFA Network R36M-E4G"; + + aliases { + label-mac-device = &wmac; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + chosen { + bootargs = "console=ttyS1,115200"; + }; + + gpio-export { + compatible = "gpio-export"; + #size-cells = <0>; + + modem-enable { + gpio-export,name = "modem-enable"; + gpio-export,output = <1>; + gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + }; + + modem-rf-enable { + gpio-export,name = "modem-rf-enable"; + gpio-export,output = <1>; + gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>; + }; + + rtc-enable { + gpio-export,name = "rtc-enable"; + gpio-export,output = <1>; + gpio-export,direction_may_change = <1>; + gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>; + }; + + sim-select { + gpio-export,name = "sim-select"; + gpio-export,output = <0>; + gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>; + }; + + sim1-detect { + gpio-export,name = "sim1-detect"; + gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + }; + + sim2-detect { + gpio-export,name = "sim2-detect"; + gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + rfkill { + label = "rfkill"; + gpios = <&gpio1 7 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + 4g { + label = "r36m-e4g:orange:4g"; + gpios = <&gpio1 3 GPIO_ACTIVE_LOW>; + }; + + lan { + label = "r36m-e4g:green:lan"; + gpios = <&gpio2 3 GPIO_ACTIVE_LOW>; + }; + + led_system: system { + label = "r36m-e4g:green:system"; + gpios = <&gpio2 0 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + sim1 { + label = "r36m-e4g:green:sim1"; + gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + sim2 { + label = "r36m-e4g:green:sim2"; + gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + wan { + label = "r36m-e4g:green:wan"; + gpios = <&gpio2 4 GPIO_ACTIVE_LOW>; + }; + + wlan { + label = "r36m-e4g:orange:wlan"; + gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0radio"; + }; + }; +}; + +&ehci { + status = "okay"; +}; + +ðernet { + mtd-mac-address = <&factory 0x28>; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio3 { + status = "okay"; +}; + +&gsw { + mediatek,port4 = "ephy"; +}; + +&i2c { + status = "okay"; +}; + +&ohci { + status = "okay"; +}; + +&pinctrl { + state_default: pinctrl0 { + gpio { + ralink,group = "ephy", "pcie", "rgmii1", "wled"; + ralink,function = "gpio"; + }; + }; +}; + +&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 = "u-boot"; + reg = <0x0 0x30000>; + read-only; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x1000>; + }; + + partition@31000 { + label = "config"; + reg = <0x31000 0xf000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xfb0000>; + }; + }; + }; +}; + +&uart { + status = "okay"; +}; + +&wmac { + ralink,mtd-eeprom = <&factory 0>; +}; diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk index d3de3074b2..8aea7f05f1 100644 --- a/target/linux/ramips/image/mt7620.mk +++ b/target/linux/ramips/image/mt7620.mk @@ -35,6 +35,15 @@ define Device/alfa-network_ac1200rm endef TARGET_DEVICES += alfa-network_ac1200rm +define Device/alfa-network_r36m-e4g + MTK_SOC := mt7620a + IMAGE_SIZE := 16064k + DEVICE_VENDOR := ALFA Network + DEVICE_MODEL := R36M-E4G + DEVICE_PACKAGES := kmod-i2c-ralink kmod-usb2 kmod-usb-ohci uboot-envtools uqmi +endef +TARGET_DEVICES += alfa-network_r36m-e4g + define Device/alfa-network_tube-e4g MTK_SOC := mt7620a IMAGE_SIZE := 16064k diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds index 59f0fe8dab..d88fdfb043 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds @@ -24,6 +24,11 @@ aigale,ai-br100) alfa-network,ac1200rm) set_wifi_led "$boardname:green:wlan2g" "wlan1" ;; +alfa-network,r36m-e4g) + ucidef_set_led_netdev "4g" "4g" "$boardname:orange:4g" "wwan0" + ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0" "0x8" + ucidef_set_led_switch "wan" "wan" "$boardname:green:wan" "switch0" "0x10" + ;; alfa-network,tube-e4g) ucidef_set_led_netdev "4g" "4g" "$boardname:green:4g" "wwan0" ucidef_set_led_netdev "lan" "lan" "$boardname:blue:lan" "eth0" diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network index 1b51f17485..12820f3a36 100755 --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network @@ -32,6 +32,11 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0" ;; + alfa-network,r36m-e4g|\ + zbtlink,zbt-we1026-h-32m) + ucidef_add_switch "switch0" \ + "3:lan" "4:wan" "6@eth0" + ;; alfa-network,tube-e4g|\ buffalo,wmr-300|\ dlink,dch-m225|\ @@ -190,10 +195,6 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "6t@eth0" ;; - zbtlink,zbt-we1026-h-32m) - ucidef_add_switch "switch0" \ - "3:lan" "4:wan" "6@eth0" - ;; zbtlink,zbt-we2026) ucidef_add_switch "switch0" \ "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan:5" "6@eth0" @@ -259,6 +260,11 @@ ramips_setup_macs() zbtlink,zbt-wr8305rt) wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) ;; + alfa-network,r36m-e4g|\ + zbtlink,zbt-we1026-h-32m) + wan_mac=$(mtd_get_mac_binary factory 0x2e) + label_mac=$(mtd_get_mac_binary factory 0x4) + ;; dlink,dch-m225) lan_mac=$(mtd_get_mac_ascii factory lanmac) ;; @@ -314,10 +320,6 @@ ramips_setup_macs() zbtlink,zbt-we1026-5g-16m) label_mac=$(mtd_get_mac_binary factory 0x4) ;; - zbtlink,zbt-we1026-h-32m) - wan_mac=$(mtd_get_mac_binary factory 0x2e) - label_mac=$(mtd_get_mac_binary factory 0x4) - ;; zyxel,keenetic-omni|\ zyxel,keenetic-omni-ii|\ zyxel,keenetic-viva) diff --git a/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount index c7b6919926..06316e48ca 100755 --- a/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7620/base-files/etc/init.d/bootcount @@ -5,6 +5,7 @@ START=99 boot() { case $(board_name) in alfa-network,ac1200rm|\ + alfa-network,r36m-e4g|\ alfa-network,tube-e4g) [ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\ echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - diff --git a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh index aad243c1f9..9f71dc918e 100755 --- a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh @@ -17,6 +17,7 @@ platform_do_upgrade() { case "$board" in alfa-network,ac1200rm|\ + alfa-network,r36m-e4g|\ alfa-network,tube-e4g) [ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\ [ -n "$(find_mtd_part backup)" ] && { From 3cfea3a32125a2c59dfaa9103804ad51609ebe9d Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Wed, 30 Oct 2019 21:48:09 +0100 Subject: [PATCH 4/8] uboot-envtools: ramips: add support for ALFA Network R36M-E4G Signed-off-by: Piotr Dymacz --- package/boot/uboot-envtools/files/ramips | 1 + 1 file changed, 1 insertion(+) diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 3612860f45..f6af232e96 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -15,6 +15,7 @@ board=$(board_name) case "$board" in alfa-network,ac1200rm|\ alfa-network,awusfree1|\ +alfa-network,r36m-e4g|\ alfa-network,tube-e4g) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000" ;; From fc0d0f5dfdfcc392e8009115a7ac3b500614f97c Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Wed, 30 Oct 2019 22:55:42 +0100 Subject: [PATCH 5/8] ramips: provide label MAC for ALFA Network Tube-E4G Signed-off-by: Piotr Dymacz --- target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts index 4097dc6140..b02b1629bb 100644 --- a/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts +++ b/target/linux/ramips/dts/mt7620a_alfa-network_tube-e4g.dts @@ -11,6 +11,7 @@ model = "ALFA Network Tube-E4G"; aliases { + label-mac-device = ðernet; led-boot = &power; led-failsafe = &power; led-running = &power; From 44d7a14a83dbe359593c5ae7e71513c3e596b6b8 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Fri, 1 Nov 2019 21:40:37 +0100 Subject: [PATCH 6/8] ramips: mt7621: refresh kernel config Signed-off-by: Piotr Dymacz --- target/linux/ramips/mt7621/config-4.14 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/mt7621/config-4.14 b/target/linux/ramips/mt7621/config-4.14 index a2c58e030b..a7276a301d 100644 --- a/target/linux/ramips/mt7621/config-4.14 +++ b/target/linux/ramips/mt7621/config-4.14 @@ -24,8 +24,6 @@ CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_BLK_MQ_PCI=y CONFIG_BOARD_SCACHE=y CONFIG_BOUNCE=y -CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y -# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set CONFIG_CEVT_R4K=y # CONFIG_CEVT_SYSTICK_QUIRK is not set CONFIG_CLKDEV_LOOKUP=y @@ -99,6 +97,7 @@ CONFIG_HAS_IOMEM=y CONFIG_HAS_IOPORT_MAP=y # CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set # CONFIG_HAVE_ARCH_BITREVERSE is not set +CONFIG_HAVE_ARCH_COMPILER_H=y CONFIG_HAVE_ARCH_JUMP_LABEL=y CONFIG_HAVE_ARCH_KGDB=y CONFIG_HAVE_ARCH_SECCOMP_FILTER=y @@ -155,6 +154,7 @@ CONFIG_MIGRATION=y CONFIG_MIPS=y CONFIG_MIPS_ASID_BITS=8 CONFIG_MIPS_ASID_SHIFT=0 +CONFIG_MIPS_CBPF_JIT=y CONFIG_MIPS_CLOCK_VSYSCALL=y CONFIG_MIPS_CM=y # CONFIG_MIPS_CMDLINE_BUILTIN_EXTEND is not set From e68539aca43a560077364de27eb220f1d85ca3ef Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Sun, 3 Nov 2019 12:12:44 +0100 Subject: [PATCH 7/8] ramips: add support for ALFA Network Quad-E4G ALFA Network Quad-E4G is a universal Wi-Fi/4G platform, which offers three miniPCIe (PCIe, USB 2.0, SIM) and a single M.2 B-key (dual-SIM, USB 3.0) slots, RTC and five Gigabit Ethernet ports with PoE support. Specification: - MT7621A (880 MHz) - 256/512 MB of RAM (DDR3) - 16/32+ MB of FLASH (SPI NOR) - optional second SPI flash (8-pin WSON/SOIC) - 1x microSD (SDXC) flash card reader - 5x 10/100/100 Mbps Ethernet, with passive PoE support (24 V) in LAN1 - optional 802.3at/af PoE module for WAN - 3x miniPCIe slot (with PCIe and USB 2.0 buses, micro SIM and 5 V) - 1x M.2/NGFF B-key 3042 (USB 3.0/2.0, mini + micro SIM) - RTC (TI BQ32002, I2C bus) with backup battery (CR2032) - external hardware watchdog (EM Microelectronic EM6324) - 1x USB 2.0 Type-A - 1x micro USB Type-B for system serial console (Holtek HT42B534) - 11x LED (5 for Ethernet, 5 driven by GPIO, 1x power indicator) - 3x button (reset, user1, user2) - 1x I2C (4-pin, 2.54 mm pitch) header on PCB - 4x SIM (6-pin, 2.00 mm pitch) headers on PCB - 2x UART2/3 (4-pin, 2.54 mm pitch) headers on PCB - 1x mechanical power switch - 1x DC jack with lock (24 V) Other: - U-Boot selects default SIM slot, based on value of 'default_sim' env variable: '1' or unset -> SIM1 (mini), '2' -> SIM2 (micro). This board has additional logic circuit for M.2 SIM switching. The 'sim-select' will work only if both SIM slots are occupied. Otherwise, always slot with SIM inside is selected, no matter 'sim-select' value. - U-Boot enables power in all three miniPCIe and M.2 slots before loading the kernel - this board supports 'dual image' feature (controlled by 'dual_image' U-Boot environment variable) - all three miniPCIe slots have additional 5 V supply on pins 47 and 49 - the board allows to install up to two oversized miniPCIe cards (vendor has dedicated MediaTek MT7615N/D cards for this board) - this board has additional logic circuit controlling PERSTn pins inside miniPCIe slots. By default, PERSTn (GPIO19) is routed to all miniPCIe slots but setting GPIO22 to high allows PERSTn control per slot, using GPIO23-25 (value is inverted) You can use the 'sysupgrade' image directly in vendor firmware which is based on OpenWrt (make sure to not preserve settings - use 'sysupgrade -n -F ...' command). Alternatively, use web recovery mode in U-Boot: 1. Power the device with reset button pressed, the modem LED will start blinking slowly and after ~3 seconds, when it starts blinking faster, you can release the button. 2. Setup static IP 192.168.1.2/24 on your PC. 3. Go to 192.168.1.1 in browser and upload 'sysupgrade' image. Signed-off-by: Piotr Dymacz --- .../dts/mt7621_alfa-network_quad-e4g.dts | 232 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 10 + .../mt7621/base-files/etc/board.d/02_network | 24 +- .../mt7621/base-files/etc/init.d/bootcount | 4 + .../mt7621/base-files/lib/upgrade/platform.sh | 14 ++ target/linux/ramips/mt7621/config-4.14 | 3 + 6 files changed, 276 insertions(+), 11 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_alfa-network_quad-e4g.dts diff --git a/target/linux/ramips/dts/mt7621_alfa-network_quad-e4g.dts b/target/linux/ramips/dts/mt7621_alfa-network_quad-e4g.dts new file mode 100644 index 0000000000..f3080c29e0 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_alfa-network_quad-e4g.dts @@ -0,0 +1,232 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/dts-v1/; + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "alfa-network,quad-e4g", "mediatek,mt7621-soc"; + model = "ALFA Network Quad-E4G"; + + aliases { + label-mac-device = ðernet; + led-boot = &led_system; + led-failsafe = &led_system; + led-running = &led_system; + led-upgrade = &led_system; + }; + + chosen { + bootargs = "console=ttyS0,115200"; + }; + + gpio-export { + compatible = "gpio-export"; + #size-cells = <0>; + + m2-enable { + gpio-export,name = "m2-enable"; + gpio-export,output = <1>; + gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>; + }; + + minipcie0-enable { + gpio-export,name = "minipcie0-enable"; + gpio-export,output = <1>; + gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + }; + + minipcie0-reset { + gpio-export,name = "minipcie0-reset"; + gpio-export,output = <0>; + gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>; + }; + + minipcie1-enable { + gpio-export,name = "minipcie1-enable"; + gpio-export,output = <1>; + gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; + }; + + minipcie1-reset { + gpio-export,name = "minipcie1-reset"; + gpio-export,output = <0>; + gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>; + }; + + minipcie2-enable { + gpio-export,name = "minipcie2-enable"; + gpio-export,output = <1>; + gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; + }; + + minipcie2-reset { + gpio-export,name = "minipcie2-reset"; + gpio-export,output = <0>; + gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>; + }; + + pcie-perst-disable { + gpio-export,name = "pcie-perst-enable"; + gpio-export,output = <0>; + gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>; + }; + + sim-select { + gpio-export,name = "sim-select"; + gpio-export,output = <1>; + gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; + }; + + watchdog-enable { + gpio-export,name = "watchdog-enable"; + gpio-export,output = <1>; + gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + }; + }; + + keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + gpios = <&gpio0 14 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + user1 { + label = "user1"; + gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + user2 { + label = "user2"; + gpios = <&gpio0 16 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_system: system { + label = "quad-e4g:red:system"; + gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + m2 { + label = "quad-e4g:orange:m2"; + gpios = <&gpio1 1 GPIO_ACTIVE_LOW>; + }; + + minipcie0 { + label = "quad-e4g:orange:minipcie0"; + gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; + }; + + minipcie1 { + label = "quad-e4g:orange:minipcie1"; + gpios = <&gpio0 27 GPIO_ACTIVE_LOW>; + }; + + minipcie2 { + label = "quad-e4g:orange:minipcie2"; + gpios = <&gpio0 28 GPIO_ACTIVE_LOW>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + hw_algo = "toggle"; + hw_margin_ms = <25000>; + always-running; + }; +}; + +ðernet { + mtd-mac-address = <&factory 0xe000>; +}; + +&i2c { + status = "okay"; + + rtc@68 { + compatible = "ti,bq32000"; + reg = <0x68>; + }; +}; + +&pcie { + status = "okay"; +}; + +&pinctrl { + state_default: pinctrl0 { + gpio { + ralink,group = "jtag", "rgmii2", "wdt"; + ralink,function = "gpio"; + }; + }; +}; + +&sdhci { + status = "okay"; +}; + +&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 = "u-boot"; + reg = <0x0 0x30000>; + }; + + partition@30000 { + label = "u-boot-env"; + reg = <0x30000 0x1000>; + }; + + partition@31000 { + label = "config"; + reg = <0x31000 0xf000>; + read-only; + }; + + factory: partition@40000 { + label = "factory"; + reg = <0x40000 0x10000>; + read-only; + }; + + partition@50000 { + compatible = "denx,uimage"; + label = "firmware"; + reg = <0x50000 0xfb0000>; + }; + }; + }; +}; + +&uartlite2 { + status = "okay"; +}; + +&uartlite3 { + status = "okay"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index a7c16b18eb..66afe29620 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -96,6 +96,16 @@ define Device/afoundry_ew1200 endef TARGET_DEVICES += afoundry_ew1200 +define Device/alfa-network_quad-e4g + MTK_SOC := mt7621 + IMAGE_SIZE := 16064k + DEVICE_VENDOR := ALFA Network + DEVICE_MODEL := Quad-E4G + DEVICE_PACKAGES := kmod-ata-core kmod-ata-ahci kmod-sdhci-mt7620 kmod-usb3 \ + uboot-envtools +endef +TARGET_DEVICES += alfa-network_quad-e4g + define Device/asiarf_ap7621-001 MTK_SOC := mt7621 IMAGE_SIZE := 16000k 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 0de3804cdb..420780a101 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 @@ -37,6 +37,18 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6@eth0" ;; + alfa-network,quad-e4g|\ + netgear,r6220|\ + netgear,r6260|\ + netgear,r6350|\ + netgear,r6850|\ + netgear,wndr3700-v5|\ + netis,wf-2881|\ + wevo,11acnas|\ + wevo,w2914ns-v2) + ucidef_add_switch "switch0" \ + "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0" + ;; asiarf,ap7621-001) ucidef_add_switch "switch0" "0:lan" "4:wan" "6@eth0" ;; @@ -106,17 +118,6 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan" "6@eth0" ;; - netgear,r6220|\ - netgear,r6260|\ - netgear,r6350|\ - netgear,r6850|\ - netgear,wndr3700-v5|\ - netis,wf-2881|\ - wevo,11acnas|\ - wevo,w2914ns-v2) - ucidef_add_switch "switch0" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "4:wan" "6@eth0" - ;; xiaomi,mir3g) ucidef_add_switch "switch0" \ "2:lan:2" "3:lan:1" "1:wan" "6t@eth0" @@ -169,6 +170,7 @@ ramips_setup_macs() zbtlink,zbt-wg2626) wan_mac=$(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) ;; + alfa-network,quad-e4g|\ asus,rt-ac57u|\ d-team,newifi-d2|\ d-team,pbr-m1|\ diff --git a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount index 807801a34f..b4d72abafc 100755 --- a/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount +++ b/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount @@ -4,6 +4,10 @@ START=99 boot() { case $(board_name) in + alfa-network,quad-e4g) + [ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\ + echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s - + ;; samknows,whitebox-v8) fw_setenv bootcount 0 ;; 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 f8aa0373a0..d74aba3bfe 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -5,6 +5,9 @@ PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 +RAMFS_COPY_BIN='fw_printenv fw_setenv' +RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' + platform_check_image() { return 0 } @@ -13,6 +16,17 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in + alfa-network,quad-e4g) + [ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\ + [ -n "$(find_mtd_part backup)" ] && { + PART_NAME=backup + if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then + fw_setenv bootactive 2 || exit 1 + else + fw_setenv bootactive 1 || exit 1 + fi + } + ;; mikrotik,rb750gr3|\ mikrotik,rbm11g|\ mikrotik,rbm33g) diff --git a/target/linux/ramips/mt7621/config-4.14 b/target/linux/ramips/mt7621/config-4.14 index a7276a301d..4112cad780 100644 --- a/target/linux/ramips/mt7621/config-4.14 +++ b/target/linux/ramips/mt7621/config-4.14 @@ -89,6 +89,8 @@ CONFIG_GPIOLIB=y CONFIG_GPIO_MT7621=y # CONFIG_GPIO_RALINK is not set CONFIG_GPIO_SYSFS=y +CONFIG_GPIO_WATCHDOG=y +# CONFIG_GPIO_WATCHDOG_ARCH_INITCALL is not set # CONFIG_GRO_CELLS is not set CONFIG_HANDLE_DOMAIN_IRQ=y CONFIG_HARDWARE_WATCHPOINTS=y @@ -253,6 +255,7 @@ CONFIG_RESET_CONTROLLER=y CONFIG_RFS_ACCEL=y CONFIG_RPS=y CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_BQ32K=y CONFIG_RTC_DRV_PCF8563=y CONFIG_RTC_I2C_AND_SPI=y CONFIG_RTC_MC146818_LIB=y From 10bcf1eb40b728b3583c1a7693111f27a9801dc5 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Sun, 3 Nov 2019 12:17:52 +0100 Subject: [PATCH 8/8] uboot-envtools: ramips: add support for ALFA Network Quad-E4G Signed-off-by: Piotr Dymacz --- package/boot/uboot-envtools/files/ramips | 1 + 1 file changed, 1 insertion(+) diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index f6af232e96..ade55dd1cb 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -15,6 +15,7 @@ board=$(board_name) case "$board" in alfa-network,ac1200rm|\ alfa-network,awusfree1|\ +alfa-network,quad-e4g|\ alfa-network,r36m-e4g|\ alfa-network,tube-e4g) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000"