element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Raspberry Pi
  • Products
  • More
Raspberry Pi
Forum Driver fixes and updates to kernel 3.18.16 and 4.0.5
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Raspberry Pi requires membership for participation - click to join
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 180 replies
  • Subscribers 148 subscribers
  • Views 3441 views
  • Users 0 members are here
  • raspberry_pi
  • raspeberry_pi_accessories
Related

Driver fixes and updates to kernel 3.18.16 and 4.0.5

hiassoft
hiassoft over 6 years ago

Edit: Current kernel versions and install/config instructions are also available from my webpage http://www.horus.com/~hias/cirrus-driver.html

 

During the last few weeks I fixed various issues in the Wolfson/Cirrus driver and rebased it so it works with the current RPi kernel versions (3.18.16 and 4.0.5).

 

You can download the patches from my GitHub repository. The 3.18 kernel with Cirrus drivers is in the cirrus-3.18.y branch, the 4.0 kernel with Cirrus drivers is in the cirrus-4.0.y branch. I'll rebase and update these branches from time to time so that the Cirrus driver and my changes will stay on top of the commit list.

 

If you just want to have an updated 3.18.16 kernel you can download precompiled binaries from here. Just unpack the tarball in the root directory. Before you do that it might be a good idea to update the firmware files (bootcode.bin, start*.elf and fixup*.dat in the boot directory) to the latest version.

 

Here's a list of my changes:

- Added the FLL1 setup back so that switching between 44.1kHz and 48kHz (and other sample rates) works fine.

- Don't register Arizona IRQ if it's set to 0. The Cirrus driver uses polling here and if we register an interrupt handler for irq 0 we get lots of "spurious interrupt" messages spamming dmesg in kernel 3.19 and newer. IRQ 0 is wrong anyway.

- Include DCVDD patches from the Cirrus linux-drivers repository. These patches make sure the WM8804 chip is initialized properly. Without this patch I sometimes had SPDIF audio out only on the right channel.

- Disable spidev0 in Cirrus device tree overlay. That's mainly a safety precaution so that userspace programs trying to access spi0.0 won't interfere with the WM8804 reset line. I'm not 100% sure this is needed at all, so maybe I'll remove it some time later.

 

And some important notes:

I haven't included the mmap patch, this is already supported in the upstream kernels but currently disabled by default. To enable mmap support add the following line to config.txt:

dtoverlay=i2s-mmap

 

If you compile the kernel on your own please note that the devicetree overlays have now been moved to arch/arm/boot/dts/overlays.

 

Kernel 4.0 now uses spi_bcm2835 by default (the older spi_bcm2708 module is available via a devicetree overlay) so you have to extend your /etc/modprobe.d conf file and add a pre-depend for spi_bcm2835 as well. It's safe to have both the old and the new module in here, so just use this configuration:

softdep arizona-spi pre: arizona-ldo1
softdep spi-bcm2708 pre: fixed
softdep spi-bcm2835 pre: fixed

 

so long,

 

Hias

  • Reply
  • Cancel
  • Cancel

