[BPI-R64] PCIe issues

I got the errors by compiling on r64 only.

I mean compiling kernel in /usr/src/linux before starting gasket

I am getting the same error when I am compiling the kernel on R64

[email protected]:/usr/src/linux-headers-5.7.0-bpi-r64# ./build.sh 
do not run as root!
[email protected]:/usr/src/linux-headers-5.7.0-bpi-r64# sudo make
scripts/kconfig/conf  --syncconfig Kconfig
scripts/kconfig/conf: 1: scripts/kconfig/conf: Syntax error: "(" unexpected
scripts/kconfig/Makefile:71: recipe for target 'syncconfig' failed
make[2]: *** [syncconfig] Error 2
Makefile:588: recipe for target 'syncconfig' failed
make[1]: *** [syncconfig] Error 2
Makefile:699: recipe for target 'include/config/auto.conf.cmd' failed
make: *** [include/config/auto.conf.cmd] Error 2

Right,my build.sh blocks run by root by default…but you can disable this by adding a # at beginning of the exit line after the message

Alternatively you can run this directly on r64

make mt7622_bpi-r64_defconfig
make

Hi Frank, I received some help from Google coral team for using on BPI-R64.

I have received the following feedback The Coral driver requires pcie bus master support and that is not working with the mt7622.

Can we get some support from mt7622 in this area?

Got response from mtk. Root cause should be class == PCI_CLASS_NOT_DEFINED

Can you try 5.8-rc with the pci-class-patch?

You’ve wrote here that on 5.4 with pci-class-patch you got ressource collision error. On 5.8 i have official patchset. Maybe your problem results in power-limitation (there is a thread about mt7615 tx power)

got another answer:

Bpi-r64 pcie slot has hw issue, so we use MTK reference board to test it before and coral card was returned to BPI already so we cannot test it again.

About r64 HW issue, we just have solution to make it stable. Maybe you can ask him to rework the board.

1.Add two 100uf capacitance

2.short pin (red circle) or change to 3K resistance to remove pcie current limit <- it’ll cause system unstable when pcie device needs more power from system

i hope these issues are fixed with next r64 version, @sinovoip any info here?

Hi,

I have complied 5.8-rc kernel and loaded on R64. When loading the Gasket driver using sudo apt install I got the following error

[email protected]:/var/lib/dkms/gasket/1.0/build# cat make.log 
DKMS make.log for gasket-1.0 for kernel 5.8.0-rc6-bpi-r64 (aarch64)
Mon Jul 27 19:01:49 CST 2020
make: Entering directory '/usr/src/linux-headers-5.8.0-rc6-bpi-r64'
  AR      /var/lib/dkms/gasket/1.0/build/built-in.a
  CC [M]  /var/lib/dkms/gasket/1.0/build/gasket_core.o
