add pcan-linux to yocto-based distribution

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
Vincent Daanen
Posts: 3
Joined: Mon 9. Apr 2018, 10:14

add pcan-linux to yocto-based distribution

Post by Vincent Daanen » Mon 9. Apr 2018, 15:14

Hi,

I'm building an embedded system which uses a mcpie-to-can board.
The motherboard is a Intel J1900 based mother board (so x86_64 processor type).

I added a recipe to my layer but build of "peak-linux-driver-8.5.1.tar.gz" failed.
The first time, it failed because the popt.h file was not found.
I followed the advice given in this thread .. That's the reason of the do_compile function.
(see below)

Now, when compiling with this recipe, the process fails with the following error: implicit declaration of function 'pci_enable_msi_range'; did you mean 'pci_enable_msix_range'?
Moreover, it seems that the makefile will create a cross-compiled module because it assumes that the system running the makefile is the target system.

So is the a work-in-progress which aims at making makefiles of the archive compliant with Yocto?
If not, can someone help me to fix the compilation error reported just above?

Thanks

Vincent

Ps: sorry for the long post..

Yocto Recipe

Code: Select all

SUMMARY = "Recipe to add peaksystem CAN drivers to kernel"
LICENSE = "CLOSED"

inherit module
# The inherit of module.bbclass will automatically name module packages with
# "kernel-module-" prefix as required by the oe-core build environment.

KERNEL_MODULE_PACKAGE_SUFFIX = ""
SRC_URI = "https://www.peak-system.com/fileadmin/media/linux/files/peak-linux-driver-8.5.1.tar.gz \
		"
SRC_URI[md5sum] = "cfccfaff7f4f34a12fba6ec7989c9906"
SRC_URI[sha256sum] = "39a4ad75e890d8915999c9df2136a1b46649665b983e205dd0c67cd3b7d1387b"

S = "${WORKDIR}"

do_compile(){
	#cd ${S}/${PN}-${PV}/driver
	cd ${S}/peak-linux-driver-8.5.1/driver
	oe_runmake
}
Output of make

Code: Select all

DEBUG: Executing shell function do_compile
NOTE: make -j 4 KERNEL_SRC=/home/rd-otx/yocto/work/build/tmp/work-shared/genericx86-64/kernel-source
***
*** Host machine kernel version=4.13.0-38-generic
*** Driver kernel version=4.13.0-38-generic (4.13.0)
*** Path to kernel sources=/usr/src/linux-headers-4.13.0-38-generic
*** use KBUILD=yes
*** x86_64-poky-linux-gcc  -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse --sysroot=/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/recipe-sysroot version=7.2.0
***
make -C /usr/src/linux-headers-4.13.0-38-generic  SUBDIRS=/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver        EXTRA_CFLAGS="-I/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver        -DNO_DEBUG -DMODVERSIONS -DPARPORT_SUBSYSTEM -DUSB_SUPPORT -DPCI_SUPPORT -DPCIEC_SUPPORT -DISA_SUPPORT -DDONGLE_SUPPORT -DPCCARD_SUPPORT -DNO_NETDEV_SUPPORT	 -DNO_RT  -Wno-date-time" V=0 modules
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/usr/src/linux-headers-4.13.0-38-generic'
make[2]: Entering directory '/home/rd-otx/yocto/work/build/tmp/work-shared/genericx86-64/kernel-build-artifacts'
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_main.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_fops.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_fifo.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_filter.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_parse.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_sja1000.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_common.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_timing.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcanfd_core.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcanfd_ucan.o
  CC [M]  /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_pci.o
/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_pci.c: In function 'pcan_pci_enable_msi':
/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_pci.c:283:44: error: implicit declaration of function 'pci_enable_msi_range'; did you mean 'pci_enable_msix_range'? [-Werror=implicit-function-declaration]
 #define pcan_pci_enable_msi_range(a, b, c) pci_enable_msi_range(a, b, c)
                                            ^
/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_pci.c:332:18: note: in expansion of macro 'pcan_pci_enable_msi_range'
  pa->msi_count = pcan_pci_enable_msi_range(pa->dev, 1, can_count);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/usr/src/linux-headers-4.13.0-38-generic/scripts/Makefile.build:308: recipe for target '/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_pci.o' failed
make[3]: *** [/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver/src/pcan_pci.o] Error 1
/usr/src/linux-headers-4.13.0-38-generic/Makefile:1550: recipe for target '_module_/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver' failed
make[2]: *** [_module_/home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/peak-linux-driver-8.5.1/driver] Error 2
make[2]: Leaving directory '/home/rd-otx/yocto/work/build/tmp/work-shared/genericx86-64/kernel-build-artifacts'
Makefile:145: recipe for target 'sub-make' failed
make[1]: *** [sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.13.0-38-generic'
Makefile:417: recipe for target 'all' failed
make: *** [all] Error 2
ERROR: oe_runmake failed
WARNING: /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/temp/run.do_compile.512:1 exit 1 from 'exit 1'
ERROR: Function failed: do_compile (log file is located at /home/rd-otx/yocto/work/build/tmp/work/genericx86_64-poky-linux/kernel-module-peaksystem/1.0-r0/temp/log.do_compile.512)

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

Re: add pcan-linux to yocto-based distribution

Post by M.Maidhof » Mon 9. Apr 2018, 15:36

Hi,

which CAN hardware from PEAK do you want to use on your system?

regards

Michael

Vincent Daanen
Posts: 3
Joined: Mon 9. Apr 2018, 10:14

Re: add pcan-linux to yocto-based distribution

Post by Vincent Daanen » Mon 9. Apr 2018, 15:55

Hi,

this one with one channel
(i.e. PCAN-miniPCIe Single Channel IPEH-003048)
Last edited by M.Gerber on Tue 10. Apr 2018, 09:06, edited 1 time in total.
Reason: Added the product name the link is pointing to.

Vincent Daanen
Posts: 3
Joined: Mon 9. Apr 2018, 10:14

Re: add pcan-linux to yocto-based distribution

Post by Vincent Daanen » Tue 10. Apr 2018, 08:19

Hi,
just to give indications for people who may run into same trouble: I found a yocto layer which provides a recipe to add pcan to the image.
I could use it but at the moment, no pcan driver exists in the image...
Last edited by M.Gerber on Tue 10. Apr 2018, 08:40, edited 1 time in total.
Reason: Edited non-working link

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: add pcan-linux to yocto-based distribution

Post by S.Grosjean » Tue 10. Apr 2018, 11:14

Hello,

Strange compilation error that should not exist since pci_enable_msi_range() is used by the pcan driver only for Kernels in range [3.14 .. 4.10[, while the logs of the "make" command says it compiles the driver with the headers of Kernel v4.13.x...

Do you confirm that the version of the Kernel that runs in your embedded system is 4.13.x?

Up to now, we didn't cross-compile pcan with Yocto but with several other embedded cross-compilation environments. Generally speaking, and according to the User Guide, cross-compiling pcan should be made like this:
  • Specifying KERNEL_LOCATION to the Kernel headers of the target Kernel
  • Defining the global CC variable to the cross-compiler of the target arch
According to your make logs, I think CC is ok. But what about KERNEL_LOCATION? Could you change KERNEL_SRC into KERNEL_LOCATION in your make cmd line? If not, you might try replacing all occurrences of "KERNEL_LOCATION" by "KERNEl_SRC"in pcan/driver/Makefile.

Note that this last proposal is ONLY a temporary workaround, to first try to fix where your own problem is located.

Regards,

Stéphane
— Stéphane

Post Reply