Support for Comfast CF-EW72 V2 MT7621

Hello everyone.
I got now also the new Version of the CF-EW72 and want to flash openwrt to it.
The Post Support for Comfast CF-EW72/MT7621 - For Developers - OpenWrt Forum is closed.

How can it be possible to get an openwrt firmware for this device.

The Comfast firmware is based on openwrt 17

CF-EW72V2-V2.6.0.1 - AP Firmware - COMFAST

At the moment I have ssh acess to the device with cf firmware.

Many thanks for helping.

It is possible, if you and the other owners work together to make it happen.

How to start?

See https://openwrt.org/faq/how_can_i_add_support_for_a_new_device

There are probably some hints in the old dev thread. You should read that and see if you can continue the work where it stopped. Supporting new MT7621 devices is pretty easy in general, but there are always some device specific stuff to figure out. Like GPIOs for buttons/LEDs. Or vendor specfici boot loader extensions like dual partition etc.

First try to get access to the serial console. This is required to continue.

3 Likes

Ok, for the moment I have only ssh access to the cf-ew72v2.
For Serial Connecton, I ordered now a new one :slight_smile:

From the old dev thread, I tried to figure out where the process stopped. I have now made a backup and copied it:

cat /proc/mtd
cat /dev/mtd0 >/tmp/uboot.bin
cat /dev/mtd1 >/tmp/ubootenv.bin
cat /dev/mtd2 >/tmp/factory.bin

cf-ew72v_mdt.zip

Can more be prepared which can be done via ssh?

Hi Frollic,
Do you own on of the cf-ew72v2?

Nope, I got the v1.

mtd

dev:    size   erasesize  name
mtd0: 00030000 00010000 "Bootloader"
mtd1: 00010000 00010000 "Config"
mtd2: 00010000 00010000 "factory"
mtd3: 00fb0000 00010000 "firmware"
mtd4: 001ac104 00010000 "kernel"
mtd5: 00e03efc 00010000 "rootfs"
mtd6: 00700000 00010000 "rootfs_data"

@bmork @123serge123
today my ct-ew72v2 arrived.
The serial console is ready, so what are the next steps?

Make sure you can access the boot loader, stopping boot and interacting with it. Try to load and boot an initramfs from RAM. Either one you've prepared for that router, or just try some other MT7621 image to start exploring the hardware. Be careful not to do any unintentional flash writes.

Save console logs showing both a complete OEM firmware boot and an OpenWrt boot.

Do not write anything to flash until you are ready for that. Boot your experimental images from RAM until you are 110% sure they work and have the proper partition layout etc.

https://openwrt.org/docs/guide-developer/adding_new_device lists the tasks you have to do. Start doing what it says on top: Look at recent commits adding new devices, in particular new MT7621 devices.You can find them by e.g doing

git log target/linux/ramips/mt7621/

And then inspect a few of the interesting commits closer by doing e.g.

git show 13308161788c98ae6cd48c22b13339fdb8c77130
git show a0b7fef0ffe4cd9cca39a652a37e4f3ce8f0a681

etc. Not everything there will be relevant for your device of course, but it should give you some idea. Make sure to look at more than those two commits. There are plenty of examples.

Creating the DTS is the most important part, since it describes all the hardware including the flash layout. Find a similar device to use as a template. The closer it matches, the less work you'll have to do.

The oem boot log is to long, how can I attach the log file?

Check all interfaces MAC addresses (lan wan wifi2g wifi5g).

OEM Boot log

Thera are many info from previous topics. So you can start from this mt7621_comfast_cf-ew72-v2.dts file to desribe hardware:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
    compatible = "comfast,cf-ew72-v2", "mediatek,mt7621-soc";
    model = "Comfast CF-EW72 v2";

    aliases {
	label-mac-device = &wan;
	led-boot = &led_power;
	led-failsafe = &led_power;
	led-running = &led_power;
	led-upgrade = &led_power;
    };

    chosen {
	bootargs = "console=ttyS0,115200";
    };

    leds {
	compatible = "gpio-leds";

	led_power: wlan {
	    label = "blue:wlan";
	    gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
	};

    };

    keys {
	compatible = "gpio-keys";

	reset {
	    label = "reset";
	    gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
	    linux,code = <KEY_RESTART>;
	    debounce-interval = <60>;
	};
    };
};

