[Banana Pi BPI-R64] Mainline OpenWRT image

Or you can just add this patch to mt76

1 Like

mt76 driver takes reference to partition from device tree, here is resulting dts from openwrt:

	snand: [email protected] {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "spi-nand";
		spi-max-frequency = <104000000>;
		reg = <0>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			[email protected] {
				label = "bl2";
				reg = <0x0 0x80000>;
				read-only;
			};

			[email protected] {
				label = "fip";
				reg = <0x80000 0x200000>;
				read-only;
			};

			rf: [email protected] {
				label = "rf";
				reg = <0x280000 0x80000>;
			};

			[email protected] {
				label = "ubi";
				reg = <0x300000 0x7d00000>;
			};
		};
	};

skip-skip-skip

&wmac {
	mediatek,mtd-eeprom = <&rf 0x0000>;
	status = "okay";
};

I’d defined mtd partition with object id “rf” (rf: [email protected]) and referenced it as mediatek,mtd-eeprom parameter of wmac. mt76 driver reads mediatek,mtd-eeprom, checks that it is a mtd partition ref and extract data through kernel mtd subsystem. Take a look at https://github.com/openwrt/mt76/blob/67ed4d902c848bb3f94cf14b87b20e4814dadc82/eeprom.c#L27

So, in case of other systems (not openwrt) you can define snand with rf-partition and reference it in wmac node in device tree. Than, after boot, just flash eeprom data to that partition using mtd-utils. So, there is no need to touch anything on MMC/SD and rf data will be always with hardware.

I think this question is more suitable for this thread. I can’t make EC25-E 4G board to work in CN8 slot.

GPIO90 (499 as 409+90) seems to be set to out/high upon boot:

[    0.028706] gpio-499 (asm_sel): hogged as output/high

But the modem board is not detected:

[email protected]:/# lsusb 
Bus 002 Device 001: ID 1d6b:0003 Linux 5.10.51 xhci-hcd xHCI Host Controller
Bus 001 Device 001: ID 1d6b:0002 Linux 5.10.51 xhci-hcd xHCI Host Controller
[email protected]:/# ls /dev/tty
tty    ttyS0  ttyS1

And GPIO90 is eventually set to low level and I can’t change it. I always get a “Resource busy” error:

[email protected]:/# cat /sys/kernel/debug/gpio 
gpiochip0: GPIOs 409-511, parent: platform/10211000.pinctrl, pinctrl_moore:
 gpio-409 (                    |reset               ) in  hi IRQ 
 gpio-463 (                    |reset               ) out hi 
 gpio-490 (                    |cd                  ) in  lo IRQ ACTIVE LOW
 gpio-494 (                    |bpi-r64:pio:blue    ) out lo 
 gpio-498 (                    |bpi-r64:pio:green   ) out lo 
 gpio-499 (                    |asm_sel             ) in  lo 
 gpio-511 (                    |wps                 ) in  hi IRQ 
[email protected]:/# echo 499 > /sys/class/gpio/export
ash: write error: Resource busy

fw_setenv bootconf config-mt7622-bananapi-bpi-r64-sata or fw_setenv bootconf config-mt7622-bananapi-bpi-r64-pcie1 have no effect on GPIO90 state.

Gpio90 is for sata and defined in dts.

According to Getting started with BananaPi R64 I need to set GPIO90 to high level and PCIe supports EC-25 4G module.

Nevertheless I can’t figure out why I end up with GPIO90 set to in/lo instead of out/high as should be for PCIe mode.

In the recent OpenWrt builds you can choose between PCIe mode (default) and SATA mode by selecting different device-tree overlay blobs at boot. That controls whether SATA or PCIe is active and also locks the asm_sel GPIO to the matching level. As PCIe is the default, you should not need to modify anything in order for both, PCIe and USB signals, to arrive at CN8. However, as the current supplied on the slot is limited, many modems don’t come up unless you change the current limit (see other reports in the wiki and forums about that).

Thank you. I’ve modified CN25 to increase current limit ([BPI-R64] OpenWRT kernel 5.4.40 running from eMMC), I need t do the same for CN8, right?

UPD: I changed the current limit (changed resistor to 3kOhm as in the post above), but it had no effect. GPIO90 is still set to in/lo and no USB modem is present in the system.

[email protected]:/# cat /sys/kernel/debug/gpio 
gpiochip0: GPIOs 409-511, parent: platform/10211000.pinctrl, pinctrl_moore:
 gpio-409 (                    |reset               ) in  hi IRQ 
 gpio-463 (                    |reset               ) out hi 
 gpio-490 (                    |cd                  ) in  lo IRQ ACTIVE LOW
 gpio-494 (                    |bpi-r64:pio:blue    ) out lo 
 gpio-498 (                    |bpi-r64:pio:green   ) out lo 
 gpio-499 (                    |asm_sel             ) in  lo 
 gpio-511 (                    |wps                 ) in  hi IRQ

Unfortunately /sys/kernel/debug/gpio doesn’t really reflect reality for gpio-hogs. Also, the USB lanes of the slot should not even be affected from what ever GPIO is set to, because that just controls whether the shared SATA/PCIE pins of the SoC are either connected to the SATA port or to the PCIe lane of the mPCIe slot.

