Dutchdoc
Posts: 4
Joined: Thu Mar 29, 2018 8:50 pm

Building the Kernel, get error during module install

Fri Mar 30, 2018 7:07 pm

I'm building a Raspbian kernel from the latest sources, and following the instructions at https://www.raspberrypi.org/documentati ... uilding.md
pretty much to the letter.

I'm building it on a fresh install of Debian 9 Stretch, on an 8 core PC.

The build of the kernel completes just fine .. no errors.

But when I get to installing the modules:

sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/media/paul/rootfs modules_install

I get some error messages about the compiler not being found, then a ton of INSTALL lines and then it ends with another error about the compiler not being found, despite just having built the kernel. When I then invoke the compiler with --version, it's there!

So when I run the above command, I get this ... (I added the testing of the compiler it's saying is missing!):

paul@paulux:~/rpi3/linux$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/media/paul/rootfs modules_install
./scripts/gcc-version.sh: line 26: arm-linux-gnueabihf-gcc: command not found
./scripts/gcc-version.sh: line 27: arm-linux-gnueabihf-gcc: command not found
make: arm-linux-gnueabihf-gcc: Command not found
make: arm-linux-gnueabihf-gcc: Command not found
INSTALL arch/arm/crypto/aes-arm-bs.ko
INSTALL arch/arm/crypto/aes-arm.ko
INSTALL arch/arm/crypto/sha1-arm-neon.ko

-- then a ton more INSTALL lines, and then it all ends with:

INSTALL sound/usb/misc/snd-ua101.ko
INSTALL sound/usb/snd-usb-audio.ko
INSTALL sound/usb/snd-usbmidi-lib.ko
make: arm-linux-gnueabihf-gcc: Command not found
DEPMOD 4.14.31-v7+

paul@paulux:~/rpi3/linux$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) 4.8.3 20140303 (prerelease)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Anyone any idea what's going on here? Or some other command missing?

~ Paul

asavah
Posts: 373
Joined: Thu Aug 14, 2014 12:49 am

Re: Building the Kernel, get error during module install

Fri Mar 30, 2018 8:15 pm

Don't use sudo to build the kernel, it's not needed, it's not used in the docs and it eats up your PATH variable with the path to cross-compiler (man sudoers , search for secure_path).

It's a common newbie mistake to use sudo even when it's not needed and maybe harmful,
generally sudo is not need to BUILD the software and it's considered a bad practice compiling stuff under root user.

Or if you insist on using sudo pass the absolute path to your cross-compiler eg. CROSS_COMPILE=/home/blah/foo/bar/arm-whatever-gcc-

Dutchdoc
Posts: 4
Joined: Thu Mar 29, 2018 8:50 pm

Re: Building the Kernel, get error during module install

Fri Mar 30, 2018 8:26 pm

I'm not building the kernel here, I already did that, and indeed without 'sudo', and it completed successfully.

What I'm doing here is installing the modules, which DOES need sudo, exactly as outlined in the instructions at https://www.raspberrypi.org/documentati ... uilding.md

Btw, I just ran the exact same exercise on a fresh install of Ubuntu 16.04.4 LTS, and ran in exactly the same issue.

User avatar
allfox
Posts: 452
Joined: Sat Jun 22, 2013 1:36 pm
Location: Guang Dong, China

Re: Building the Kernel, get error during module install

Sat Mar 31, 2018 8:54 am

OP is right, module installation needs sudo.

You would need to include the compiler binary path in root's PATH environment variable.

Mostly, I believe, that people run into this problem because they use the Raspbian official cross compiler which is git cloned into somewhere.

However, you could use the Debian or Ubuntu supplied cross compiler to build the kernel. Apt utility would set the environment ready for building and module installation.

Usually, Debian or Ubuntu would have a higher version compiler than the official 4.8.

Just for info: you could use the -j parameter when call make.

make -j 8 .......

This would use all your 8 CPU cores when building the kernel.

Dutchdoc
Posts: 4
Joined: Thu Mar 29, 2018 8:50 pm

Re: Building the Kernel, get error during module install

Mon Apr 02, 2018 4:38 pm

Thanks to both commenters ...

Indeed, SUDO messes with the PATH environment variable (which you can disable by commenting out the "Defaults secure_path=" line in your sudoers file).

And indeed, because of that you will need to specify the full path to your compiler, or, which is way easier, and a more generic solution, add "env PATH=$PATH" to your command line, thusly:

sudo env PATH=$PATH make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

That takes care of the missing cross compiler ...

Problem solved!

Thanks guys!

embedded.bluez
Posts: 1
Joined: Mon Jan 28, 2019 12:35 pm

Re: Building the Kernel, get error during module install

Thu May 16, 2019 8:54 am

I faced the similar issue while installing the modules.

Code: Select all

testsys@ubuntu:~/linux$ sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install
./scripts/gcc-version.sh: line 26: arm-linux-gnueabihf-gcc: command not found
./scripts/gcc-version.sh: line 27: arm-linux-gnueabihf-gcc: command not found
make: arm-linux-gnueabihf-gcc: Command not found
make: arm-linux-gnueabihf-gcc: Command not found
  INSTALL arch/arm/crypto/aes-arm-bs.ko
...
lots of install messages
...
make: arm-linux-gnueabihf-gcc: Command not found
DEPMOD  4.19.42-v7+

So following the previous discussion, I commented out Defaults secure_path in /etc/sudoers in my host system and I ran the the module install command as:

Code: Select all

sudo env PATH=$PATH make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install



RPi boots up with the new kernel however I am not able to compile kernel modules(hello world module). I am getting the following error:

Code: Select all

pi@raspberrypi:~ $ make
make -C /lib/modules/4.19.42-v7+/build/ M=/home/pi modules
make[1]: *** /lib/modules/4.19.42-v7+/build/: No such file or directory.  Stop.
Makefile:3: recipe for target 'all' failed
make: *** [all] Error 2

I checked for the build directory and it looks like its a broken symbolic link to the directory of my host system where i cross compiled
the kernel.

Code: Select all

pi@raspberrypi:~ $ file /lib/modules/`uname -r`/build
/lib/modules/4.19.42-v7+/build: broken symbolic link to /home/testsys/linux
pi@raspberrypi:~ $

I am using a fresh installation of Ubuntu 16.04.5 LTS, 2018-11-13 raspbian stretch lite image on RPi3B+ and I am following the cross compilation instructions from https://www.raspberrypi.org/documentati ... uilding.md.

Can you please suggest what am I missing here?

Thanks.

Return to “General discussion”