This post will detail how to align your Linux kernel source code to your running kernel version (on your Pi). It will then give the commands to cross compile (build) the system on your desktop. It then gets you on the path of installing the compiled code into your Pi's file system so that it loads and runs.
In this case, we will talk about recompiling the Audio Injector Octo machine driver.
Fist thing is to install build prereqs on your build computer like this (on debian or ubuntu) :
Code: Select all
sudo apt install gcc-arm-linux-gnueabihf
Code: Select all
cat /proc/version
Code: Select all
git clone https://github.com/raspberrypi/linux.git
Code: Select all
cd linux
Code: Select all
$ ssh pi@192.168.0.114 'cat /proc/version'
Linux version 4.9.45-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #1031 SMP Fri Aug 25 19:02:16 BST 2017
Code: Select all
https://github.com/raspberrypi/linux/commits/rpi-4.9.y?after=8af328b2e65c58f5d7153b03a18f314a371c8fd1+349
I can now checkout the correct linux source code version to match my kernel :
Code: Select all
git checkout 3ce72830a8c8bba33c37ebe4bee71ac3177451b0
Code: Select all
export KERNEL=kernel7
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
Code: Select all
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
Once you are happy and want to test it out, you need to copy the ko module over to the Pi. I do it like so :
Code: Select all
export VER='4.9.45'
export HOST='192.168.0.114'
scp ./sound/soc/bcm/snd-soc-audioinjector-octo-soundcard.ko pi@$HOST:
ssh pi@$HOST 'sudo mv snd-soc-audioinjector-octo-soundcard.ko /lib/modules/'$VER'-v7+/kernel/sound/soc/bcm/'
Code: Select all
ssh pi@$HOST 'sudo reboot'
Matt