And as the EC-25 only uses the USB (and SIM card and power supply) pins of the slot which are always available on CN8 (and not available on CN25 at all afaik) it should work as soon as it has enough power to come up. I’ve heard reports from users that power is not supplied by the board in case of SATA being selected as it depends on the PCIe controller being enabled, apparently. I had no time yet to verify or fix that and if you haven’t manually switched the installation to SATA mode, you don’t need to be concerned about that.

Regarding the slot, I also see the same line

 gpio-499 (                    |asm_sel             ) in  lo 

on my system and the MT7615E module sitting in the CN8 slot works great. So maybe we miss some USB port nodes in DTS? I never had the chance to try the USB pins of the slot as I only got NGFF modem in NGFF->USB3 adapter externally.

Thanks. I think I misguided you and myself with GPIO. I found out that mainline image does see the EC25 board (http://downloads.openwrt.org/snapshots/targets/mediatek/mt7622/openwrt-mediatek-mt7622-bananapi_bpi-r64-sdcard.img.gz) but if I compile the image myself with all the defaults from scratch the modem is missing from cat /sys/kernel/debug/usb/devices. Below is the output from mainline image.

[email protected]:/# cat /sys/kernel/debug/usb/devices 

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 5.10
S:  Manufacturer=Linux 5.10.52 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=1a0c0000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=2c7c ProdID=0125 Rev= 3.18
S:  Manufacturer=Android
S:  Product=Android
C:* #Ifs= 5 Cfg#= 1 Atr=a0 MxPwr=500mA                                   
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)     
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms                              
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms                              
I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
E:  Ad=87(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=89(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
E:  Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev= 5.10
S:  Manufacturer=Linux 5.10.52 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=1a0c0000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

So now I need to find out the difference between mainline image and default build with Bananapi Bpi-R64 profile.

There is a quite straight answer to that and it’s here:

https://downloads.openwrt.org/snapshots/targets/mediatek/mt7622/config.buildinfo

1 Like

Thank you. Now that’s a mystery.

I’ve recompiled OpenWrt from scratch (with make distclean and git pull) with the above config.buildinfo and the only patch from @frank-w to make mt76 module take calibration data from files. And 4G EC25 module isn’t listed.

[email protected]:/# cat /sys/kernel/debug/usb/devices 

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480  MxCh= 2
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 5.10
S:  Manufacturer=Linux 5.10.52 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=1a0c0000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=02 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=5000 MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  0, #Iso=  0
D:  Ver= 3.00 Cls=09(hub  ) Sub=00 Prot=03 MxPS= 9 #Cfgs=  1
P:  Vendor=1d6b ProdID=0003 Rev= 5.10
S:  Manufacturer=Linux 5.10.52 xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=1a0c0000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

What am I missing?

P. S. Maybe there is a way to make mainline image take WiFi calibration data from files?

You can use mainline snapshot SDK to build only package/kernel/mt76 from source and replace the wifi-related kernel modules.

Looks like SDK won’t work for me as I’m using MacOS.

Is there any other way I can reproduce mainline image exactly as it is apart from mt76 patch?

I’m afraid using a Linux x86_64 VM is the most straight forward way to go. Reproducing the mainline image using the config seed can also work on Darwin or architectures other than x86_64, but you really have to build with all kmods (incl. those from feeds) enabled for the kernel to be compatible (and that may turn out to be more complicated than just using SDK inside a Ubuntu VM)

Sorry for asking so much noobs questions, but could you be more specific? I’ve got a Linux VM with mainline SDK up and running, but after performing these commands mt76 source code is nowhere to be found. And I can’t figure out where to put .patch files.

tar -xf openwrt-sdk-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64.tar.xz 
cd openwrt-sdk-mediatek-mt7622_gcc-8.4.0_musl.Linux-x86_64/
./scripts/feeds update -a
./scripts/feeds install mt76
make menuconfig
make feeds/base/package/kernel/mt76 download
make feeds/base/package/kernel/mt76 prepare
make -j8 package/feeds/base/mt76/compile

You can create a folder feeds/base/package/kernel/mt76/patches/ and put your patch there.

From the looks of it it has no effect since no source files ever appear in mt76 folder. I know that there should be a eeprom.c file but it’s nowhere to be found in the SDK folder.

$ ls feeds/base/package/kernel/mt76
Makefile  patches

After installing the newly compiled mt76-test_2021-07-15-bbebea7d-4_aarch64_cortex-a53.ipk nothing has changed.

Here’s example patch to hardcode mt7622 wmac eeprom.

1 Like

Thank you, I know this approach. But the problem I face is not the patch itself, but the fact that it’s not applied.

Or that self-compiled OpenWrt image for BPI-R64 is different from the one precompiled in mainline repo.

If you create a folder patches in feeds/base/package/kernel/mt76 and place the patch there it should get applied during build. Maybe watch the build to see if that’s really happening:

make package/mt76/{clean,compile} V=99
1 Like