[BPI-R4] how to activate key B PCIe2 @ 11280000? [solved]

The title says it all … the USB port of the B. key is working, the pcie link is not. it states “link down”. According to BPI-R4 schematic diagram, this has nothing to do with the shared usb/pcie combo phy, as the usb port is routed in a different way. I’d still like to use the pcie2 link after all. In the dts file, it states “active”, so it SHOULD work … Does anybody know a way (probably using a dtb overlay) to activate the pcie2 link?

Afaik pci2 needs xphy-patch

Maybe this helps: [WIP/RFC] mediatek: switch to Linux 6.1 and add BananaPi BPi-R4 by dangowrt · Pull Request #14140 · openwrt/openwrt · GitHub

that might help … I applied it, but still get the warning “pcie link down” maybe the key b → key a+e adapter (testing using a M.2 A+E adapter) is bad?

Do not know :slight_smile: maybe @dangowrt can tell whats needed

@jpsollie which codebase do you use?

PCIe2 doesn’t work for me despite the xphy patch (and having disabled xhci controller 0x11190000). I could test it only recently because I didn’t have any device fitting into that M.2 socket.

@jpsollie Using pcie@11280000 always needs to setup the usb/pcie combo PHY because the pins for this PCIe bus are shared with the pins for another USB 3 host controller (which isn’t used on on the R4).

Now I can clearly see that SnapDragon X55-based PCIe modem does get detected with SinoVoip’s image but does not with vanilla Linux. Could be we are missing a clock, and I’ve spent a day or two digging into that, but didn’t find a way to make it work.

Thank you! I can already test using @sinovoip 's image then, It hopefully tells me whether my key m → minipcie adapter has the pcie pins actually connected, or only the usb pins. Let me know whether there’s something else I should test!

I’m using openwrt master with dangowrt’s bpi-r4 branch mergef

So I tested using the img file on the wiki, the link is not coming up, I think the adapter is not forwarding the pcie link, I’ll order myself another one

@dangowrt: congrats on getting the BPI-R4 upstreamed! I re-built the upstreamed openwrt, but right now I get this error during startup:

[    1.724181] mtk-xsphy usb-phy@11e10000: incompatible phy type
[    1.730017] mtk-pcie 11280000.pcie: failed to get max link width
[    1.943471] mtk-pcie 11280000.pcie: PCIe link down, ltssm reg val: 0x1
[    1.950120] mtk-pcie: probe of 11280000.pcie failed with error -110

Are you sure the issue isn’t at the driver? It looks like the mtk-xsphy isn’t accepting the phy, no?

EDIT: forget about this, I wasn’t booting the correct image and ended up with prebuilt image on sdcard, sorry

How did you compile the @sinovoip github openwrt image? The image on the wiki doesn’t work, and defconfig → build sdcard of the github branch for bpi-r4 results in a compile error while building the kernel

Here is written that compile works with ubuntu 20.4

Which os do you use for building?

I guess newer gcc does not work because of additional checks. You can try using oldest gcc you have on your current system…ubuntu has different versions you can install

I’m building using gentoo. Here’s something about the build system:

Portage 3.0.61 (python 3.11.8-final-0, default/linux/amd64/17.1, gcc-13, glibc-2.38-r11, 6.8.0-rc5release+ x86_64)
System uname: Linux-6.8.0-rc5release+-x86_64-AMD_100-000000011-11-with-glibc2.38
KiB Mem:   131795560 total,  28857004 free
KiB Swap:  207393772 total, 207393772 free
Timestamp of repository gentoo: Tue, 20 Feb 2024 23:15:00 +0000
Head commit of repository gentoo: c13f39be6f5f2b8d6e777cf6eb99d3a1b0ae629a
Timestamp of repository eras-overlay: Tue, 13 Feb 2024 15:18:28 +0000
Head commit of repository eras-overlay: a4ffe0ed8e83f19ef76d30433745020382790fef

Timestamp of repository guru: Wed, 21 Feb 2024 01:48:26 +0000
Head commit of repository guru: f07ae4d3ef35662ecd16e8ab2bda597e3ef13f0c

