OpenWrt support for custom board (similar C6U)

I can confirm that your commit (https://github.com/openwrt/openwrt/commit/0d9939a0d0cdc6164eb9a460af8d3c6fa0d2e3ef) is working on my C6U but on another board I'm getting:

[   10.546355] mt7603e 0000:01:00.0: Firmware Version: ap_pcie
[   10.551980] mt7603e 0000:01:00.0: Build Time: 20160107100755
[   10.585058] mt7603e 0000:01:00.0: firmware init done
[   10.762519] ------------[ cut here ]------------
[   10.767229] WARNING: CPU: 1 PID: 742 at backports-5.10.16-1/net/wireless/core.c:875 wiphy_register+0xd8c/0xd94 [cfg80211]
[   10.778151] Modules linked in: mt7603e(+) mt76_connac_lib mt76 mac80211 ipt_REJECT cfg80211 xt_time xt_tcpudp xt_multiport xt_mark xt_mac xt_limit xt_comment xt_TCPMSS xt_LOG slhc nf_reject_ipv4 nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 iptable_mangle iptable_filter ip_tables crc_ccitt compat ledtrig_usbport nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 leds_gpio xhci_plat_hcd xhci_pci xhci_mtk xhci_hcd gpio_button_hotplug usbcore nls_base usb_common
[   10.823074] CPU: 1 PID: 742 Comm: kmodloader Not tainted 5.4.102 #0
[   10.829309] Stack : 00000005 8007d86c 806b0000 806b3b74 80720000 806b3b3c 806b2c90 86d5796c
[   10.837632]         80850000 87f5c188 806fcd03 80647dd4 00000001 00000001 86d57910 44c617d6
[   10.845953]         00000000 00000000 80890000 00000000 00000030 00000106 20646574 2e342e35
[   10.854274]         00000000 00000000 00000000 000c8f22 80000000 80720000 00000000 86f01248
[   10.862596]         00000009 86875cdc 00000001 00000005 00000002 8034fcc4 00000004 80850004
[   10.870917]         ...
[   10.873354] Call Trace:
[   10.875810] [<8000b70c>] show_stack+0x30/0x100
[   10.880262] [<8058c1e0>] dump_stack+0xa4/0xdc
[   10.884615] [<8002c008>] __warn+0xc0/0x10c
[   10.888696] [<8002c0b0>] warn_slowpath_fmt+0x5c/0xac
[   10.893670] [<86f01248>] wiphy_register+0xd8c/0xd94 [cfg80211]
[   10.899612] [<868014a8>] ieee80211_register_hw+0x9b8/0xd88 [mac80211]
[   10.906069] [<86e6380c>] mt76_register_device+0x208/0x340 [mt76]
[   10.912086] [<86e3280c>] mt7603_register_device+0x9a0/0xb74 [mt7603e]
[   10.918518] [<86e3016c>] init_module+0x4a16c/0x4b364 [mt7603e]
[   10.924459] ---[ end trace e5c48b31d7c5c199 ]---
[   10.930674] mt7603e: probe of 0000:01:00.0 failed with error -22
[   10.942665] mt7621-pci 1e140000.pcie: bus=2 slot=1 irq=24
[   10.948112] pci 0000:00:01.0: enabling device (0004 -> 0007)
[   10.953777] mt7615e 0000:02:00.0: enabling device (0000 -> 0002)

and then after a minute:

[   70.933038] rcu: INFO: rcu_sched self-detected stall on CPU
[   70.938616] rcu: 	1-....: (14997 ticks this GP) idle=262/1/0x40000002 softirq=510/510 fqs=7500 
[   70.947272] 	(t=15003 jiffies g=-239 q=175)
[   70.951436] NMI backtrace for cpu 1
[   70.954914] CPU: 1 PID: 742 Comm: kmodloader Tainted: G        W         5.4.102 #0
[   70.962531] Stack : 80700000 8007d86c 806b0000 806b3b74 80720000 806b3b3c 806b2c90 87c0fd3c
[   70.970857]         80850000 87f5c188 806fcd03 80647dd4 00000001 00000001 87c0fce0 44c617d6
[   70.979179]         00000000 00000000 80890000 00000000 00000030 00000120 20202020 2e342e35
[   70.987500]         00000000 00000003 00000000 000e9222 80000000 80720000 00000000 00000001
[   70.995822]         8063be30 806fa2d0 80700000 00000000 00000002 8034fcc4 00000004 80850004
[   71.004143]         ...
[   71.006579] Call Trace:
[   71.009045] [<8000b70c>] show_stack+0x30/0x100
[   71.013499] [<8058c1e0>] dump_stack+0xa4/0xdc
[   71.017847] [<8059283c>] nmi_cpu_backtrace+0xe4/0x134
[   71.022879] [<805929e8>] nmi_trigger_cpumask_backtrace+0x15c/0x194
[   71.029060] [<8008d5f4>] rcu_dump_cpu_stacks+0xe0/0x12c
[   71.034270] [<80092274>] rcu_sched_clock_irq+0x6e0/0x948
[   71.039573] [<80097378>] update_process_times+0x2c/0x78
[   71.044794] [<800a96d8>] tick_handle_periodic+0x34/0xd0
[   71.050023] [<803e4ee0>] gic_compare_interrupt+0x7c/0x9c
[   71.055314] [<80084b88>] handle_percpu_devid_irq+0xbc/0x19c
[   71.060878] [<8007eaa4>] generic_handle_irq+0x40/0x58
[   71.065915] [<802f0920>] gic_handle_local_int+0x98/0x120
[   71.071205] [<802f0b6c>] gic_irq_dispatch+0x10/0x20
[   71.076064] [<8007eaa4>] generic_handle_irq+0x40/0x58
[   71.081114] [<805acd1c>] do_IRQ+0x1c/0x2c
[   71.085109] [<802f03c8>] plat_irq_dispatch+0x64/0x104
[   71.090142] [<80006dc8>] except_vec_vi_end+0xb8/0xc4
[   71.095086] [<805aac44>] down_write+0x34/0x5c
[   71.099429] [<803e3778>] led_trigger_register+0x144/0x214
[   71.104933] [<8685740c>] ieee80211_led_init+0x3c/0x180 [mac80211]
[   71.111051] [<86801160>] ieee80211_register_hw+0x670/0xd88 [mac80211]
[   71.117507] [<86e6380c>] mt76_register_device+0x208/0x340 [mt76]
[   71.123505] [<868f44e8>] mt7615_register_device+0x148/0x1a8 [mt7615e]
[   71.129926] [<868f5bd8>] mt7615_mmio_probe+0x200/0x218 [mt7615e]
[   71.135916] [<80314a14>] pci_device_probe+0xbc/0x150
[   71.140863] [<8036087c>] really_probe+0x104/0x358
[   71.145550] [<80360fb4>] device_driver_attach+0x74/0x7c
[   71.150755] [<8036101c>] __driver_attach+0x60/0x100
[   71.155632] [<8035e864>] bus_for_each_dev+0x68/0xa4
[   71.160495] [<8035fbd8>] bus_add_driver+0x1f4/0x204
[   71.165355] [<803616b0>] driver_register+0x84/0x148
[   71.170214] [<8000161c>] do_one_initcall+0x7c/0x1dc
[   71.175083] [<800b4598>] do_init_module+0x60/0x228
[   71.179856] [<800b6778>] load_module+0x1f9c/0x2530
[   71.184629] [<800b6e78>] sys_init_module+0x16c/0x1a8
[   71.189583] [<80014578>] syscall_common+0x34/0x58

Does this output mean that is something wrong with my calibration data?

the other board is what? another C6U? same version?

I got custom board with exact same hardware as C6U but with swapped pcie lines for MT7603 and MT7613, so I just swapped them in dts file:

&pcie0 {
	mt76@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&radio 0x8000>;
		mtd-mac-address = <&config 0x8>;
		ieee80211-freq-limit = <5000000 6000000>;
	};
};