/var/lib/dkms/gasket/1.0/build/gasket_core.c: In function ‘gasket_map_pci_bar’:
/var/lib/dkms/gasket/1.0/build/gasket_core.c:319:3: error: implicit declaration of function ‘ioremap_nocache’ [-Werror=implicit-function-declaration]
   ioremap_nocache(gasket_dev->bar_data[bar_num].phys_base,
   ^
/var/lib/dkms/gasket/1.0/build/gasket_core.c:318:42: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  gasket_dev->bar_data[bar_num].virt_base =
                                          ^
cc1: some warnings being treated as errors
scripts/Makefile.build:280: recipe for target '/var/lib/dkms/gasket/1.0/build/gasket_core.o' failed
make[1]: *** [/var/lib/dkms/gasket/1.0/build/gasket_core.o] Error 1
Makefile:1756: recipe for target '/var/lib/dkms/gasket/1.0/build' failed
make: *** [/var/lib/dkms/gasket/1.0/build] Error 2
make: Leaving directory '/usr/src/linux-headers-5.8.0-rc6-bpi-r64'

Is this function not available in 5.8-rc kernel? What do I need to fix this?

this was dropped in 5.6…in wifi-driver i changed to ioremap()

i have downloaded the commit d1aed33 and using the same where i am getting this error.

look at the commit i’ve posted itself…it is a way to fix gasket-code (i have done it to r2 wifi-driver and it links to upstream-commit which removes the ioremap_nocache for further information). you have to change gasket-code

have you modified your r64 like i’ve posted above (adding capacitor/removing resistor)

i have the hardware changes

I have updated the gasket_core.c by replacing ioremap_nocache as ioremap_cache

Now I get the following error

make[1]: Entering directory '/usr/src/linux-headers-5.8.0-rc6-bpi-r64'

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.

Makefile:719: recipe for target 'include/config/auto.conf' failed
make[1]: *** [include/config/auto.conf] Error 1
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-rc6-bpi-r64'
Makefile:12: recipe for target 'all' failed
make: *** [all] Error 2

on building the 5.8 kernel source on R64 following is the output

[email protected]:/usr/src/linux-headers-5.8.0-rc6-bpi-r64# ./build.sh 
do not run as root!
do not run as root!
Build Kernel
Cleanup Kernel Build
needed: make u-boot-tools bc gcc libc6-dev libncurses5-dev ccache libssl-dev
generate branch vars...
getting git branch: 
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

kernbranch:,gitbranch:
  HOSTLD  scripts/kconfig/conf
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
scripts/kconfig/conf.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
scripts/Makefile.host:112: recipe for target 'scripts/kconfig/conf' failed
make[2]: *** [scripts/kconfig/conf] Error 1
Makefile:606: recipe for target 'syncconfig' failed
make[1]: *** [syncconfig] Error 2
Makefile:711: recipe for target 'include/config/auto.conf.cmd' failed
make: *** [include/config/auto.conf.cmd] Error 2

In order to get the config i executed the command ./build.sh importconfig on R64 where I get following error

[email protected]:/usr/src/linux-headers-5.8.0-rc6-bpi-r64# ./build.sh importconfig
do not run as root!
import a defconfig file
Import r64 config
  HOSTLD  scripts/kconfig/conf
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
/usr/bin/ld: scripts/kconfig/conf.o: Relocations in generic ELF (EM: 62)
scripts/kconfig/conf.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
scripts/Makefile.host:112: recipe for target 'scripts/kconfig/conf' failed
make[1]: *** [scripts/kconfig/conf] Error 1
Makefile:606: recipe for target 'mt7622_bpi-r64_defconfig' failed
make: *** [mt7622_bpi-r64_defconfig] Error 2

oh, i see you have missing packages:

needed: make u-boot-tools bc gcc libc6-dev libncurses5-dev ccache libssl-dev

you can try steps advertised there ( make oldconfig && make prepare)

maybe building on r64 is not same as building with crosscompiler (if you downloaded built kernel from my gdrive/github-releases)

try make clean/mrproper and then importconfig (maybe build kernel) again

Before running the first ./build.sh command I had loaded the packages needed

I already tried make oldconfig && make prepare

Even this Fails

Please share link of your gdrive.

how have you “installed” the kernel-sources? is this a git-checkout or have you installed with deb/tar.gz?

try a “make clean” before the importconfig

files on my gdrive may cause but not fix this…

I did a make clean on the linux source in R64.

Then I executed the ./build.sh command to execute all the script related commands

After that I have compiled the Gasket source and i get the following Error.

[email protected]:/var/lib/dkms/gasket/1.0/source# make
make -C /lib/modules/5.8.0-rc6-bpi-r64/build M=/var/lib/dkms/gasket/1.0/source modules
make[1]: Entering directory '/usr/src/linux-headers-5.8.0-rc6-bpi-r64'
  CC [M]  /var/lib/dkms/gasket/1.0/source/gasket_core.o
  CC [M]  /var/lib/dkms/gasket/1.0/source/gasket_ioctl.o
  CC [M]  /var/lib/dkms/gasket/1.0/source/gasket_interrupt.o
  CC [M]  /var/lib/dkms/gasket/1.0/source/gasket_page_table.o
  CC [M]  /var/lib/dkms/gasket/1.0/source/gasket_sysfs.o
  LD [M]  /var/lib/dkms/gasket/1.0/source/gasket.o
  CC [M]  /var/lib/dkms/gasket/1.0/source/apex_driver.o
  LD [M]  /var/lib/dkms/gasket/1.0/source/apex.o
  MODPOST /var/lib/dkms/gasket/1.0/source/Module.symvers
ERROR: modpost: "dma_buf_detach" [/var/lib/dkms/gasket/1.0/source/gasket.ko] undefined!
ERROR: modpost: "dma_buf_put" [/var/lib/dkms/gasket/1.0/source/gasket.ko] undefined!
ERROR: modpost: "dma_buf_get" [/var/lib/dkms/gasket/1.0/source/gasket.ko] undefined!
ERROR: modpost: "dma_buf_unmap_attachment" [/var/lib/dkms/gasket/1.0/source/gasket.ko] undefined!
ERROR: modpost: "dma_buf_map_attachment" [/var/lib/dkms/gasket/1.0/source/gasket.ko] undefined!
ERROR: modpost: "dma_buf_attach" [/var/lib/dkms/gasket/1.0/source/gasket.ko] undefined!
scripts/Makefile.modpost:111: recipe for target '/var/lib/dkms/gasket/1.0/source/Module.symvers' failed
make[2]: *** [/var/lib/dkms/gasket/1.0/source/Module.symvers] Error 1
make[2]: *** Deleting file '/var/lib/dkms/gasket/1.0/source/Module.symvers'
Makefile:1669: recipe for target 'modules' failed
make[1]: *** [modules] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-rc6-bpi-r64'
Makefile:12: recipe for target 'all' failed
make: *** [all] Error 2

Looks like you need to compile kernel with dma_buf support

https://elixir.bootlin.com/linux/latest/A/ident/dma_buf_detach

At least CONFIG_DMA_SHARED_BUFFER on a quick look this seems enough (all functions listed are inside dma-buf.c and i see no idefs around

Hi Do I need to recompile and reinstall the kernel or just recompile on the R64

Imho recompile to compile the gasket,but reinstall to use :slight_smile:

In command ‘./build.sh config’ which setting refers to dma_buf support. Alternatively is it possible to directly provide this setting via some file?

Press / in menuconfig (build.sh config) to search and search for CONFIG_DMA_SHARED_BUFFER then press 1 and space to set,exit with save