sh bash 5.2_p26
ld GNU ld (Gentoo 2.41 p5) 2.41.0
distcc 3.4 x86_64-pc-linux-gnu [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p26::gentoo
dev-build/autoconf:        2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.28.3::gentoo
dev-build/libtool:         2.4.7-r2::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.3.2::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r1::gentoo
dev-lang/python:           3.10.13_p3::gentoo, 3.11.8_p1::gentoo
dev-lang/rust:             1.74.1::gentoo
sys-apps/baselayout:       2.14-r2::gentoo
sys-apps/openrc:           0.53::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/binutils:        2.41-r5::gentoo, 2.42-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           17.0.6::gentoo
sys-devel/gcc:             12.3.1_p20231215::gentoo, 13.2.1_p20240210::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             17.0.6::gentoo
sys-devel/llvm:            17.0.6::gentoo
sys-kernel/linux-headers:  6.7::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r11::gentoo

And the error of openwrt compile:

ENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7988/linux-5.4.260/user_headers ] || LD_PRELOAD="/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/staging_dir/host/lib/ldlogger.so" 
CC_LOGGER_KEEP_LINK=true make -C /home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7988/linux-5.4.260 KCFLAGS="-fmacro-prefix-map=/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl=target-aarch64_cortex-a53_musl -fno-caller-saves " HOSTCFLAGS="-O2 -I/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/staging_dir/host/include  -Wall -Wmissing-prototypes -Wstrict-prototypes" CROSS_COMPILE="aarch64-openwrt-linux-musl-" ARCH="arm64" KBUILD_HAVE_NLS=no KBUILD_BUILD_USER="" KBUILD_BUILD_HOST="" KBUILD_BUILD_TIMESTAMP="Fri Feb  2 10:27:34 2024" KBUILD_BUILD_VERSION="0" HOST_LOADLIBES="-L/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/staging_dir/host/lib" KBUILD_HOSTLDLIBS="-L/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/staging_dir/host/lib" CONFIG_SHELL="bash" V=1  cmd_syscalls=  KERNELRELEASE=5.4.260 CC="aarch64-openwrt-linux-musl-gcc"
INSTALL_HDR_PATH=/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7988/linux-5.4.260/user_headers headers_install
make -f ./scripts/Makefile.build obj=scripts/basic 
make[5]: Entering directory '/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7988/linux-5.4.260'
scripts/Makefile.build:42: /scripts/basic/Makefile: No such file or directory
make[5]: *** No rule to make target '/scripts/basic/Makefile'.  Stop.
make[5]: Leaving directory '/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7988/linux-5.4.260'
make[5]: *** [Makefile:530: scripts_basic] Error 2
make[4]: *** [Makefile:32: /home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7988/linux-5.4.260/.configured] Error 2
make[4]: Leaving directory '/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/target/linux/mediatek'
make[3]: *** [Makefile:11: compile] Error 2
make[3]: Leaving directory '/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/target/linux' 
time: target/linux/compile#0.54#0.02#0.55                                       ERROR: target/linux failed to build.
make[2]: *** [target/Makefile:30: target/linux/compile] Error 1
make[2]: Leaving directory '/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02'  
make[1]: *** [target/Makefile:23: 
/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/staging_dir/target-aarch64_cortex-a53_musl/stamp/.target_compile] Error 2
make[1]: Leaving directory '/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02'                   
make: *** [/home/janpieter/openwrt_kernel_trees/BPI-R4-MT76-OPENWRT-V21.02/include/toplevel.mk:230: world] 
Error 2

Is your crosscompiler (aarch64-linux-gnu-gcc) also v12? Maybe you can try lower version (i guess around 9 should work).

How does the system cross-compiler get involved when the openwrt is using musl? EDIT: and yes, using 13, actually

ah, you’re right, openwrt first compiles his own crosscompiler, forgot this.

1 Like

Exactly. I also took a look at the failing makefile, It looks like this:

# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)

So it looks like the variable kbuild-dir isn’t initialized properly, leading to a


call, whereas


would actually work. Nonetherless, when compiling the kernel, it should already use the openwrt compiler @sinovoip1 @sinovoip : any suggestions?

The pcie2 does not yet work with mainline openwrt,so it is a bit different case in this thread.

Also, as far as the issue with the makefile you’re running into. As soon as I switched to ubuntu 20.04 AND was using 5.4 kernel, that error went away. Even if you correct the Makefile you run into more errors later. The system you’re building on is too new.

Yes, by default, I’m using openwrt master branch, But I’d like to check whether my key b → key e adapter works for pcie. No doubt it will work after some time on openwrt/master, but I’d like to check first. I’ll create a ubuntu vm and build it on that one

so I created a ubuntu 20.04 server vm, installed necessary packages, ran make defconfig, menuconfig → select BPI-R4 SD, enable target specific packages, but I still do not succeed at building a minimal openwrt distro Has anyone a (minimal) binary SD card image which I could use? the only thing it really needs is lspci and dmesg (or busybox for all I care)