[PATCH] Adds support for Comfast CF-E538AC

Adrian Schmutzler mail at adrianschmutzler.de
Wed Nov 11 17:57:11 EST 2020


Hi Sven,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Sven Danner
> Sent: Mittwoch, 11. November 2020 06:05
> To: john at phrozen.org
> Cc: openwrt-devel at lists.openwrt.org
> Subject: [PATCH] Adds support for Comfast CF-E538AC
> 
>     Comfast CF-E538AC is an wall mounted access point with an
>     additional Ethernet LAN access port. It supports
>     802.11AC Wave2 MU-MIMO
> 
>     Serial port access for debricking requires simple soldering of 4 pins.

this is based on an outdated version of OpenWrt, please submit the patch based on current master.

A few additional comments above.

> 
>     Device specifications:
>     * SoC: MT7620DA @ 580MHz
>     * RAM: 64MiB DDR2
>     * Flash: 8iB SPI
>     * Wireless 2.4GHz (SoC): b/g/n
>     * Wireless 5Ghz (MT7612E): n/ac, 2x2 MU-MINO
>     * Ethernet (RTL8211F): 1× 1GbE, 802.3af PoE
>     * Ethernet (RTL8211F): 1× 1GbE
> 
>     Flashing instructions:
>     * Upgrade using web interface
> 
>     Debricking:
>     * Serial port can be soldered on top PCB (marked as 1)
>       (1: VCC, 2: GND, 3: TX, 4: RX)
>         * Use 3.3V, 115200 baud, 8n1
>     * Recovery only possible via TFTP
>     * Modified U-Boot environment does not allow recovery via serial
>       (will not commit it to flash)
>     * Bootloader will show a menu for 1 seconds
>     * Select 2: Load system code then write to Flash via TFTP.
> ---
>  .../ramips/base-files/etc/board.d/01_leds     |   3 +
>  .../ramips/base-files/etc/board.d/02_network  |   9 +
>  target/linux/ramips/base-files/lib/ramips.sh  |   3 +
>  target/linux/ramips/dts/CF-E538AC.dts         | 161 ++++++++++++++++++
>  target/linux/ramips/image/mt7620.mk           |   7 +
>  5 files changed, 183 insertions(+)
>  create mode 100644 target/linux/ramips/dts/CF-E538AC.dts
> 
> diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds
> b/target/linux/ramips/base-files/etc/board.d/01_leds
> index 5c005db0c1..16c012d827 100755
> --- a/target/linux/ramips/base-files/etc/board.d/01_leds
> +++ b/target/linux/ramips/base-files/etc/board.d/01_leds
> @@ -88,6 +88,9 @@ c50)
>  	ucidef_set_led_switch "lan" "lan" "$boardname:green:lan" "switch0"
> "0x1e"
>  	ucidef_set_led_switch "wan" "wan" "$boardname:green:wan"
> "switch0" "0x01"
>  	;;
> +cf-e538ac)
> +	set_wifi_led "$boardname:white:wifi"

Use DT trigger instead.

> +	;;
>  cf-wr800n)
>  	ucidef_set_led_netdev "lan" "lan" "$boardname:white:ethernet"
> eth0.1
>  	set_wifi_led "$boardname:white:wifi"
> diff --git a/target/linux/ramips/base-files/etc/board.d/02_network
> b/target/linux/ramips/base-files/etc/board.d/02_network
> index 8ca1831afe..637a4fd6a1 100755
> --- a/target/linux/ramips/base-files/etc/board.d/02_network
> +++ b/target/linux/ramips/base-files/etc/board.d/02_network
> @@ -310,6 +310,11 @@ ramips_setup_interfaces()
>  		ucidef_add_switch "switch0" \
>  			"4:lan" "6t at eth0"
>  		;;
> +	cf-e538ac)
> +		ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"

This can be dropped, ucidef_add_switch will do that automatically.

> +		ucidef_add_switch "switch0" \
> +			"4:wan" "5:lan" "6 at eth0"
> +		;;
>  	cudy,wr1000)
>  		ucidef_add_switch "switch0" \
>  			"2:lan:2" "3:lan:1" "4:wan" "6 at eth0"
> @@ -548,6 +553,10 @@ ramips_setup_macs()
>  		lan_mac=$(cat /sys/class/net/eth0/address)
>  		wan_mac=$(mtd_get_mac_binary devdata 7)
>  		;;
> +	cf-e538ac)
> +		lan_mac=$(mtd_get_mac_binary factory 57344)

This can be done with mtd_mac_address in DTS.

> +		wan_mac=$(macaddr_add "$lan_mac" 1)

No additional address on flash (0xe006, 0x28, 0x2e)?
What's the MAC address assignment on stock FW?

