0

I am not very familiar with Linux, so may be my question is a little bit foolish.

I would like to compile kernel module without recompiling the kernel (USB Wi-Fi stick driver for MT7106U chip). I have the source code and instructions.

As I understand, the module should be compiled with the same gcc version, that was used for kernel build. Currently I have this configuration:

Linux raspberrypi 4.9.59+ #1047 Sun Oct 29 11:47:10 GMT 2017 armv6l GNU/Linux
gcc (Raspbian 6.3.0-18+rpi1) 6.3.0 20170516

How to find which compiler version was used to build kernel and how to change gcc version for this correctly? I tried

sudo update-alternatives --config gcc

but I got

update-alternatives: error: no alternatives for gcc

Should I uninstall current version of gcc or it can be installed along with this one?

Also I need Raspberry Pi linux headers using rpi-source. I have found this one:

https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source

Is this correct link?

Thanks.

3 Answers 3

1

I do not believe that is the right link. You ought to be able to build a custom kernel with the relevant packages, which I think could be: linux-kbuild and linux-source and dependences although the exact process on an RPi is not one I have engaged with...

1

first I'll address the headers, most distros provide a convenience package for you to download the headers for your current kernel, on raspbian this is in the package raspberrypi-kernel-headers so a simple apt-get install ... will get the correct headers.

secondly I'm not 100% sure about the specifics regarding matching exact compiler options, but where i was writing this kernel extension I had no issues using the version of gcc that came with the distro.

So all you should need to is install the headers from the package, symlink them to where the driver is expecting/able to find them and then run the commands to build/install it.

hopefully this plus the instructions/makefile in my repo help you.

0

As others have pointed out above, I do think gcc version irrelevant in compiling a Linux kernel. That said, to find out a version of gcc on your platform, just run gcc -v from your command prompt and gcc will print out some information about its version along with its build specs (see below).

[habibie@kali:/home/local/PEOPLE/habibie 1%] ~ gcc -v

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabi/8/lto-wrapper Target: arm-linux-gnueabi Configured with: ../src/configure -v --with-pkgversion='Debian 8.2.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=arm-linux-gnueabi- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv5te --with-float=soft --disable-werror --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi

Thread model: posix gcc version 8.2.0 (Debian 8.2.0-6) [habibie@kali:/home/local/PEOPLE/habibie 2%] ~

On a debian distro as well as its derivatives, i.e. kali, raspbian, ubuntu, etc., alternatives has already been installed by default under dpkg (see here and the comment above it). As such, there is no need to uninstall the existing gcc package and just use update-alternatives to set the version of gcc you want as the default. You can run which update-alternatives to find out where it is installed in your device's rootfs partition.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.