&pcie1 {
	mt76@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&radio 0x0>;
		mtd-mac-address = <&config 0x8>;
		mtd-mac-address-increment = <(-1)>;
		ieee80211-freq-limit = <2400000 2500000>;
	};
};

Actually I was a bit wrong in last posts, if I set dts with mtd-mac-address-increment = <(-1)>; for MT7603 I get into kernel panic:

[   12.782386] mt7621-pci 1e140000.pcie: bus=1 slot=0 irq=23
[   12.787857] pci 0000:00:00.0: enabling device (0004 -> 0007)
[   12.793524] mt7603e 0000:01:00.0: enabling device (0000 -> 0002)
[   12.799722] mt7603e 0000:01:00.0: ASIC revision: 76030010
[   12.900201] random: crng init done
[   12.903628] random: 7 urandom warning(s) missed due to ratelimiting
[   13.422564] mt7603e 0000:01:00.0: Firmware Version: ap_pcie
[   13.428220] mt7603e 0000:01:00.0: Build Time: 20160107100755
[   13.457624] mt7603e 0000:01:00.0: firmware init done
[   13.638825] ------------[ cut here ]------------
[   13.643572] WARNING: CPU: 0 PID: 730 at backports-5.10.16-1/net/wireless/core.c:875 wiphy_register+0xd8c/0xd94 [cfg80211]
[   13.654502] Modules linked in: mt7603e(+) mt76_connac_lib mt76 mac80211 ipt_REJECT cfg80211 xt_time xt_tcpudp xt_multiport xt_mark xt_mac xt_limit xt_comment xt_TCPMSS xt_LOG slhc nf_reject_ipv4 nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 iptable_mangle iptable_filter ip_tables crc_ccitt compat ledtrig_usbport nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 leds_gpio xhci_plat_hcd xhci_pci xhci_mtk xhci_hcd gpio_button_hotplug usbcore nls_base usb_common
[   13.699441] CPU: 0 PID: 730 Comm: kmodloader Not tainted 5.4.102 #0
[   13.705677] Stack : 00000005 8007d86c 806b0000 806b3c48 80720000 806b3c10 806b2d64 868f396c
[   13.714001]         80c40000 87479488 806fcd03 80647e64 00000000 00000001 868f3910 a27c8c3d
[   13.722319]         00000000 00000000 80c80000 00000000 00000030 000000fe 20646574 2e342e35
[   13.730637]         00000000 00000000 00000000 000aac31 80000000 80720000 00000000 87601248
[   13.738955]         00000009 87275cdc 00000001 00000005 00000002 8034fcc4 00000000 80c40000
[   13.747274]         ...
[   13.749707] Call Trace:
[   13.752161] [<8000b70c>] show_stack+0x30/0x100
[   13.756610] [<8058c1e0>] dump_stack+0xa4/0xdc
[   13.760959] [<8002c008>] __warn+0xc0/0x10c
[   13.765037] [<8002c0b0>] warn_slowpath_fmt+0x5c/0xac
[   13.770006] [<87601248>] wiphy_register+0xd8c/0xd94 [cfg80211]
[   13.775944] [<872014a8>] ieee80211_register_hw+0x9b8/0xd88 [mac80211]
[   13.782394] [<8719380c>] mt76_register_device+0x208/0x340 [mt76]
[   13.788407] [<86c1280c>] mt7603_register_device+0x9a0/0xb74 [mt7603e]
[   13.794834] [<86c1016c>] 0x86c1016c
[   13.798475] ---[ end trace 7f2fa1eee56348ad ]---
[   13.804613] mt7603e: probe of 0000:01:00.0 failed with error -22
[   13.816691] mt7621-pci 1e140000.pcie: bus=2 slot=1 irq=24
[   13.822202] pci 0000:00:01.0: enabling device (0004 -> 0007)
[   13.827883] mt7615e 0000:02:00.0: enabling device (0000 -> 0002)
[   13.842115] CPU 0 Unable to handle kernel paging request at virtual address 07797000, epc == 80076cb0, ra == 80076c8c
[   13.852697] Oops[#1]:
[   13.854966] CPU: 0 PID: 730 Comm: kmodloader Tainted: G        W         5.4.102 #0
[   13.862581] $ 0   : 00000000 00000001 00000000 07797000
[   13.867785] $ 4   : 871533f8 00000000 4f000000 86cd6380
[   13.872986] $ 8   : 00000000 805a69bc 00000000 f4dfdfa6
[   13.878187] $12   : 8ad87137 2219ec5e b723fa9c 435bbda8
[   13.883388] $16   : 871533f0 00000000 00000001 871533f8
[   13.888590] $20   : 00000002 00800000 871533fc 868f3a50
[   13.893792] $24   : 00000000 e44a31b6                  
[   13.898993] $28   : 868f2000 868f3a28 80700000 80076c8c
[   13.904195] Hi    : 001dc681
[   13.907056] Lo    : 24c118ce
[   13.909932] epc   : 80076cb0 rwsem_down_write_slowpath+0xa0/0x450
[   13.915993] ra    : 80076c8c rwsem_down_write_slowpath+0x7c/0x450
[   13.922050] Status: 11008402	KERNEL EXL 
[   13.925955] Cause : 4080000c (ExcCode 03)
[   13.929939] BadVA : 07797000
[   13.932800] PrId  : 0001992f (MIPS 1004Kc)
[   13.936869] Modules linked in: mt7615e(+) mt7615_common mt7603e mt76_connac_lib mt76 mac80211 ipt_REJECT cfg80211 xt_time xt_tcpudp xt_multiport xt_mark xt_mac xt_limit xt_comment xt_TCPMSS xt_LOG slhc nf_reject_ipv4 nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 iptable_mangle iptable_filter ip_tables crc_ccitt compat ledtrig_usbport nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 leds_gpio xhci_plat_hcd xhci_pci xhci_mtk xhci_hcd gpio_button_hotplug usbcore nls_base usb_common
[   13.983645] Process kmodloader (pid: 730, threadinfo=64a180db, task=78cd35ab, tls=77e75ec8)
[   13.991949] Stack : 45adbdc4 98e8b532 80c74f74 868f3a7c 871533f8 00000000 868f3a80 80357d20
[   14.000269]         00000001 868f3a48 871533fc 07797000 874790e0 00000000 fffee87a 80358284
[   14.008588]         87153374 87285ca8 871533f0 80712cc0 80710000 00800000 00000000 00000005
[   14.016906]         00000005 803e3778 00000000 00000000 00000000 00000000 00000000 87284c20
[   14.025224]         00000000 0000000e 00000000 00000001 00000000 8725740c 87284c20 00000000
[   14.033542]         ...
[   14.035974] Call Trace:
[   14.038408] [<80076cb0>] rwsem_down_write_slowpath+0xa0/0x450
[   14.044152] [<803e3778>] led_trigger_register+0x144/0x214
[   14.049656] [<8725740c>] ieee80211_led_init+0x3c/0x180 [mac80211]
[   14.055769] [<87201160>] ieee80211_register_hw+0x670/0xd88 [mac80211]
[   14.062218] [<8719380c>] mt76_register_device+0x208/0x340 [mt76]
[   14.068211] [<876744e8>] mt7615_register_device+0x148/0x1a8 [mt7615e]
[   14.074627] [<87675bd8>] mt7615_mmio_probe+0x200/0x218 [mt7615e]
[   14.080611] [<80314a14>] pci_device_probe+0xbc/0x150
[   14.085554] [<8036087c>] really_probe+0x104/0x358
[   14.090238] [<80360fb4>] device_driver_attach+0x74/0x7c
[   14.095439] [<8036101c>] __driver_attach+0x60/0x100
[   14.100313] [<8035e864>] bus_for_each_dev+0x68/0xa4
[   14.105172] [<8035fbd8>] bus_add_driver+0x1f4/0x204
[   14.110028] [<803616b0>] driver_register+0x84/0x148
[   14.114884] [<8000161c>] do_one_initcall+0x7c/0x1dc
[   14.119749] [<800b4598>] do_init_module+0x60/0x228
[   14.124518] [<800b6778>] load_module+0x1f9c/0x2530
[   14.129287] [<800b6e78>] sys_init_module+0x16c/0x1a8
[   14.134236] [<80014578>] syscall_common+0x34/0x58
[   14.138918] Code: afb60028  afa3002c  2e310001 <ac770000> 12c200d5  00000000  8e020000  30430001  106000bb 
[   14.148627] 
[   14.150534] ---[ end trace 7f2fa1eee56348ae ]---
[   14.155156] Kernel panic - not syncing: Fatal exception

But if I set mtd-mac-address-increment = <(-1)>; for MT7613 - at least I'm able to log in.

Looks like that MT7613 is working, but MT7603 is not. Any suggestions how to debug this situation? :pray:

May be LED settings changed for wifi mt7603?, There is a kernel exception while setting LED.

Not sure what do you mean. Can I solve my problem just within dts file?

	leds {
		compatible = "gpio-leds";

		led_power: power {
			label = "green:power";
			gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
		};

		usb {
			label = "green:usb";
			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
			trigger-sources = <&ehci_port2>;
			linux,default-trigger = "usbport";
		};

		wan-orange {
			label = "orange:wan";
			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
		};

		lan {
			label = "green:lan";
			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
		};

		wifi5g {
			label = "green:wifi5g";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy1tpt";
		};

		wifi2g {
			label = "green:wifi2g";
			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		wan-green {
			label = "green:wan";
			gpios = <&gpio 45 GPIO_ACTIVE_LOW>;
		};
	};

I've thought that leds part won't affect so drastically for driver loading. There is wifi2g at GPIO 18 - but that is just output indicating that corresponding wi-fi is working. There is GPIO 16 for wifi5g, GPIO 16 state does not effect on loading MT7613/MT7615 driver. GPIO 18 state does not effect on loading MT7603 driver.

WARNING: CPU: 0 PID: 742 at backports-5.10.16-1/net/wireless/core.c:875 wiphy_register+0xd8c/0xd94 [cfg80211]

As of backports-5.10.16-1/net/wireless/core.c file at line 845 I have

874:	if (!have_band) {
875:		WARN_ON(1);
876:		return -EINVAL;
877:	}

Not sure what should I do, because this is just a warning.

I found something similar in old issues - https://github.com/abperiasamy/rtl8812AU_8821AU_linux/issues/22, but the issue was not solved yet.