> +		;;
>  	cy-swr1100|\
>  	dir-645)
>  		lan_mac=$(mtd_get_mac_ascii nvram lanmac) diff --git
> a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-
> files/lib/ramips.sh
> index 093303892c..5e9b8fdb09 100755
> --- a/target/linux/ramips/base-files/lib/ramips.sh
> +++ b/target/linux/ramips/base-files/lib/ramips.sh
> @@ -97,6 +97,9 @@ ramips_board_detect() {
>  	*"CF-WR800N")
>  		name="cf-wr800n"
>  		;;
> +	*"CF-E538AC")
> +		name="cf-e538ac"
> +		;;
>  	*"CS-QR10")
>  		name="cs-qr10"
>  		;;
> diff --git a/target/linux/ramips/dts/CF-E538AC.dts
> b/target/linux/ramips/dts/CF-E538AC.dts
> new file mode 100644
> index 0000000000..9a2504203b
> --- /dev/null
> +++ b/target/linux/ramips/dts/CF-E538AC.dts
> @@ -0,0 +1,161 @@
> +// 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 = "comfast,cf-e538ac", "ralink,mt7620n-soc";
> +	model = "Comfast CF-E538AC";
> +
> +	aliases {
> +		led-boot = &led_wifi;
> +		led-failsafe = &led_wifi;
> +		led-running = &led_wifi;
> +		led-upgrade = &led_wifi;
> +	};
> +
> +	chosen {
> +		bootargs = "console=ttyS0,115200";
> +	};
> +
> +	leds {
> +		compatible = "gpio-leds";
> +
> +		led_wifi: wifi {
> +			label = "cf-e538ac:white:wifi";
> +			gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
> +		};
> +	};
> +
> +	keys {
> +		compatible = "gpio-keys-polled";
> +		poll-interval = <20>;
> +
> +		reset {
> +			label = "reset";
> +			gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
> +			linux,code = <KEY_RESTART>;
> +		};
> +	};
> +
> +};
> +
> +&gpio0 {
> +	status = "okay";
> +};
> +
> +&gpio2 {
> +	status = "okay";
> +};
> +
> +&gpio3 {
> +	status = "okay";
> +};
> +
> +&spi0 {
> +	status = "okay";
> +
> +	m25p80 at 0 {
> +		compatible = "jedec,spi-nor";
> +		reg = <0>;
> +		spi-max-frequency = <10000000>;
> +
> +		partitions {
> +			compatible = "fixed-partitions";
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +
> +			partition at 0 {
> +				label = "u-boot";
> +				reg = <0x0 0x30000>;
> +				read-only;
> +			};
> +
> +			partition at 30000 {
> +				label = "u-boot-env";
> +				reg = <0x30000 0x10000>;
> +				read-only;
> +			};
> +
> +			factory: partition at 40000 {
> +				label = "factory";
> +				reg = <0x40000 0x10000>;
> +				read-only;
> +			};
> +
> +			partition at 50000 {
> +				compatible = "denx,uimage";
> +				label = "firmware";
> +				reg = <0x50000 0x7b0000>;
> +			};
> +		};
> +	};
> +};
> +
> +&ethernet {
> +	status = "okay";
> +	pinctrl-names = "default";
> +	mtd-mac-address = < 0x09 0xe000 >;

<&factory 0xe000> ?

> +	pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>;
> +	mediatek,portmap = "llllw";
> +
> +	port at 4 {
> +		status = "okay";
> +		phy-mode = "rgmii";
> +		phy-handle = <&phy4>;
> +	};
> +
> +	port at 5 {
> +		status = "okay";
> +		phy-mode = "rgmii";
> +		phy-handle = <&phy5>;
> +	};
> +
> +	mdio-bus {
> +		status = "okay";
> +
> +		phy4: ethernet-phy at 4 {
> +			reg = < 0x04 >;
> +			phy-mode = "rgmii";
> +		};
> +
> +		phy5: ethernet-phy at 5 {
> +			reg = < 0x05 >;
> +			phy-mode = "rgmii";
> +		};
> +	};
> +};
> +
> +&gsw  {
> +		mediatek,port4 = "gmac";

Broken indent.

> +};
> +
> +&wmac {
> +	ralink,mtd-eeprom = <&factory 0>;

Please use 0x0 for consistency.

> +	reg = < 0x10180000 0x9c40 >;

Needed?

> +};
> +
> +
> +&pcie {
> +		status = "okay";

Indent.

> +};
> +
> +&pinctrl {
> +	state_default: pinctrl0 {

&state_default can be referenced directly.

Best

Adrian

> +		gpio {
> +			ralink,group = "uartf", "nd_sd", "wled";
> +			ralink,function = "gpio";
> +		};
> +	};
> +};
> +
> +&pcie0 {
> +	mt76 at 0,0 {
> +		reg = <0x0000 0 0 0 0>;
> +		mediatek,mtd-eeprom = <&factory 0x8000>;
> +		ieee80211-freq-limit = <5000000 6000000>;
> +	};
> +};
> diff --git a/target/linux/ramips/image/mt7620.mk
> b/target/linux/ramips/image/mt7620.mk
> index 89723fbb52..d16704a55e 100644
> --- a/target/linux/ramips/image/mt7620.mk
> +++ b/target/linux/ramips/image/mt7620.mk
> @@ -155,6 +155,13 @@ define Device/cf-wr800n  endef  TARGET_DEVICES
> += cf-wr800n
> 
> +define Device/cf-e538ac
> +  DTS := CF-E538AC
> +  DEVICE_TITLE := Comfast CF-E538AC
> +  DEVICE_PACKAGES := kmod-mt76x2
> +endef
> +TARGET_DEVICES += cf-e538ac
> +
>  define Device/cs-qr10
>    DTS := CS-QR10
>    DEVICE_TITLE := Planex CS-QR10
> --
> 2.20.1
> 
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.openwrt.org/pipermail/openwrt-devel/attachments/20201111/3d36838b/attachment-0001.sig>


More information about the openwrt-devel mailing list