Merge Official Source

This commit is contained in:
CN_SZTL 2019-11-14 12:48:23 +08:00
commit 2ae1c231ff
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
17 changed files with 573 additions and 20 deletions

View File

@ -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

View File

@ -15,6 +15,8 @@ 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"
;;

View File

@ -0,0 +1,218 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7620a.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
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 = <KEY_RESTART>;
};
rfkill {
label = "rfkill";
gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RFKILL>;
};
};
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";
};
&ethernet {
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>;
};

View File

@ -11,6 +11,7 @@
model = "ALFA Network Tube-E4G";
aliases {
label-mac-device = &ethernet;
led-boot = &power;
led-failsafe = &power;
led-running = &power;

View File

@ -0,0 +1,232 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "mt7621.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
/ {
compatible = "alfa-network,quad-e4g", "mediatek,mt7621-soc";
model = "ALFA Network Quad-E4G";
aliases {
label-mac-device = &ethernet;
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 = <KEY_RESTART>;
};
user1 {
label = "user1";
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
};
user2 {
label = "user2";
gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
linux,code = <BTN_1>;
};
};
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;
};
};
&ethernet {
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";
};

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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)

View File

@ -0,0 +1,14 @@
#!/bin/sh /etc/rc.common
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 -
;;
esac
}

View File

@ -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,20 @@ platform_do_upgrade() {
local board=$(board_name)
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)" ] && {
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"
;;

View File

@ -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|\

View File

@ -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
;;

View File

@ -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)

View File

@ -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
@ -154,6 +156,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
@ -252,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

View File

@ -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
;;

View File

@ -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"