There have been a few comments recently about compilation of the "Cirrus-Logic" Linux kernel, so I thought I'd post my recipe. This is for native compilation running on a fresh installation of Rasbian 2014-12-24 (2014-12-24-wheezy-raspbian.zip). It takes about 10 hours so let it run overnight. The comments are minimal, but the process is well described in the Debian documentation.
NB this will compile the v3.12 kernel, which only works on the original Raspberry Pi series. It will not work on an Raspberry Pi 2.
# How to recompile the Raspberry-Pi kernel
# see http://elinux.org/Raspberry_Pi_Kernel_Compilation
### PREREQUISITES : install compiler (~2MB of disk space)
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y install gcc make bc screen ncurses-dev
### get source for alternative kernel
mkdir ~/tmp
cd ~/tmp
git init
git clone --depth 1 https://github.com/CirrusLogic/wiki-content.git # download audio-card config scripts
mv wiki-content/scripts ~/
rm -rf wiki-content
git clone -b rpi-3.12.y --depth 1 https://github.com/CirrusLogic/rpi-linux.git # download kernel source
tar -czvf rpi-kernel-3-12-33-cirrus.tgz rpi-linux # save source as tar for next time
#tar -xzvf rpi-kernel-3-12-33-cirrus.tgz # extract source from saved tar instead of re-downloading
cd rpi-linux
### configure & compile kernel
make mrproper # clean up build directory
make bcmrpi_defconfig # create config for Cirrus Logic audio card (same as official instructions)
make oldconfig # ensure config is up to date
make menuconfig # give kernel unique suffix : General Setup -> Local version
#zcat /proc/config.gz | diff - .config # compare with running config
uname -a # running kernel version
make kernelversion # new kernel version
make kernelrelease
nohup make & # compile (about 10 hours)
### compile and install kernel and modules
make KBUILD_DEBARCH=armhf deb-pkg # create packages
ver=$(make kernelrelease) # get release string
sudo dpkg -i ../linux-image-${ver}_${ver}-1_armhf.deb
sudo mv /boot/vmlinuz-${ver} /boot/kernel_new.img
sudo rm /boot/*${ver}
### configure bootloader and modules
sudo perl -i.original -pe 's/^\s*(kernel=.+)$/\#${1}/' /boot/config.txt
echo -e "\n#Use new kernel\nkernel=kernel_new.img" | sudo tee -a /boot/config.txt
sudo perl -i.original -pe 's/^(snd-bcm2835)/\#${1}/' /etc/modules # disable onboard sound
echo 'snd-soc-rpi-wsp' | sudo tee -a /etc/modules # enable Cirrus sound
sudo perl -i.original -pe 's/^(.+-bcm2708)/\#${1}/' /etc/modprobe.d/raspi-blacklist.conf # enable spi and i2c
echo 'softdep arizona-spi pre: arizona-ldo1
blacklist snd-soc-pcm512x
#blacklist snd-soc-wm8804
' | sudo tee -a /etc/modprobe.d/raspi-blacklist.conf
### configure alsa
echo 'pcm.!default {
type hw
card sndrpiwsp
}
ctl.!default {
type hw
card sndrpiwsp
}' > ~/.asoundrc
# power off, connect Cirrus Audio Card & reboot
sudo halt




