Page 1 of 1

Building USB2CAN driver fails

Posted: 14 May 2019, 11:32
by porteous
I am getting the this error while building a driver on the RevPi Connect running Raspbian Stretch:

Code: Select all

scripts/basic/fixdep: not found
I used the instructions at http://www.8devices.com/wiki/usb2can:compile-raspberry to build the driver:

Code: Select all

sudo apt-get update
sudo apt-get install git raspberrypi-kernel raspberrypi-kernel-headers can-utils
git clone https://github.com/krumboeck/usb2can.git
cd usb2can
sudo make
I get this error when running the make command:

Code: Select all

make -C /lib/modules/4.9.76-rt60-v7+/build M=/home/pi/usb2can modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.76-rt60-v7+'
  CC [M]  /home/pi/usb2can/usb_8dev.o
/bin/sh: 1: scripts/basic/fixdep: not found
Here is the kernel version:

Code: Select all

uname -a
Linux RevPi11760 4.9.76-rt60-v7+ #1 SMP PREEMPT RT Tue, 12 Mar 2019 15:19:36 +0100 armv7l GNU/Linux
Could this be an error in the RevPi distribution? I found a similar situation which was due to a distro error.

Thanks,
Ed

Re: Building USB2CAN driver fails

Posted: 06 Jun 2019, 10:58
by porteous
Has anyone else managed to compile an external module using kernel 4.9.76-rt60-v7+?

I've tried a couple of different modules and I always get:

Code: Select all

/bin/sh: 1: scripts/basic/fixdep: not found
Thanks,
Ed

Re: Building USB2CAN driver fails

Posted: 13 Jun 2019, 12:03
by porteous
The problem is that the update.sh script includes a function copy_files() which doesn't copy the script binaries (fixdep, genksyms, etc.) from the kbuild and kbuild7 directories into the header directories, so the header directories on the RevPi do not contain these script binaries. In contrast, the base Raspberry Pi header directories do contain these binaries. I suggest that update.sh should be modified to copy these binaries into the release header directories.

A workaround is to run on the Revolution Pi:

Code: Select all

cd /usr/src/linux-headers-4.9.76-rt60-v7+/
sudo make scripts
sudo make scripts_basic
This allows me to build my external modules.

Re: Building USB2CAN driver fails

Posted: 09 Jun 2020, 14:50
by lukas
Hi porteous,

thanks for the suggestion and apologies for the belated reply.

The problem is that we cross-compile the kernel on x86. (Compiling on a RevPi would be too slow.) The kernel's build system only builds tools like "fixdep" for the host architecture on which the compiler runs. It doesn't build them for the target architecture when cross-compiling. That's the reason why we couldn't ship those tools with our raspberrypi-kernel-headers package. The Raspberry Pi Foundation seems to compile the kernel on a Raspberry Pi (or possibly in an ARM VM), hence doesn't cross-compile and is able to ship the tools in their raspberrypi-kernel-headers package.

To overcome this problem, I've extended the kernel's build system such that it optionally cross-compiles and installs the module build tools. This change is contained in the top-most commit on our revpi-4.19 branch and will ship as part of the kernel update and accompanying image which we'll release this month.