Top Replies

  • hiassoft
    hiassoft over 5 years ago in reply to Former Member +3

    I just had a look at volumio 2 (RC2 hotfix):

     

    It's setup is a quite different to Raspbian, it uses an initrd which sets up squashfs+overlayfs for the root partition. If you update the kernel, the modules…

  • hiassoft
    hiassoft over 6 years ago +2

    I've uploaded a new kernel build, based upon 4.1.19:

    http://www.horus.com/~hias/tmp/cirrus/cirrus-linux-4.1.19.tgz

     

    I finally found out what was causing the issues on the new RPi3 (other soundcards where…

  • markzed
    markzed over 6 years ago +1

    Thanks a bunch for doing this. For those of us who are really noobs (like me) here are detailed instructions.

     

    For 3.18.16

     

    • Get the 3.18.16 raspbian image. I used the Raspbian image provided by Raspberry Pi…
  • markzed
    markzed over 6 years ago

    Thanks a bunch for doing this. For those of us who are really noobs (like me) here are detailed instructions.

     

    For 3.18.16

     

    • Get the 3.18.16 raspbian image. I used the Raspbian image provided by Raspberry Pi org here: https://www.raspberrypi.org/downloads/
    • Do what you need to create the SD image, test it, expand it - see the Raspbian doc for this
    • Once you've verified it's working, untar the image pointed to in the main post:

    cd /

    sudo tar -xvzf path-to-the-gz-file

    sudo nano /boot/config.txt

      • add these two lines to the end of the config.txt file

    dtoverlay=rpi-cirrus-wm5102-overlay

    dtoverlay=i2s-mmap

    sudo nano /etc/modprobe.d/raspi-blacklist.conf

      • note the file may not be already there
      • add the three lines shown in the first post to the end of the file

    softdep arizona-spi pre: arizona-ldo1 

    softdep spi-bcm2708 pre: fixed 

    softdep spi-bcm2835 pre: fixed 

     

    Now reboot, via     sudo reboot


    To verify that everything is ok, type     aplay -l      in a terminal window and the first card should be sndrpiwsp shown as a WM5102

     

    Next, you'll want the scripts from Wolfson that make things straightforward. To get those, in a terminal window type (this is from https://github.com/CirrusLogic/rpi-linux/wiki/Building-the-code)

     

    cd ~
    git clone --depth 1 https://github.com/CirrusLogic/wiki-content.git
    mv wiki-content/scripts/* ~/
    chmod +x *.sh

     

    To really test this you can use aplay but it has limited support. I installed mplayer and had to edit my ~/.asoundrc file to point to card 0 by default. This plays well:

     

    mplayer -srate 96000 -format s32le music-file-path

    • Cancel
    • Up +1 Down
    • Reply
    • Cancel
  • timg73
    timg73 over 6 years ago

    Great work Matthias, thank you!

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • hiassoft
    hiassoft over 6 years ago

    Thanks a lot for the feedback!

     

    I've uploaded new compiled kernels, based on 4.0.9 (including commits up to today):

    http://www.horus.com/~hias/tmp/cirrus/cirrus-linux-4.0.9.tgz

     

    As before, just extract the tgz file in the root directory (as user root).

     

    This kernel now properly sets up the GPIO interrupt to the Wolfson/Cirrus card and I've removed the hack to disable the arizona IRQ.

     

    so long,

     

    Hias

    • Cancel
    • Up +1 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 6 years ago in reply to hiassoft

    Hi, I downloaded the RPI 3.18.x tgz file, went through the rebuilding of the kernel as specified by Cirrus Logic, (takes a day on Pi B) and when all is done, does not recognize the Wolfson card.

     

    Can someone just host a Pi B card image that works and has the DMA Engine fix so the memory leak doesn't panic the kernel after a week... I am using the 3.10.x image but was hoping to upgrade to a later kernel with the DMA engine fix.

     

    I need to record for 10 days straight without reboot for a scientific experiment and while a experienced software engineer, don't know that much about kernel rebuilds and drivers.

     

    shannon@simmunity.com

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 6 years ago

    FYI: For 4.1.x kernels, /etc/modprobe.d/raspi-blacklist.conf should contain

     

    softdep snd-soc-wm8804-i2c pre: snd-soc-rpi-wsp-preinit

    softdep snd-soc-rpi-wsp pre: snd-soc-wm8804-i2c

     

    My full file looks like this:

    softdep snd-soc-wm8804-i2c pre: snd-soc-rpi-wsp-preinit

    softdep snd-soc-rpi-wsp pre: snd-soc-wm8804-i2c

    softdep arizona-spi pre: arizona-ldo1

    softdep spi-bcm2708 pre: fixed

    softdep spi-bcm2835 pre: fixed

     

    Not sure if this 100% correct, but it works...

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • hiassoft
    hiassoft over 6 years ago in reply to Former Member

    Christoph Appel wrote:

    Not sure if this 100% correct, but it works...

    Yes, that's correct. You beat me to it, just wanted to post this info

     

    so long,

     

    Hias

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • hiassoft
    hiassoft over 6 years ago

    If you don't want to compile yourself, here's a precompiled 4.1.6+ kernel (tested with original Wolfson card on RPi B and Cirrus card on RPi 2):

    http://www.horus.com/~hias/tmp/cirrus/cirrus-linux-4.1.6.tgz

     

    As already mentioned you need to add 2 softdep lines to your modprobe configuration. Here's my /etc/modprobe.d/cirrus.conf file:

     

    softdep arizona-spi pre: arizona-ldo1
    softdep spi-bcm2708 pre: fixed
    softdep spi-bcm2835 pre: fixed
    softdep snd-soc-wm8804-i2c pre: snd-soc-rpi-wsp-preinit
    softdep snd-soc-rpi-wsp pre: snd-soc-wm8804-i2c

     

    Some background info about this new change:

     

    The Wolfson/Cirrus driver (snd-soc-rpi-wsp/rpi-cirrus-sound-pi.c) contained code to reset the wm8804 chip and initialize it to I2C mode by directly switching the GPIO pins, including the I2C pins. Unfortunately, this interfers with the Linux (deferred) driver loading mechanism. This WM8804 init code was called on each try to init the Cirrus driver which led to quite long delays until the driver would be loaded and, even worse, it could interfere with the WM8804 I2C detection. If WM8804 I2C detection is run when the Cirrus driver has taken over the GPIO pins the detection will fail and you end up with a non-working card.

     

    I ended up with the current solution, moving this one-time init code into a separate module and adding softdeps to ensure this WM8804 init is done before WM8804 detection and Cirrus driver loading. It's kind of a hack and I'm not 100% happy with the solution, but it seems to work fine. If someone has a better idea how to solve this, I'd be glad to hear about it!

     

    so long,

     

    Hias

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 6 years ago in reply to hiassoft

    Matthias,

     

    Hi, I apologize for being lame, but can you post an SD card full raspbian image to google drive or dropbox or an ftp download site so I can just try your solution.  I am out of ammo and time on building kernels and can't even get a 3.18.16 image, it is a 3.18.10 on the web site.  I have huge SD cards so if the image is large that is not a problem and I can reduce it for re-sharing.  I am sure that lots of folks will be interested in a decent, modern, driver leak fixed Wolfson Audio/Pi B and Pi 2 Raspbian image.  I'd be happy to host the image on our web site.  Really Cirrus Logic ought to host a correct, bug free image.

     

    Thanks for your hard work and consideration,

     

    Shannon

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • hiassoft
    hiassoft over 6 years ago in reply to Former Member

    Hi Shannon!

     

    Sorry, I can't provide an image. One reason is that my DSL upload speed really sucks, the other reason is that I'm not a huge fan of prebuilt images.

     

    Instead just do the following:

    • Do a standard raspbian installation, configure it to your likes (eg get rid of all that desktop stuff if you don't need it)
    • Do a "sudo apt-mark hold raspberrypi-bootloader" so that further raspbian updates won't overwrite the custom Cirrus kernel
    • Download the precompiled Cirrus kernel from this thread and the usecase scripts and install them (unpack the kernel in the root directory, as user root, unpack the usescase script tarball somewhere you like - eg /usr/local/bin or /home/pi/bin)
    • Edit /boot/config.txt and create the /etc/modprobe.d/cirrus.conf file as described

     

    That's all you need to do.

     

    so long,

     

    Hias

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
  • Former Member
    Former Member over 6 years ago

    Will this Kernel work for Arch Linux Distro on the RPi? I am not as famaiar with Arch as I am with Raspbian. Do you know if the Kernel compilation process the same?

    • Cancel
    • Up 0 Down
    • Reply
    • Cancel
>
Element14

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 © 2022 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube