element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Kernel compilation walk-through
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 24 replies
  • Subscribers 675 subscribers
  • Views 3141 views
  • Users 0 members are here
  • compilation
  • kernel
Related

Kernel compilation walk-through

timg73
timg73 over 10 years ago

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

  • Sign in to reply
  • Cancel
Parents
  • Former Member
    Former Member over 10 years ago

    I don't know what kind of problem you have with cross compiling. This will work  on ANY  64-bit linux system.

    All yours

    Georg

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Unfortunately, that statement isn't accurate.

     

    Read through the other thread about ELF errors.  Based on your experience, you should know what they are.

     

    The RPi is a 32-bit system.  You can't build 32-bit code on a 64-bit-only system, because the libraries required to build 32-bit code are absent.  You need to have a 32-bit toolkit installed on a 64-bit system to build 32-bit code, or you're guaranteed to fail. 

     

    It seems that a lot of people don't know this, probably because they've been blindly installing 32-bit libraries on their 64-bit systems without even knowing it, and they aren't aware of why they have success.  The truth is that it won't work on any 64-bit system; it will only work on a 64-bit system that has 32-bit ELF addressing.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Georg, you're doing Cirrus job for them. image

     

    Looking at the link that you posted, the tutorial reaffirms everything that I said earlier.  It is NOT possible to cross-compile the 32-bit kernel and drivers on a pure-64-bit system.  The first step in the tutorial that you referenced demonstrates how to perform the make by converting the 64-bit debian environment to a 32-bit debian environment.

     

    This is exactly what I was referring to earlier -- the people who can get the make to work are working in a 32-bit environment, not a 64-bit environment.  They just happen to be running a 32-bit environment on a 64-bit machine, perhaps without even realizing why they're successful.

     

    It's great that you're providing people with help about how to do this.  But the truth is that you're doing Cirrus jjob for them.  The developers at cirrus aren't even smart enough to realize there is a problem, and to include the solution in their kernel building guide.

     

    What a bunch of dolts.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    Gentlemen:

    I would be one of those Noobees who would be trying to work the Cirrus Logic card with RPi2 next week. I am not familiar with compiling a kernel for Unix even though I can maneuver around an Unix environment as I used to support a CRM system running on Solaris 8 and then AIX.  I am currently running an Ubuntu in a HyperV environment at home for Plex.  So looking at the all comments, it looks like the step for a Noobee like me is as follows:-

    1. Prepare a SD card with NOOBS from raspberrypi.org

    2. Boot up Raspberry PI and install RASBIAN

    3. Follow Tim's script

    4. Then attach the Cirrus Logic card to PI and reboot

     

    Thanks,

    Ahmed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    When I exectued the following line, it did not work and I could not find the ./cirrus-kernel folder.  I went through the steps all the way to end of "configure & compile kernel" section.

    tar -czvf ./cirrus-kernel/rpi-kernel-3-12-33-cirrus.tgz rpi-linux # save source as tar for next time

     

    I am hoping to execute the rest of the steps this evening.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • timg73
    timg73 over 10 years ago in reply to Former Member

    Hi Ahmed.  Just create that directory, or delete the "./cirrus-kernel/" part of the path name.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to timg73

    Tim, will do.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Former Member

    I was not able to get it to work and called to get a RMA for my card, but Newark told me to keep the card and they will refund the money.  Couple of the observations, I had are:-

    1. sudo mv /boot/vmlinuz-${ver} /boot/kernel_new.img  # you would have to be at the tmp folder as the images is created a level above rpi-linux folder

    2. I was getting no file found error after executing "sudo perl -i.original -pe 's/^(.+-bcm2708)/\#${1}/' /etc/modprobe.d/raspi-blacklist.conf"

    3. After the first compile, my RPI2 will not boot.  I had to press Shift and restore Raspbian again

    4. The second time, I tried, after "make oldconfig", I got this very huge interactive setup questions(a lot of it), I was hitting enter  to take the default and gave up on that after a while.  I don't remember seeing it the first time.

    5. At this point, I do have a card, I do not know what to do with.  I am just using the HDMI to send music through Kodi and BubbleUPnp to an Onkyo receiver

     

    Ahmed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • timg73
    timg73 over 10 years ago in reply to Former Member

    Ahmed, the instructions above were written for the 3.12 kernel, which does not work with the RPi2.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to timg73

    Sorry, I missed your very clear posting about the incompatibility in the previous thread, so now getting the angst against the Cirrus Logic folks.  Thanks for putting this together though and your willingness to help others.

     

    Ahmed

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to timg73

    Tim, your instructions work with the 3.18 kernel but the problem is there is no rpi-wolfson-sound-pi.c driver in 3.18. Thanks for the instructions, I was able to compile a kernel. Took around 2hrs on the pi2 to compile.

     

    https://github.com/CirrusLogic/rpi-linux/tree/rpi-3.12.y/sound/soc/bcm

     

    https://github.com/CirrusLogic/rpi-linux/tree/rpi-3.18.y/sound/soc/bcm

     

    Are these patch/driver useful or work for pi?

     

    http://opensource.wolfsonmicro.com/~git/asoc/

     

    https://github.com/CirrusLogic/linux-drivers

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • timg73
    timg73 over 10 years ago in reply to Former Member

    I've updated the instructions above to point to specific versions of Raspbian and the kernel.  I noticed on Github that Cirrus Logic have changed the default branch of the patched kernel to rpi-3.18.y, although this branch hasn't actually received any updates for 7 months.  The revised instructions above download the rpi-3.12.y branch, which is the most recent working version and was last updated 4 months ago.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • timg73
    timg73 over 10 years ago in reply to Former Member

    I've updated the instructions above to point to specific versions of Raspbian and the kernel.  I noticed on Github that Cirrus Logic have changed the default branch of the patched kernel to rpi-3.18.y, although this branch hasn't actually received any updates for 7 months.  The revised instructions above download the rpi-3.12.y branch, which is the most recent working version and was last updated 4 months ago.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube