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

    Hi,

     

    what I do need to change if I would like to compile 3.12.x    Cirrus Audio Code against the RPI 3.18.x  Kernel?  If I follow the Script it automatically selects teh 3.12 code stream.

     

    Did anybody try this already and did it work out? I would like to geht the Audio Card running onto the RPI 2.

     

    kind regards,

     

    --thomas

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

    The CLAC patches for the 3.12 kernel cannot be applied directly to the 3.18 kernel.  Thus the CL audio card is not (currently) compatible with the RPi 2.

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

    http://open-nandra.com/2011/10/compile-32bit-kernel-on-64-bit-machine-without-chroot-magic/

    • Cancel
    • Vote Up 0 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
>
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