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 3131 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

    Tim Giles schrieb:

     

    It takes about 10 hours so let it run overnight.

    That's only one side of the truth. Do you know how to cross-compile a kernel. It takes me on an 8 core about 10 minutes!

    Take a look at

    http://elinux.org/Raspberry_Pi_Kernel_Compilation#2._Cross_compiling_from_Linux

    and have fun.

    If there's someone who likes to install a precompiled kernel in deb-format  (DOES NOT WORK FOR Raspberry Pi 2! ) ->

    https://blog.georgmill.de/2015/02/18/update-for-wolfson-audio-card-on-raspberry-pi/

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

    That's only one side of the truth. Do you know how to cross-compile a kernel. It takes me on an 8 core about 10 minutes!

    That's an incomplete truth.  It's a false generalization that's based upon the assumption that everyone uses a debian-type 32-bit compatible linux system.  Now that we're in the 21st Century, the world is full of 64-bit only installations and those boxes aren't going to result in a make that requires only 10-minutes of seat time.

     

    If a user happens to be running something like 32-bit Ubuntu on an 8-core box then he might succeed in a 10-minute 8-core make.  In that case, things will probably "just work" because as a matter of coincidence he happens to be running a backward-compatible system on the same type of backward-compatible platform as the guy who wrote the incomplete set of cross-compiling instructions that are tailored to that type of platform.  Try cross compiling a 32-bit deb target using a 64-bit-only RPM-based system and let us know how that works out.  There will be far less seat-time and a lot less frustration required if you compile natively on the Pi and let it run overnight.

     

    I've been building linux from source code for ~15 years.  I have my own 40-core distributed compiling farm.  I have enough experience with cross-compiling under distcc that I understand the pitfalls of cross-compiling, and that it's a bad idea to blindly recommend cross-compiling for everyone.  If a n00b is interested in compiling a kernel for the first time, I'd want to know exactly what kind of environment they're working in before making a recommendation that involved cross-compiling.  Cross-compiling can be fraught with errors while compiling in the native environment is simple by comparison.  Personally, I think that the recommendation to compile on the native platform is a more responsible recommendation to make, irrespective of how much wall-clock-time may be involved.

     

    In the big scheme of things, how much wall-clock-time it takes to compile a kernel isn't really relevant.  It's only relevant to someone who is intent on staring at the monitor and watching everything happen in real-time.

     

    I think that Tim is doing the community a great service by posting foolproof instructions on how to perform a native compile on the Raspberry Pi.  IMO too many guides offer only cross-compiling instructions, which I think is irresponsible and short-sighted.  I would not consider recommending cross-compiling until after I had performed the due diligence required to ensure that such a recommendation would work properly on the user's system.  Anything less amounts to a bum steer.

     

    Thanks for posting this, Tim.

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

    That's only one side of the truth. Do you know how to cross-compile a kernel. It takes me on an 8 core about 10 minutes!

    That's an incomplete truth.  It's a false generalization that's based upon the assumption that everyone uses a debian-type 32-bit compatible linux system.  Now that we're in the 21st Century, the world is full of 64-bit only installations and those boxes aren't going to result in a make that requires only 10-minutes of seat time.

     

    If a user happens to be running something like 32-bit Ubuntu on an 8-core box then he might succeed in a 10-minute 8-core make.  In that case, things will probably "just work" because as a matter of coincidence he happens to be running a backward-compatible system on the same type of backward-compatible platform as the guy who wrote the incomplete set of cross-compiling instructions that are tailored to that type of platform.  Try cross compiling a 32-bit deb target using a 64-bit-only RPM-based system and let us know how that works out.  There will be far less seat-time and a lot less frustration required if you compile natively on the Pi and let it run overnight.

     

    I've been building linux from source code for ~15 years.  I have my own 40-core distributed compiling farm.  I have enough experience with cross-compiling under distcc that I understand the pitfalls of cross-compiling, and that it's a bad idea to blindly recommend cross-compiling for everyone.  If a n00b is interested in compiling a kernel for the first time, I'd want to know exactly what kind of environment they're working in before making a recommendation that involved cross-compiling.  Cross-compiling can be fraught with errors while compiling in the native environment is simple by comparison.  Personally, I think that the recommendation to compile on the native platform is a more responsible recommendation to make, irrespective of how much wall-clock-time may be involved.

     

    In the big scheme of things, how much wall-clock-time it takes to compile a kernel isn't really relevant.  It's only relevant to someone who is intent on staring at the monitor and watching everything happen in real-time.

     

    I think that Tim is doing the community a great service by posting foolproof instructions on how to perform a native compile on the Raspberry Pi.  IMO too many guides offer only cross-compiling instructions, which I think is irresponsible and short-sighted.  I would not consider recommending cross-compiling until after I had performed the due diligence required to ensure that such a recommendation would work properly on the user's system.  Anything less amounts to a bum steer.

     

    Thanks for posting this, Tim.

    • 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