&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 = "config";
		reg = <0x30000 0x10000>;
		read-only;
	    };

	    factory: partition@40000 {
		label = "factory";
		reg = <0x40000 0x10000>;
		read-only;
	    };

	    partition@50000 {
		compatible = "denx,uimage";
		label = "firmware";
		reg = <0x50000 0xfb0000>;
	    };
	};
    };
};

&pcie {
    status = "okay";
};

&pcie0 {
    wifi@0,0 {
	compatible = "mediatek,mt76";
	reg = <0x0000 0 0 0 0>;
	mediatek,mtd-eeprom = <&factory 0x0000>;
    };
};

&pcie1 {
    wifi@0,0 {
	compatible = "mediatek,mt76";
	reg = <0x0000 0 0 0 0>;
	mediatek,mtd-eeprom = <&factory 0x8000>;
    };
};

&gmac0 {
    nvmem-cells = <&macaddr_factory_e000>;
    nvmem-cell-names = "mac-address";
};

&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";
	};

	wan: port@4 {
	    status = "okay";
	    label = "wan";
	    nvmem-cells = <&macaddr_factory_e000>;
	    nvmem-cell-names = "mac-address";
	};
    };
};

&state_default {
    gpio {
	groups = "i2c", "uart2", "uart3", "sdhci", "jtag";
	function = "gpio";
    };
};

&factory {
    compatible = "nvmem-cells";
    #address-cells = <1>;
    #size-cells = <1>;

    macaddr_factory_4: macaddr@4 {
	reg = <0x4 0x6>;
    };

    macaddr_factory_8004: macaddr@8004 {
	reg = <0x8004 0x6>;
    };

    macaddr_factory_e000: macaddr@e000 {
	reg = <0xe000 0x6>;
    };
};

In vendor dts-file only 2 gpio were defined: reset button and wlan led.
So you have to define it yourself.
LAN/WAN ports number must be checked too.
But all these enough to build test image.

Post printenv and help, from uboot too.

Might want to mask out any MAC.

printenv

baudrate=115200
bootcmd=mtkautoboot
bootdelay=0
bootmenu_0=Startup system (Default)=mtkboardboot
bootmenu_1=Upgrade firmware=mtkupgrade fw
bootmenu_2=Upgrade bootloader=mtkupgrade bl
bootmenu_3=Upgrade bootloader (advanced mode)=mtkupgrade bladv
bootmenu_4=Load image=mtkload
ethact=eth@1e100000
fdtcontroladdr=87ff68d0
ipaddr=192.168.1.1
netmask=255.255.255.0
serverip=192.168.1.10
stderr=uartlite0@1e000c00
stdin=uartlite0@1e000c00
stdout=uartlite0@1e000c00

Environment size: 460/65532 bytes
1 Like

help

help
?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootmenu- ANSI terminal bootmenu
bootp   - boot image via network using BOOTP/TFTP protocol
chpart  - change active partition
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
echo    - echo args to console
editenv - edit environment variable
env     - environment handling commands
fdt     - flattened device tree utility commands
go      - start application at address 'addr'
gpio    - query and control gpio pins
help    - print command description/usage
httpd   - Start failsafe HTTP server
iminfo  - print header information for application image
itest   - return true/false on integer compare
ledtest - MediaTek gpio led test
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loadx   - load binary file over serial line (xmodem mode)
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mtdparts- define flash/nand partitions
mtkautoboot- Display MediaTek bootmenu
mtkboardboot- Boot MTK firmware
mtkload - MTK image loading utility
mtkupgrade- MTK firmware/bootloader upgrading utility
mw      - memory write (fill)
nm      - memory modify (constant address)
printenv- print environment variables
reset   - Perform RESET of the CPU
run    0- run commands in an environment variable
saveenv - save environment variables to persistent storage
setenv  - set environment variables
setexpr - set environment variable as the result of eval expression
setmac  - save new MAC address in FLASH
xx:xx:xx:xx:xx:xx [serial-no] [pin-code]
        - change MAC address stored in FLASH (xx - value in hex format)

sf      - SPI flash sub-system
sleep   - delay execution for some time
source  - run script from memory
tftpboot- boot image via network using TFTP protocol
version - print monitor, compiler and linker version
1 Like

Ok, I want to try to make a new firmware totday, but for me is not clear to start.

I have now Ubuntu up and runing and also checked out the openwrt git.
What is the next step?